diff --git a/lib/components/root/sidebar.dart b/lib/components/root/sidebar.dart index 9c572b28..5cffb0aa 100644 --- a/lib/components/root/sidebar.dart +++ b/lib/components/root/sidebar.dart @@ -90,26 +90,14 @@ class Sidebar extends HookConsumerWidget { ); }, ).toList(), - extended: true, - leading: Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - children: [ - if (kIsMacOS) macSpacer, - Row( - children: [ - brandLogo(), - const SizedBox(width: 10), - Text( - "Spotube", - style: Theme.of(context).textTheme.titleLarge, - ), - ], - ), - ], + extended: breakpoints > Breakpoints.md, + leading: const SidebarHeader(), + trailing: const Expanded( + child: Align( + alignment: Alignment.bottomCenter, + child: SidebarFooter(), ), ), - trailing: const SidebarFooter(), ), Expanded(child: child) ], @@ -117,6 +105,38 @@ class Sidebar extends HookConsumerWidget { } } +class SidebarHeader extends HookWidget { + const SidebarHeader({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + final breakpoint = useBreakpoints(); + + if (breakpoint <= Breakpoints.md) { + return Sidebar.brandLogo(); + } + + return Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + children: [ + if (kIsMacOS) const SizedBox(height: 25), + Row( + children: [ + Sidebar.brandLogo(), + const SizedBox(width: 10), + Text( + "Spotube", + style: Theme.of(context).textTheme.titleLarge, + ), + ], + ), + ], + ), + ); + } +} + class SidebarFooter extends HookConsumerWidget { const SidebarFooter({ Key? key, @@ -124,68 +144,67 @@ class SidebarFooter extends HookConsumerWidget { @override Widget build(BuildContext context, ref) { - return SizedBox( - width: 256, - child: HookBuilder( - builder: (context) { - final me = useQueries.user.me(ref); - final data = me.data; + final breakpoint = useBreakpoints(); + final me = useQueries.user.me(ref); + final data = me.data; - final avatarImg = TypeConversionUtils.image_X_UrlString( - data?.images, - index: (data?.images?.length ?? 1) - 1, - placeholder: ImagePlaceholder.artist, - ); + final avatarImg = TypeConversionUtils.image_X_UrlString( + data?.images, + index: (data?.images?.length ?? 1) - 1, + placeholder: ImagePlaceholder.artist, + ); - final auth = ref.watch(AuthenticationNotifier.provider); + final auth = ref.watch(AuthenticationNotifier.provider); - return Padding( - padding: const EdgeInsets.all(16).copyWith(left: 0), + if (breakpoint <= Breakpoints.md) { + return IconButton( + icon: const Icon(SpotubeIcons.settings), + onPressed: () => Sidebar.goToSettings(context), + ); + } + + return Container( + padding: const EdgeInsets.only(left: 12), + width: 250, + child: Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + if (auth != null && data == null) + const CircularProgressIndicator() + else if (data != null) + Flexible( child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - if (auth != null && data == null) - const Center( - child: CircularProgressIndicator(), - ) - else if (data != null) - Flexible( - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - CircleAvatar( - backgroundImage: - UniversalImage.imageProvider(avatarImg), - onBackgroundImageError: (exception, stackTrace) => - Assets.userPlaceholder.image( - height: 16, - width: 16, - ), - ), - const SizedBox( - width: 10, - ), - Flexible( - child: Text( - data.displayName ?? "Guest", - maxLines: 1, - softWrap: false, - overflow: TextOverflow.fade, - style: Theme.of(context) - .textTheme - .bodyMedium - ?.copyWith(fontWeight: FontWeight.bold), - ), - ), - ], - ), + CircleAvatar( + backgroundImage: UniversalImage.imageProvider(avatarImg), + onBackgroundImageError: (exception, stackTrace) => + Assets.userPlaceholder.image( + height: 16, + width: 16, ), - IconButton( - icon: const Icon(SpotubeIcons.settings), - onPressed: () => Sidebar.goToSettings(context)), + ), + const SizedBox(width: 10), + Flexible( + child: Text( + data.displayName ?? "Guest", + maxLines: 1, + softWrap: false, + overflow: TextOverflow.fade, + style: Theme.of(context) + .textTheme + .bodyMedium + ?.copyWith(fontWeight: FontWeight.bold), + ), + ), ], - )); - }, + ), + ), + IconButton( + icon: const Icon(SpotubeIcons.settings), + onPressed: () => Sidebar.goToSettings(context), + ), + ], ), ); } diff --git a/lib/components/root/spotube_navigation_bar.dart b/lib/components/root/spotube_navigation_bar.dart index ff42ea0a..9c32673f 100644 --- a/lib/components/root/spotube_navigation_bar.dart +++ b/lib/components/root/spotube_navigation_bar.dart @@ -37,11 +37,11 @@ class SpotubeNavigationBar extends HookConsumerWidget { if (layoutMode == LayoutMode.extended || (breakpoint.isMoreThan(Breakpoints.sm) && layoutMode == LayoutMode.adaptive)) return const SizedBox(); - return BottomNavigationBar( - items: [ + return NavigationBar( + destinations: [ ...navbarTileList.map( (e) { - return BottomNavigationBarItem( + return NavigationDestination( icon: Badge( backgroundColor: Theme.of(context).primaryColor, isLabelVisible: e.title == "Library" && downloadCount > 0, @@ -59,8 +59,8 @@ class SpotubeNavigationBar extends HookConsumerWidget { }, ), ], - currentIndex: insideSelectedIndex.value, - onTap: (i) { + selectedIndex: insideSelectedIndex.value, + onDestinationSelected: (i) { insideSelectedIndex.value = i; if (navbarTileList[i].title == "Settings") { Sidebar.goToSettings(context); diff --git a/pubspec.lock b/pubspec.lock index e9ce8f14..a4f1b5ad 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -551,6 +551,14 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_adaptive_scaffold: + dependency: "direct main" + description: + name: flutter_adaptive_scaffold + sha256: d5842a235ec810320c7e6dac282876d93bccf231201be6e684b016cd717c0576 + url: "https://pub.dev" + source: hosted + version: "0.1.0" flutter_app_builder: dependency: transitive description: