Blur effect applied in Lyrics, PlayerView & PlayerOverlay

Drag to scroll support for Playlist Categories
Sidebar user name & settings icon moved down
This commit is contained in:
Kingkor Roy Tirtho 2022-07-05 14:08:56 +06:00
parent 7e24059900
commit da2e371dfd
13 changed files with 595 additions and 384 deletions

View File

@ -1,3 +1,4 @@
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart' hide Page; import 'package:flutter/material.dart' hide Page;
import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart';
@ -65,14 +66,23 @@ class CategoryCard extends HookConsumerWidget {
? const Text("Something Went Wrong") ? const Text("Something Went Wrong")
: SizedBox( : SizedBox(
height: 245, height: 245,
child: ScrollConfiguration(
behavior: ScrollConfiguration.of(context).copyWith(
dragDevices: {
PointerDeviceKind.touch,
PointerDeviceKind.mouse,
},
),
child: Scrollbar( child: Scrollbar(
controller: scrollController, controller: scrollController,
interactive: false,
child: PagedListView<int, PlaylistSimple>( child: PagedListView<int, PlaylistSimple>(
shrinkWrap: true, shrinkWrap: true,
pagingController: pagingController, pagingController: pagingController,
scrollController: scrollController, scrollController: scrollController,
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
builderDelegate: PagedChildBuilderDelegate<PlaylistSimple>( builderDelegate:
PagedChildBuilderDelegate<PlaylistSimple>(
noItemsFoundIndicatorBuilder: (context) { noItemsFoundIndicatorBuilder: (context) {
return const NotFound(); return const NotFound();
}, },
@ -88,7 +98,8 @@ class CategoryCard extends HookConsumerWidget {
), ),
), ),
), ),
) ),
),
], ],
); );
} }

View File

@ -74,9 +74,11 @@ class Home extends HookConsumerWidget {
if (!Platform.isMacOS && !kIsMobile) if (!Platform.isMacOS && !kIsMobile)
const TitleBarActionButtons(), const TitleBarActionButtons(),
], ],
)) ),
)
], ],
)); ),
);
final backgroundColor = Theme.of(context).backgroundColor; final backgroundColor = Theme.of(context).backgroundColor;
@ -96,6 +98,7 @@ class Home extends HookConsumerWidget {
child: Scaffold( child: Scaffold(
body: Column( body: Column(
children: [ children: [
if (_selectedIndex.value != 3)
kIsMobile kIsMobile
? titleBarContents ? titleBarContents
: WindowTitleBarBox(child: titleBarContents), : WindowTitleBarBox(child: titleBarContents),
@ -110,7 +113,11 @@ class Home extends HookConsumerWidget {
if (_selectedIndex.value == 0) if (_selectedIndex.value == 0)
Expanded( Expanded(
child: Padding( child: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.only(
bottom: 8.0,
top: 8.0,
left: 8.0,
),
child: HookBuilder(builder: (context) { child: HookBuilder(builder: (context) {
final pagingController = usePaginatedFutureProvider< final pagingController = usePaginatedFutureProvider<
Page<Category>, int, Category>( Page<Category>, int, Category>(

View File

@ -1,9 +1,11 @@
import 'package:bitsdojo_window/bitsdojo_window.dart';
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:spotube/helpers/image-to-url-string.dart'; import 'package:spotube/helpers/image-to-url-string.dart';
import 'package:spotube/hooks/useBreakpointValue.dart';
import 'package:spotube/hooks/useBreakpoints.dart'; import 'package:spotube/hooks/useBreakpoints.dart';
import 'package:spotube/models/sideBarTiles.dart'; import 'package:spotube/models/sideBarTiles.dart';
import 'package:spotube/provider/SpotifyRequests.dart'; import 'package:spotube/provider/SpotifyRequests.dart';
@ -37,6 +39,14 @@ class Sidebar extends HookConsumerWidget {
final extended = useState(false); final extended = useState(false);
final meSnapshot = ref.watch(currentUserQuery); final meSnapshot = ref.watch(currentUserQuery);
final int titleBarDragMaxWidth = useBreakpointValue(
md: 80,
lg: 256,
sm: 0,
xl: 0,
xxl: 0,
);
useEffect(() { useEffect(() {
if (breakpoints.isMd && extended.value) { if (breakpoints.isMd && extended.value) {
extended.value = false; extended.value = false;
@ -47,7 +57,32 @@ class Sidebar extends HookConsumerWidget {
return null; return null;
}); });
return NavigationRail( return Material(
color: Theme.of(context).navigationRailTheme.backgroundColor,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (selectedIndex == 3)
SizedBox(
height: appWindow.titleBarHeight,
width: titleBarDragMaxWidth.toDouble(),
child: MoveWindow(),
),
extended.value
? Padding(
padding: const EdgeInsets.only(left: 15),
child: Row(children: [
_buildSmallLogo(),
const SizedBox(
width: 10,
),
Text("Spotube",
style: Theme.of(context).textTheme.headline4),
]),
)
: _buildSmallLogo(),
Expanded(
child: NavigationRail(
destinations: sidebarTileList destinations: sidebarTileList
.map( .map(
(e) => NavigationRailDestination( (e) => NavigationRailDestination(
@ -65,24 +100,16 @@ class Sidebar extends HookConsumerWidget {
selectedIndex: selectedIndex, selectedIndex: selectedIndex,
onDestinationSelected: onSelectedIndexChanged, onDestinationSelected: onSelectedIndexChanged,
extended: extended.value, extended: extended.value,
leading: extended.value
? Padding(
padding: const EdgeInsets.only(left: 15),
child: Row(children: [
_buildSmallLogo(),
const SizedBox(
width: 10,
), ),
Text("Spotube", style: Theme.of(context).textTheme.headline4), ),
]), SizedBox(
) width: titleBarDragMaxWidth.toDouble(),
: _buildSmallLogo(), child: meSnapshot.when(
trailing: meSnapshot.when(
data: (data) { data: (data) {
final avatarImg = imageToUrlString(data.images, final avatarImg = imageToUrlString(data.images,
index: (data.images?.length ?? 1) - 1); index: (data.images?.length ?? 1) - 1);
return extended.value if (extended.value) {
? Padding( return Padding(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
@ -106,17 +133,25 @@ class Sidebar extends HookConsumerWidget {
icon: const Icon(Icons.settings_outlined), icon: const Icon(Icons.settings_outlined),
onPressed: () => goToSettings(context)), onPressed: () => goToSettings(context)),
], ],
)) ));
: InkWell( } else {
return Padding(
padding: const EdgeInsets.all(8.0),
child: InkWell(
onTap: () => goToSettings(context), onTap: () => goToSettings(context),
child: CircleAvatar( child: CircleAvatar(
backgroundImage: CachedNetworkImageProvider(avatarImg), backgroundImage: CachedNetworkImageProvider(avatarImg),
), ),
),
); );
}
}, },
error: (e, _) => Text("Error $e"), error: (e, _) => Text("Error $e"),
loading: () => const CircularProgressIndicator(), loading: () => const CircularProgressIndicator(),
), ),
)
],
),
); );
} }
} }

View File

@ -2,13 +2,18 @@ import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:spotify/spotify.dart'; import 'package:spotify/spotify.dart';
import 'package:spotube/components/LoaderShimmers/ShimmerLyrics.dart'; import 'package:spotube/components/LoaderShimmers/ShimmerLyrics.dart';
import 'package:spotube/components/Shared/PageWindowTitleBar.dart';
import 'package:spotube/helpers/artist-to-string.dart'; import 'package:spotube/helpers/artist-to-string.dart';
import 'package:spotube/hooks/useBreakpoints.dart'; import 'package:spotube/hooks/useBreakpoints.dart';
import 'package:spotube/provider/Playback.dart'; import 'package:spotube/provider/Playback.dart';
import 'package:spotube/provider/SpotifyRequests.dart'; import 'package:spotube/provider/SpotifyRequests.dart';
class Lyrics extends HookConsumerWidget { class Lyrics extends HookConsumerWidget {
const Lyrics({Key? key}) : super(key: key); final Color? titleBarForegroundColor;
const Lyrics({
required this.titleBarForegroundColor,
Key? key,
}) : super(key: key);
@override @override
Widget build(BuildContext context, ref) { Widget build(BuildContext context, ref) {
@ -17,10 +22,10 @@ class Lyrics extends HookConsumerWidget {
final breakpoint = useBreakpoints(); final breakpoint = useBreakpoints();
final textTheme = Theme.of(context).textTheme; final textTheme = Theme.of(context).textTheme;
return Expanded( return Column(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
PageWindowTitleBar(foregroundColor: titleBarForegroundColor),
Center( Center(
child: Text( child: Text(
playback.track?.name ?? "", playback.track?.name ?? "",
@ -68,7 +73,6 @@ class Lyrics extends HookConsumerWidget {
), ),
) )
], ],
),
); );
} }
} }

View File

@ -1,13 +1,20 @@
import 'dart:ui';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:palette_generator/palette_generator.dart';
import 'package:spotify/spotify.dart'; import 'package:spotify/spotify.dart';
import 'package:spotube/components/LoaderShimmers/ShimmerLyrics.dart'; import 'package:spotube/components/LoaderShimmers/ShimmerLyrics.dart';
import 'package:spotube/components/Lyrics/Lyrics.dart'; import 'package:spotube/components/Lyrics/Lyrics.dart';
import 'package:spotube/components/Shared/PageWindowTitleBar.dart';
import 'package:spotube/components/Shared/SpotubeMarqueeText.dart'; import 'package:spotube/components/Shared/SpotubeMarqueeText.dart';
import 'package:spotube/helpers/artist-to-string.dart'; import 'package:spotube/helpers/artist-to-string.dart';
import 'package:spotube/helpers/image-to-url-string.dart';
import 'package:spotube/hooks/useAutoScrollController.dart'; import 'package:spotube/hooks/useAutoScrollController.dart';
import 'package:spotube/hooks/useBreakpoints.dart'; import 'package:spotube/hooks/useBreakpoints.dart';
import 'package:spotube/hooks/usePaletteColor.dart';
import 'package:spotube/hooks/useSyncedLyrics.dart'; import 'package:spotube/hooks/useSyncedLyrics.dart';
import 'package:spotube/provider/Playback.dart'; import 'package:spotube/provider/Playback.dart';
import 'package:scroll_to_index/scroll_to_index.dart'; import 'package:scroll_to_index/scroll_to_index.dart';
@ -88,14 +95,44 @@ class SyncedLyrics extends HookConsumerWidget {
}, [lyricValue]); }, [lyricValue]);
// when synced lyrics not found, fallback to GeniusLyrics // when synced lyrics not found, fallback to GeniusLyrics
if (failed.value) return const Lyrics();
final headlineTextStyle = breakpoint >= Breakpoints.md String albumArt = useMemoized(
() => imageToUrlString(
playback.track?.album?.images,
index: (playback.track?.album?.images?.length ?? 1) - 1,
),
[playback.track?.album?.images],
);
final palette = usePaletteColor(albumArt, ref);
final headlineTextStyle = (breakpoint >= Breakpoints.md
? textTheme.headline3 ? textTheme.headline3
: textTheme.headline4?.copyWith(fontSize: 25); : textTheme.headline4?.copyWith(fontSize: 25))
?.copyWith(color: palette.titleTextColor);
return Expanded( return Expanded(
child: Column( child: Container(
clipBehavior: Clip.hardEdge,
decoration: BoxDecoration(
image: DecorationImage(
image: CachedNetworkImageProvider(
albumArt,
cacheKey: albumArt,
),
fit: BoxFit.cover,
),
),
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 15, sigmaY: 15),
child: Container(
color: palette.color.withOpacity(.7),
child: failed.value
? Lyrics(titleBarForegroundColor: palette.bodyTextColor)
: Column(
children: [ children: [
PageWindowTitleBar(
foregroundColor: palette.bodyTextColor,
),
Center( Center(
child: SizedBox( child: SizedBox(
height: breakpoint >= Breakpoints.md ? 50 : 30, height: breakpoint >= Breakpoints.md ? 50 : 30,
@ -112,7 +149,8 @@ class SyncedLyrics extends HookConsumerWidget {
)), )),
Center( Center(
child: Text( child: Text(
artistsToString<Artist>(playback.track?.artists ?? []), artistsToString<Artist>(
playback.track?.artists ?? []),
style: breakpoint >= Breakpoints.md style: breakpoint >= Breakpoints.md
? textTheme.headline5 ? textTheme.headline5
: textTheme.headline6, : textTheme.headline6,
@ -125,7 +163,8 @@ class SyncedLyrics extends HookConsumerWidget {
itemCount: lyricValue.lyrics.length, itemCount: lyricValue.lyrics.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
final lyricSlice = lyricValue.lyrics[index]; final lyricSlice = lyricValue.lyrics[index];
final isActive = lyricSlice.time.inSeconds == currentTime; final isActive =
lyricSlice.time.inSeconds == currentTime;
if (isActive) { if (isActive) {
controller.scrollToIndex( controller.scrollToIndex(
index, index,
@ -145,8 +184,9 @@ class SyncedLyrics extends HookConsumerWidget {
// indicating the active state of that lyric slice // indicating the active state of that lyric slice
color: isActive color: isActive
? Theme.of(context).primaryColor ? Theme.of(context).primaryColor
: null, : palette.bodyTextColor,
fontWeight: isActive ? FontWeight.bold : null, fontWeight:
isActive ? FontWeight.bold : null,
fontSize: 30, fontSize: 30,
), ),
textAlign: TextAlign.center, textAlign: TextAlign.center,
@ -158,10 +198,14 @@ class SyncedLyrics extends HookConsumerWidget {
), ),
), ),
if (playback.track != null && if (playback.track != null &&
(lyricValue == null || lyricValue.lyrics.isEmpty == true)) (lyricValue == null ||
lyricValue.lyrics.isEmpty == true))
const Expanded(child: ShimmerLyrics()), const Expanded(child: ShimmerLyrics()),
], ],
), ),
),
),
),
); );
} }
} }

View File

@ -13,8 +13,10 @@ import 'package:spotube/provider/SpotifyRequests.dart';
class PlayerActions extends HookConsumerWidget { class PlayerActions extends HookConsumerWidget {
final MainAxisAlignment mainAxisAlignment; final MainAxisAlignment mainAxisAlignment;
final bool floatingQueue;
PlayerActions({ PlayerActions({
this.mainAxisAlignment = MainAxisAlignment.center, this.mainAxisAlignment = MainAxisAlignment.center,
this.floatingQueue = true,
Key? key, Key? key,
}) : super(key: key); }) : super(key: key);
final logger = getLogger(PlayerActions); final logger = getLogger(PlayerActions);
@ -37,7 +39,8 @@ class PlayerActions extends HookConsumerWidget {
isDismissible: true, isDismissible: true,
enableDrag: true, enableDrag: true,
isScrollControlled: true, isScrollControlled: true,
backgroundColor: Colors.transparent, backgroundColor: Colors.black12,
barrierColor: Colors.black12,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10), borderRadius: BorderRadius.circular(10),
), ),
@ -45,7 +48,7 @@ class PlayerActions extends HookConsumerWidget {
maxHeight: MediaQuery.of(context).size.height * .7, maxHeight: MediaQuery.of(context).size.height * .7,
), ),
builder: (context) { builder: (context) {
return const PlayerQueue(); return PlayerQueue(floating: floatingQueue);
}, },
); );
} }

View File

@ -8,6 +8,7 @@ import 'package:spotube/provider/Playback.dart';
class PlayerControls extends HookConsumerWidget { class PlayerControls extends HookConsumerWidget {
final Color? iconColor; final Color? iconColor;
PlayerControls({ PlayerControls({
this.iconColor, this.iconColor,
Key? key, Key? key,

View File

@ -1,3 +1,5 @@
import 'dart:ui';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart';
@ -20,7 +22,7 @@ class PlayerOverlay extends HookConsumerWidget {
Widget build(BuildContext context, ref) { Widget build(BuildContext context, ref) {
final breakpoint = useBreakpoints(); final breakpoint = useBreakpoints();
final isCurrentRoute = useIsCurrentRoute("/"); final isCurrentRoute = useIsCurrentRoute("/");
final paletteColor = usePaletteColor(context, albumArt, ref); final paletteColor = usePaletteColor(albumArt, ref);
final playback = ref.watch(playbackProvider); final playback = ref.watch(playbackProvider);
if (isCurrentRoute == false) { if (isCurrentRoute == false) {
@ -45,12 +47,20 @@ class PlayerOverlay extends HookConsumerWidget {
GoRouter.of(context).push("/player"); GoRouter.of(context).push("/player");
} }
}, },
child: ClipRRect(
borderRadius: BorderRadius.circular(5),
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 15, sigmaY: 15),
child: AnimatedContainer( child: AnimatedContainer(
duration: const Duration(milliseconds: 500), duration: const Duration(milliseconds: 500),
width: MediaQuery.of(context).size.width, width: MediaQuery.of(context).size.width,
height: 50, height: 50,
decoration: BoxDecoration( decoration: BoxDecoration(
color: paletteColor.color, color: paletteColor.color.withOpacity(.7),
border: Border.all(
color: paletteColor.titleTextColor,
width: 2,
),
borderRadius: BorderRadius.circular(5), borderRadius: BorderRadius.circular(5),
), ),
child: Material( child: Material(
@ -99,6 +109,8 @@ class PlayerOverlay extends HookConsumerWidget {
), ),
), ),
), ),
),
),
); );
} }
} }

View File

@ -1,56 +1,103 @@
import 'dart:ui'; import 'dart:ui';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:scroll_to_index/scroll_to_index.dart';
import 'package:spotube/components/Shared/NotFound.dart'; import 'package:spotube/components/Shared/NotFound.dart';
import 'package:spotube/components/Shared/TrackTile.dart'; import 'package:spotube/components/Shared/TrackTile.dart';
import 'package:spotube/helpers/image-to-url-string.dart'; import 'package:spotube/helpers/image-to-url-string.dart';
import 'package:spotube/helpers/zero-pad-num-str.dart'; import 'package:spotube/helpers/zero-pad-num-str.dart';
import 'package:spotube/hooks/useAutoScrollController.dart';
import 'package:spotube/provider/Playback.dart'; import 'package:spotube/provider/Playback.dart';
import 'package:collection/collection.dart';
class PlayerQueue extends HookConsumerWidget { class PlayerQueue extends HookConsumerWidget {
const PlayerQueue({Key? key}) : super(key: key); final bool floating;
const PlayerQueue({
this.floating = true,
Key? key,
}) : super(key: key);
@override @override
Widget build(BuildContext context, ref) { Widget build(BuildContext context, ref) {
final playback = ref.watch(playbackProvider); final playback = ref.watch(playbackProvider);
final controller = useAutoScrollController();
final tracks = playback.playlist?.tracks ?? []; final tracks = playback.playlist?.tracks ?? [];
if (tracks.isEmpty) { if (tracks.isEmpty) {
return const NotFound(vertical: true); return const NotFound(vertical: true);
} }
final borderRadius = floating
? BorderRadius.circular(10)
: const BorderRadius.only(
topLeft: Radius.circular(10),
topRight: Radius.circular(10),
);
final headlineColor = Theme.of(context).textTheme.headline4?.color;
useEffect(() {
if (playback.track == null || playback.playlist == null) return null;
final index = playback.playlist!.tracks
.indexWhere((track) => track.id == playback.track!.id);
if (index < 0) return;
controller.scrollToIndex(
index,
preferPosition: AutoScrollPosition.middle,
);
return null;
}, []);
return BackdropFilter( return BackdropFilter(
filter: ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0), filter: ImageFilter.blur(
sigmaX: 12.0,
sigmaY: 12.0,
),
child: Container( child: Container(
margin: EdgeInsets.all(floating ? 8.0 : 0),
padding: const EdgeInsets.only(
top: 5.0,
),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Theme.of(context) color: Theme.of(context)
.navigationRailTheme .navigationRailTheme
.backgroundColor .backgroundColor
?.withOpacity(0.5), ?.withOpacity(0.5),
borderRadius: BorderRadius.circular(10), borderRadius: borderRadius,
),
margin: const EdgeInsets.all(8.0),
padding: const EdgeInsets.only(
top: 5.0,
), ),
child: Column( child: Column(
children: [ children: [
Container(
height: 5,
width: 100,
margin: const EdgeInsets.only(bottom: 5, top: 2),
decoration: BoxDecoration(
color: headlineColor,
borderRadius: BorderRadius.circular(20),
),
),
Text( Text(
"Queue (${playback.playlist?.name})", "Queue (${playback.playlist?.name})",
style: Theme.of(context).textTheme.headline4, style: Theme.of(context).textTheme.headline4?.copyWith(
fontWeight: FontWeight.bold,
),
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
const SizedBox(height: 10),
Flexible( Flexible(
child: ListView( child: ListView.builder(
controller: controller,
itemCount: tracks.length,
shrinkWrap: true, shrinkWrap: true,
children: [ itemBuilder: (context, i) {
...tracks.asMap().entries.mapIndexed((i, track) { final track = tracks.asMap().entries.elementAt(i);
String duration = String duration =
"${track.value.duration?.inMinutes.remainder(60)}:${zeroPadNumStr(track.value.duration?.inSeconds.remainder(60) ?? 0)}"; "${track.value.duration?.inMinutes.remainder(60)}:${zeroPadNumStr(track.value.duration?.inSeconds.remainder(60) ?? 0)}";
return Padding( return AutoScrollTag(
key: ValueKey(i),
controller: controller,
index: i,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0), padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: TrackTile( child: TrackTile(
playback, playback,
@ -64,10 +111,9 @@ class PlayerQueue extends HookConsumerWidget {
await playback.setPlaylistPosition(i); await playback.setPlaylistPosition(i);
}, },
), ),
),
); );
}), }),
],
),
), ),
], ],
), ),

View File

@ -1,3 +1,5 @@
import 'dart:ui';
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_hooks/flutter_hooks.dart';
@ -44,22 +46,38 @@ class PlayerView extends HookConsumerWidget {
[currentTrack?.album?.images], [currentTrack?.album?.images],
); );
final PaletteColor paletteColor = usePaletteColor(context, albumArt, ref); final PaletteColor paletteColor = usePaletteColor(albumArt, ref);
useCustomStatusBarColor( useCustomStatusBarColor(
paletteColor.color, paletteColor.color,
GoRouter.of(context).location == "/player", GoRouter.of(context).location == "/player",
noSetBGColor: true,
); );
return SafeArea( return SafeArea(
child: Scaffold( child: Scaffold(
appBar: const PageWindowTitleBar( // backgroundColor: paletteColor.color,
leading: BackButton(), body: Container(
backgroundColor: Colors.transparent, decoration: BoxDecoration(
image: DecorationImage(
image: CachedNetworkImageProvider(
albumArt,
cacheKey: albumArt,
), ),
backgroundColor: paletteColor.color, fit: BoxFit.cover,
body: Column( ),
),
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 15, sigmaY: 15),
child: Container(
color: paletteColor.color.withOpacity(.5),
child: Column(
children: [ children: [
PageWindowTitleBar(
leading: const BackButton(),
backgroundColor: Colors.transparent,
foregroundColor: paletteColor.titleTextColor,
),
Padding( Padding(
padding: const EdgeInsets.all(10), padding: const EdgeInsets.all(10),
child: Column( child: Column(
@ -70,8 +88,10 @@ class PlayerView extends HookConsumerWidget {
currentTrack!.name!.length > 29 currentTrack!.name!.length > 29
? SpotubeMarqueeText( ? SpotubeMarqueeText(
text: currentTrack.name ?? "Not playing", text: currentTrack.name ?? "Not playing",
style: style: Theme.of(context)
Theme.of(context).textTheme.headline5?.copyWith( .textTheme
.headline5
?.copyWith(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: paletteColor.titleTextColor, color: paletteColor.titleTextColor,
), ),
@ -83,7 +103,8 @@ class PlayerView extends HookConsumerWidget {
), ),
artistsToClickableArtists( artistsToClickableArtists(
currentTrack?.artists ?? [], currentTrack?.artists ?? [],
textStyle: Theme.of(context).textTheme.headline6!.copyWith( textStyle:
Theme.of(context).textTheme.headline6!.copyWith(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: paletteColor.bodyTextColor, color: paletteColor.bodyTextColor,
), ),
@ -112,12 +133,16 @@ class PlayerView extends HookConsumerWidget {
}), }),
const Spacer(), const Spacer(),
PlayerActions( PlayerActions(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
floatingQueue: false,
), ),
PlayerControls(iconColor: paletteColor.bodyTextColor), PlayerControls(iconColor: paletteColor.bodyTextColor),
], ],
), ),
), ),
),
),
),
); );
} }
} }

View File

@ -13,15 +13,28 @@ class TitleBarActionButtons extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Row( return TextButtonTheme(
data: TextButtonThemeData(
style: ButtonStyle(
splashFactory: NoSplash.splashFactory,
shape: MaterialStateProperty.all(const RoundedRectangleBorder()),
overlayColor: MaterialStateProperty.all(Colors.black12),
padding: MaterialStateProperty.all(EdgeInsets.zero),
minimumSize: MaterialStateProperty.all(const Size(50, 40)),
maximumSize: MaterialStateProperty.all(const Size(50, 40)),
),
),
child: IconTheme(
data: const IconThemeData(size: 16),
child: Row(
children: [ children: [
TextButton( TextButton(
onPressed: () { onPressed: () {
appWindow.minimize(); appWindow.minimize();
}, },
style: ButtonStyle( style: ButtonStyle(
foregroundColor: foregroundColor: MaterialStateProperty.all(
MaterialStateProperty.all(Theme.of(context).iconTheme.color), Theme.of(context).iconTheme.color),
), ),
child: Icon( child: Icon(
Icons.minimize_rounded, Icons.minimize_rounded,
@ -32,10 +45,13 @@ class TitleBarActionButtons extends StatelessWidget {
appWindow.maximizeOrRestore(); appWindow.maximizeOrRestore();
}, },
style: ButtonStyle( style: ButtonStyle(
foregroundColor: foregroundColor: MaterialStateProperty.all(
MaterialStateProperty.all(Theme.of(context).iconTheme.color), Theme.of(context).iconTheme.color),
), ),
child: Icon(Icons.crop_square_rounded, color: color)), child: Icon(
Icons.crop_square_rounded,
color: color,
)),
TextButton( TextButton(
onPressed: () { onPressed: () {
appWindow.close(); appWindow.close();
@ -49,6 +65,8 @@ class TitleBarActionButtons extends StatelessWidget {
Icons.close_rounded, Icons.close_rounded,
)), )),
], ],
),
),
); );
} }
} }

View File

@ -2,12 +2,17 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_hooks/flutter_hooks.dart';
void useCustomStatusBarColor(Color color, bool isCurrentRoute) { void useCustomStatusBarColor(
Color color,
bool isCurrentRoute, {
bool noSetBGColor = false,
}) {
final context = useContext(); final context = useContext();
final backgroundColor = Theme.of(context).backgroundColor; final backgroundColor = Theme.of(context).backgroundColor;
resetStatusbar() => SystemChrome.setSystemUIOverlayStyle( resetStatusbar() => SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle( SystemUiOverlayStyle(
statusBarColor: backgroundColor, // status bar color statusBarColor:
!noSetBGColor ? backgroundColor : null, // status bar color
statusBarIconBrightness: backgroundColor.computeLuminance() > 0.179 statusBarIconBrightness: backgroundColor.computeLuminance() > 0.179
? Brightness.dark ? Brightness.dark
: Brightness.light, : Brightness.light,

View File

@ -10,8 +10,8 @@ final _paletteColorState = StateProvider<PaletteColor>(
}, },
); );
PaletteColor usePaletteColor( PaletteColor usePaletteColor(String imageUrl, WidgetRef ref) {
BuildContext context, String imageUrl, WidgetRef ref) { final context = useContext();
final paletteColor = ref.watch(_paletteColorState); final paletteColor = ref.watch(_paletteColorState);
final mounted = useIsMounted(); final mounted = useIsMounted();