fix: player view artist link when local playlist is playing, lyric delay adjust button alignment

This commit is contained in:
Kingkor Roy Tirtho 2022-12-07 13:27:46 +06:00
parent bc8a04e544
commit ee5c417ac3
6 changed files with 107 additions and 70 deletions

View File

@ -44,12 +44,14 @@ class Genres extends HookConsumerWidget {
.toList()
];
final isMounted = useIsMounted();
return PlatformScaffold(
appBar: kIsDesktop ? PageWindowTitleBar() : null,
body: Waypoint(
onTouchEdge: () {
if (categoriesQuery.hasNextPage) {
categoriesQuery.fetchNextPage();
onTouchEdge: () async {
if (categoriesQuery.hasNextPage && isMounted()) {
await categoriesQuery.fetchNextPage();
}
},
controller: scrollController,

View File

@ -71,7 +71,7 @@ class SyncedLyrics extends HookConsumerWidget {
return Column(
children: [
SizedBox(
height: breakpoint >= Breakpoints.md ? 50 : 30,
height: breakpoint >= Breakpoints.md ? 50 : 40,
child: Material(
type: MaterialType.transparency,
textStyle: PlatformTheme.of(context).textTheme!.body!,
@ -84,11 +84,11 @@ class SyncedLyrics extends HookConsumerWidget {
isHovering: true,
),
),
Positioned.fill(
Positioned(
top: 10,
right: 10,
child: Align(
alignment: Alignment.centerRight,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: PlatformFilledButton(
child: const Icon(
Icons.av_timer_rounded,
@ -97,8 +97,7 @@ class SyncedLyrics extends HookConsumerWidget {
onPressed: () async {
final delay = await showPlatformAlertDialog(
context,
builder: (context) =>
const LyricDelayAdjustDialog(),
builder: (context) => const LyricDelayAdjustDialog(),
);
if (delay != null) {
ref.read(lyricDelayState.notifier).state = delay;
@ -107,7 +106,6 @@ class SyncedLyrics extends HookConsumerWidget {
),
),
),
),
],
),
),

View File

@ -28,6 +28,7 @@ class PlayerActions extends HookConsumerWidget {
@override
Widget build(BuildContext context, ref) {
final Playback playback = ref.watch(playbackProvider);
final isLocalTrack = playback.playlist?.isLocal == true;
final downloader = ref.watch(downloaderProvider);
final isInQueue =
downloader.inQueue.any((element) => element.id == playback.track?.id);
@ -74,6 +75,7 @@ class PlayerActions extends HookConsumerWidget {
}
: null,
),
if (!isLocalTrack)
PlatformIconButton(
icon: const Icon(Icons.alt_route_rounded),
tooltip: "Alternative Track Sources",
@ -99,7 +101,7 @@ class PlayerActions extends HookConsumerWidget {
}
: null,
),
if (!kIsWeb)
if (!kIsWeb && !isLocalTrack)
if (isInQueue)
const SizedBox(
height: 20,
@ -120,7 +122,8 @@ class PlayerActions extends HookConsumerWidget {
? () => downloader.addToQueue(playback.track!)
: null,
),
if (playback.track != null) TrackHeartButton(track: playback.track!),
if (playback.track != null && !isLocalTrack)
TrackHeartButton(track: playback.track!),
...(extraActions ?? [])
],
);

View File

@ -6,6 +6,7 @@ import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:palette_generator/palette_generator.dart';
import 'package:platform_ui/platform_ui.dart';
import 'package:spotify/spotify.dart';
import 'package:spotube/components/Player/PlayerActions.dart';
import 'package:spotube/components/Player/PlayerControls.dart';
import 'package:spotube/components/Shared/PageWindowTitleBar.dart';
@ -28,6 +29,9 @@ class PlayerView extends HookConsumerWidget {
final currentTrack = ref.watch(playbackProvider.select(
(value) => value.track,
));
final isLocalTrack = ref.watch(playbackProvider.select(
(value) => value.playlist?.isLocal == true,
));
final breakpoint = useBreakpoints();
final canRotate = ref.watch(
userPreferencesProvider.select((s) => s.rotatingAlbumArt),
@ -102,6 +106,18 @@ class PlayerView extends HookConsumerWidget {
isHovering: true,
),
),
if (isLocalTrack)
Text(
TypeConversionUtils.artists_X_String<Artist>(
currentTrack?.artists ?? [],
),
style:
Theme.of(context).textTheme.headline6!.copyWith(
fontWeight: FontWeight.bold,
color: paletteColor.bodyTextColor,
),
)
else
TypeConversionUtils.artists_X_ClickableArtists(
currentTrack?.artists ?? [],
textStyle:

View File

@ -1,9 +1,11 @@
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:visibility_detector/visibility_detector.dart';
class Waypoint extends HookWidget {
final void Function()? onTouchEdge;
final FutureOr<void> Function()? onTouchEdge;
final Widget? child;
final ScrollController controller;
final bool isGrid;
@ -18,27 +20,31 @@ class Waypoint extends HookWidget {
@override
Widget build(BuildContext context) {
final isMounted = useIsMounted();
useEffect(() {
if (isGrid) {
return null;
}
listener() {
Future<void> listener() async {
// nextPageTrigger will have a value equivalent to 80% of the list size.
final nextPageTrigger = 0.8 * controller.position.maxScrollExtent;
// scrollController fetches the next paginated data when the current postion of the user on the screen has surpassed
if (controller.position.pixels >= nextPageTrigger) {
onTouchEdge?.call();
if (controller.position.pixels >= nextPageTrigger && isMounted()) {
await onTouchEdge?.call();
}
}
if (controller.hasClients) {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (controller.hasClients && isMounted()) {
listener();
}
controller.addListener(listener);
});
return () => controller.removeListener(listener);
}, [controller, onTouchEdge]);
}, [controller, onTouchEdge, isMounted]);
if (isGrid) {
return VisibilityDetector(

View File

@ -154,12 +154,24 @@ const iosDarkTheme = CupertinoThemeData(
);
final linuxTheme = AdwaitaThemeData.light().copyWith(
extensions: [
ShimmerColorTheme(
shimmerBackgroundColor: Colors.grey[300],
shimmerColor: Colors.grey[400],
)
],
listTileTheme: ListTileThemeData(
iconColor: Colors.grey[900],
horizontalTitleGap: 0,
),
);
final linuxDarkTheme = AdwaitaThemeData.dark().copyWith(
extensions: [
ShimmerColorTheme(
shimmerBackgroundColor: Colors.grey[800],
shimmerColor: Colors.grey[900],
)
],
listTileTheme: ListTileThemeData(
iconColor: Colors.grey[50],
horizontalTitleGap: 0,