From 3d334d96fdfcb23d9d3a27eba945da0ca1b0d848 Mon Sep 17 00:00:00 2001 From: Kingkor Roy Tirtho Date: Tue, 11 Mar 2025 21:28:57 +0600 Subject: [PATCH] fix(desktop): double titlebar in local library folders and massive space in overlay player --- lib/collections/routes.dart | 10 ++-- .../adaptive/adaptive_pop_sheet_list.dart | 54 ++++++++++--------- .../presentation_actions.dart | 2 +- .../sort_tracks_dropdown.dart | 2 +- lib/components/track_tile/track_options.dart | 2 +- lib/modules/player/player.dart | 4 +- lib/modules/player/player_actions.dart | 2 +- lib/pages/lyrics/lyrics.dart | 1 + 8 files changed, 41 insertions(+), 36 deletions(-) diff --git a/lib/collections/routes.dart b/lib/collections/routes.dart index 87f2720e..543bc471 100644 --- a/lib/collections/routes.dart +++ b/lib/collections/routes.dart @@ -75,17 +75,17 @@ class AppRouter extends RootStackRouter { path: "local", page: UserLocalLibraryRoute.page, ), - AutoRoute( - path: "local/folder", - page: LocalLibraryRoute.page, - // parentNavigatorKey: shellRouteNavigatorKey, - ), AutoRoute( path: "downloads", page: UserDownloadsRoute.page, ), ], ), + AutoRoute( + path: "local/folder", + page: LocalLibraryRoute.page, + // parentNavigatorKey: shellRouteNavigatorKey, + ), AutoRoute( path: "library/generate", page: PlaylistGeneratorRoute.page, diff --git a/lib/components/adaptive/adaptive_pop_sheet_list.dart b/lib/components/adaptive/adaptive_pop_sheet_list.dart index 95d3fae7..0f02ee73 100644 --- a/lib/components/adaptive/adaptive_pop_sheet_list.dart +++ b/lib/components/adaptive/adaptive_pop_sheet_list.dart @@ -28,7 +28,7 @@ class AdaptiveMenuButton extends MenuButton { /// or equal to 640px /// In smaller screen, a [IconButton] with a [showModalBottomSheet] is shown class AdaptivePopSheetList extends StatelessWidget { - final List> children; + final List> Function(BuildContext context) items; final Widget? icon; final Widget? child; final bool useRootNavigator; @@ -43,7 +43,7 @@ class AdaptivePopSheetList extends StatelessWidget { const AdaptivePopSheetList({ super.key, - required this.children, + required this.items, this.icon, this.child, this.useRootNavigator = true, @@ -59,27 +59,28 @@ class AdaptivePopSheetList extends StatelessWidget { Future showDropdownMenu(BuildContext context, Offset position) async { final mediaQuery = MediaQuery.of(context); - final childrenModified = children.map((s) { - if (s.onPressed == null) { - return MenuButton( - key: s.key, - autoClose: s.autoClose, - enabled: s.enabled, - leading: s.leading, - focusNode: s.focusNode, - onPressed: (context) { - if (s.value != null) { - onSelected?.call(s.value as T); - } - }, - popoverController: s.popoverController, - subMenu: s.subMenu, - trailing: s.trailing, - child: s.child, - ); - } - return s; - }).toList(); + List childrenModified(BuildContext context) => + items(context).map((s) { + if (s.onPressed == null) { + return MenuButton( + key: s.key, + autoClose: s.autoClose, + enabled: s.enabled, + leading: s.leading, + focusNode: s.focusNode, + onPressed: (context) { + if (s.value != null) { + onSelected?.call(s.value as T); + } + }, + popoverController: s.popoverController, + subMenu: s.subMenu, + trailing: s.trailing, + child: s.child, + ); + } + return s; + }).toList(); if (mediaQuery.mdAndUp) { await showDropdown( @@ -92,7 +93,7 @@ class AdaptivePopSheetList extends StatelessWidget { position: position, builder: (context) { return DropdownMenu( - children: childrenModified, + children: childrenModified(context), ); }, ).future; @@ -109,11 +110,12 @@ class AdaptivePopSheetList extends StatelessWidget { ), backgroundColor: context.theme.colorScheme.card, builder: (context) { + final children = childrenModified(context); return ListView.builder( - itemCount: childrenModified.length, + itemCount: children.length, shrinkWrap: true, itemBuilder: (context, index) { - final data = childrenModified[index]; + final data = children[index]; return Button( enabled: data.enabled, diff --git a/lib/components/track_presentation/presentation_actions.dart b/lib/components/track_presentation/presentation_actions.dart index 01228524..4948cf69 100644 --- a/lib/components/track_presentation/presentation_actions.dart +++ b/lib/components/track_presentation/presentation_actions.dart @@ -166,7 +166,7 @@ class TrackPresentationActionsSection extends HookConsumerWidget { }, icon: const Icon(SpotubeIcons.moreVertical), variance: ButtonVariance.outline, - children: [ + items: (context) => [ AdaptiveMenuButton( value: "download", leading: const Icon(SpotubeIcons.download), diff --git a/lib/components/track_presentation/sort_tracks_dropdown.dart b/lib/components/track_presentation/sort_tracks_dropdown.dart index 54990503..0a07cbad 100644 --- a/lib/components/track_presentation/sort_tracks_dropdown.dart +++ b/lib/components/track_presentation/sort_tracks_dropdown.dart @@ -23,7 +23,7 @@ class SortTracksDropdown extends StatelessWidget { onSelected: onChanged, tooltip: context.l10n.sort_tracks, icon: const Icon(SpotubeIcons.sort), - children: [ + items: (context) => [ AdaptiveMenuButton( value: SortBy.none, enabled: value != SortBy.none, diff --git a/lib/components/track_tile/track_options.dart b/lib/components/track_tile/track_options.dart index 25e27ba4..10a43c71 100644 --- a/lib/components/track_tile/track_options.dart +++ b/lib/components/track_tile/track_options.dart @@ -366,7 +366,7 @@ class TrackOptions extends HookConsumerWidget { ), ), ], - children: [ + items: (context) => [ if (isLocalTrack) AdaptiveMenuButton( value: TrackOptionValue.delete, diff --git a/lib/modules/player/player.dart b/lib/modules/player/player.dart index 12c1d773..aa5171d5 100644 --- a/lib/modules/player/player.dart +++ b/lib/modules/player/player.dart @@ -27,6 +27,7 @@ import 'package:spotube/provider/audio_player/audio_player.dart'; import 'package:spotube/provider/server/active_sourced_track.dart'; import 'package:spotube/provider/volume_provider.dart'; import 'package:spotube/services/sourced_track/sources/youtube.dart'; +import 'package:spotube/utils/platform.dart'; import 'package:url_launcher/url_launcher_string.dart'; @@ -101,7 +102,8 @@ class PlayerView extends HookConsumerWidget { backgroundColor: Colors.transparent, headers: [ SafeArea( - minimum: const EdgeInsets.only(top: 80), + minimum: + kIsMobile ? const EdgeInsets.only(top: 80) : EdgeInsets.zero, bottom: false, child: TitleBar( surfaceOpacity: 0, diff --git a/lib/modules/player/player_actions.dart b/lib/modules/player/player_actions.dart index d4d8a239..0ed56ed2 100644 --- a/lib/modules/player/player_actions.dart +++ b/lib/modules/player/player_actions.dart @@ -191,7 +191,7 @@ class PlayerActions extends HookConsumerWidget { sleepTimerNotifier.setSleepTimer(value); } }, - children: [ + items: (context) => [ for (final entry in sleepTimerEntries.entries) AdaptiveMenuButton( value: entry.value, diff --git a/lib/pages/lyrics/lyrics.dart b/lib/pages/lyrics/lyrics.dart index 98a238f0..d3e77bf0 100644 --- a/lib/pages/lyrics/lyrics.dart +++ b/lib/pages/lyrics/lyrics.dart @@ -81,6 +81,7 @@ class LyricsPage extends HookConsumerWidget { title: tabbar, height: 58 * context.theme.scaling, surfaceBlur: 0, + automaticallyImplyLeading: false, ) : tabbar ],