mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
fix: player view artist link when local playlist is playing, lyric delay adjust button alignment
This commit is contained in:
parent
bc8a04e544
commit
ee5c417ac3
@ -44,12 +44,14 @@ class Genres extends HookConsumerWidget {
|
|||||||
.toList()
|
.toList()
|
||||||
];
|
];
|
||||||
|
|
||||||
|
final isMounted = useIsMounted();
|
||||||
|
|
||||||
return PlatformScaffold(
|
return PlatformScaffold(
|
||||||
appBar: kIsDesktop ? PageWindowTitleBar() : null,
|
appBar: kIsDesktop ? PageWindowTitleBar() : null,
|
||||||
body: Waypoint(
|
body: Waypoint(
|
||||||
onTouchEdge: () {
|
onTouchEdge: () async {
|
||||||
if (categoriesQuery.hasNextPage) {
|
if (categoriesQuery.hasNextPage && isMounted()) {
|
||||||
categoriesQuery.fetchNextPage();
|
await categoriesQuery.fetchNextPage();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
controller: scrollController,
|
controller: scrollController,
|
||||||
|
@ -71,7 +71,7 @@ class SyncedLyrics extends HookConsumerWidget {
|
|||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: breakpoint >= Breakpoints.md ? 50 : 30,
|
height: breakpoint >= Breakpoints.md ? 50 : 40,
|
||||||
child: Material(
|
child: Material(
|
||||||
type: MaterialType.transparency,
|
type: MaterialType.transparency,
|
||||||
textStyle: PlatformTheme.of(context).textTheme!.body!,
|
textStyle: PlatformTheme.of(context).textTheme!.body!,
|
||||||
@ -84,11 +84,11 @@ class SyncedLyrics extends HookConsumerWidget {
|
|||||||
isHovering: true,
|
isHovering: true,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Positioned.fill(
|
Positioned(
|
||||||
|
top: 10,
|
||||||
|
right: 10,
|
||||||
child: Align(
|
child: Align(
|
||||||
alignment: Alignment.centerRight,
|
alignment: Alignment.centerRight,
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: PlatformFilledButton(
|
child: PlatformFilledButton(
|
||||||
child: const Icon(
|
child: const Icon(
|
||||||
Icons.av_timer_rounded,
|
Icons.av_timer_rounded,
|
||||||
@ -97,8 +97,7 @@ class SyncedLyrics extends HookConsumerWidget {
|
|||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
final delay = await showPlatformAlertDialog(
|
final delay = await showPlatformAlertDialog(
|
||||||
context,
|
context,
|
||||||
builder: (context) =>
|
builder: (context) => const LyricDelayAdjustDialog(),
|
||||||
const LyricDelayAdjustDialog(),
|
|
||||||
);
|
);
|
||||||
if (delay != null) {
|
if (delay != null) {
|
||||||
ref.read(lyricDelayState.notifier).state = delay;
|
ref.read(lyricDelayState.notifier).state = delay;
|
||||||
@ -107,7 +106,6 @@ class SyncedLyrics extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -28,6 +28,7 @@ class PlayerActions extends HookConsumerWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, ref) {
|
Widget build(BuildContext context, ref) {
|
||||||
final Playback playback = ref.watch(playbackProvider);
|
final Playback playback = ref.watch(playbackProvider);
|
||||||
|
final isLocalTrack = playback.playlist?.isLocal == true;
|
||||||
final downloader = ref.watch(downloaderProvider);
|
final downloader = ref.watch(downloaderProvider);
|
||||||
final isInQueue =
|
final isInQueue =
|
||||||
downloader.inQueue.any((element) => element.id == playback.track?.id);
|
downloader.inQueue.any((element) => element.id == playback.track?.id);
|
||||||
@ -74,6 +75,7 @@ class PlayerActions extends HookConsumerWidget {
|
|||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
|
if (!isLocalTrack)
|
||||||
PlatformIconButton(
|
PlatformIconButton(
|
||||||
icon: const Icon(Icons.alt_route_rounded),
|
icon: const Icon(Icons.alt_route_rounded),
|
||||||
tooltip: "Alternative Track Sources",
|
tooltip: "Alternative Track Sources",
|
||||||
@ -99,7 +101,7 @@ class PlayerActions extends HookConsumerWidget {
|
|||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
if (!kIsWeb)
|
if (!kIsWeb && !isLocalTrack)
|
||||||
if (isInQueue)
|
if (isInQueue)
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
@ -120,7 +122,8 @@ class PlayerActions extends HookConsumerWidget {
|
|||||||
? () => downloader.addToQueue(playback.track!)
|
? () => downloader.addToQueue(playback.track!)
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
if (playback.track != null) TrackHeartButton(track: playback.track!),
|
if (playback.track != null && !isLocalTrack)
|
||||||
|
TrackHeartButton(track: playback.track!),
|
||||||
...(extraActions ?? [])
|
...(extraActions ?? [])
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
@ -6,6 +6,7 @@ import 'package:go_router/go_router.dart';
|
|||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:palette_generator/palette_generator.dart';
|
import 'package:palette_generator/palette_generator.dart';
|
||||||
import 'package:platform_ui/platform_ui.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/PlayerActions.dart';
|
||||||
import 'package:spotube/components/Player/PlayerControls.dart';
|
import 'package:spotube/components/Player/PlayerControls.dart';
|
||||||
import 'package:spotube/components/Shared/PageWindowTitleBar.dart';
|
import 'package:spotube/components/Shared/PageWindowTitleBar.dart';
|
||||||
@ -28,6 +29,9 @@ class PlayerView extends HookConsumerWidget {
|
|||||||
final currentTrack = ref.watch(playbackProvider.select(
|
final currentTrack = ref.watch(playbackProvider.select(
|
||||||
(value) => value.track,
|
(value) => value.track,
|
||||||
));
|
));
|
||||||
|
final isLocalTrack = ref.watch(playbackProvider.select(
|
||||||
|
(value) => value.playlist?.isLocal == true,
|
||||||
|
));
|
||||||
final breakpoint = useBreakpoints();
|
final breakpoint = useBreakpoints();
|
||||||
final canRotate = ref.watch(
|
final canRotate = ref.watch(
|
||||||
userPreferencesProvider.select((s) => s.rotatingAlbumArt),
|
userPreferencesProvider.select((s) => s.rotatingAlbumArt),
|
||||||
@ -102,6 +106,18 @@ class PlayerView extends HookConsumerWidget {
|
|||||||
isHovering: true,
|
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(
|
TypeConversionUtils.artists_X_ClickableArtists(
|
||||||
currentTrack?.artists ?? [],
|
currentTrack?.artists ?? [],
|
||||||
textStyle:
|
textStyle:
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
import 'package:visibility_detector/visibility_detector.dart';
|
import 'package:visibility_detector/visibility_detector.dart';
|
||||||
|
|
||||||
class Waypoint extends HookWidget {
|
class Waypoint extends HookWidget {
|
||||||
final void Function()? onTouchEdge;
|
final FutureOr<void> Function()? onTouchEdge;
|
||||||
final Widget? child;
|
final Widget? child;
|
||||||
final ScrollController controller;
|
final ScrollController controller;
|
||||||
final bool isGrid;
|
final bool isGrid;
|
||||||
@ -18,27 +20,31 @@ class Waypoint extends HookWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final isMounted = useIsMounted();
|
||||||
|
|
||||||
useEffect(() {
|
useEffect(() {
|
||||||
if (isGrid) {
|
if (isGrid) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
listener() {
|
Future<void> listener() async {
|
||||||
// nextPageTrigger will have a value equivalent to 80% of the list size.
|
// nextPageTrigger will have a value equivalent to 80% of the list size.
|
||||||
final nextPageTrigger = 0.8 * controller.position.maxScrollExtent;
|
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
|
// scrollController fetches the next paginated data when the current postion of the user on the screen has surpassed
|
||||||
if (controller.position.pixels >= nextPageTrigger) {
|
if (controller.position.pixels >= nextPageTrigger && isMounted()) {
|
||||||
onTouchEdge?.call();
|
await onTouchEdge?.call();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (controller.hasClients) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
if (controller.hasClients && isMounted()) {
|
||||||
listener();
|
listener();
|
||||||
}
|
}
|
||||||
|
|
||||||
controller.addListener(listener);
|
controller.addListener(listener);
|
||||||
|
});
|
||||||
return () => controller.removeListener(listener);
|
return () => controller.removeListener(listener);
|
||||||
}, [controller, onTouchEdge]);
|
}, [controller, onTouchEdge, isMounted]);
|
||||||
|
|
||||||
if (isGrid) {
|
if (isGrid) {
|
||||||
return VisibilityDetector(
|
return VisibilityDetector(
|
||||||
|
@ -154,12 +154,24 @@ const iosDarkTheme = CupertinoThemeData(
|
|||||||
);
|
);
|
||||||
|
|
||||||
final linuxTheme = AdwaitaThemeData.light().copyWith(
|
final linuxTheme = AdwaitaThemeData.light().copyWith(
|
||||||
|
extensions: [
|
||||||
|
ShimmerColorTheme(
|
||||||
|
shimmerBackgroundColor: Colors.grey[300],
|
||||||
|
shimmerColor: Colors.grey[400],
|
||||||
|
)
|
||||||
|
],
|
||||||
listTileTheme: ListTileThemeData(
|
listTileTheme: ListTileThemeData(
|
||||||
iconColor: Colors.grey[900],
|
iconColor: Colors.grey[900],
|
||||||
horizontalTitleGap: 0,
|
horizontalTitleGap: 0,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
final linuxDarkTheme = AdwaitaThemeData.dark().copyWith(
|
final linuxDarkTheme = AdwaitaThemeData.dark().copyWith(
|
||||||
|
extensions: [
|
||||||
|
ShimmerColorTheme(
|
||||||
|
shimmerBackgroundColor: Colors.grey[800],
|
||||||
|
shimmerColor: Colors.grey[900],
|
||||||
|
)
|
||||||
|
],
|
||||||
listTileTheme: ListTileThemeData(
|
listTileTheme: ListTileThemeData(
|
||||||
iconColor: Colors.grey[50],
|
iconColor: Colors.grey[50],
|
||||||
horizontalTitleGap: 0,
|
horizontalTitleGap: 0,
|
||||||
|
Loading…
Reference in New Issue
Block a user