mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
refactor: use NavigationSidebar and NavigationRail for desktop sidebar
This commit is contained in:
parent
e73d2d06d8
commit
fe2f0a373f
@ -66,29 +66,16 @@ class Sidebar extends HookConsumerWidget {
|
||||
return Scaffold(child: child);
|
||||
}
|
||||
|
||||
return LayoutBuilder(builder: (context, constrains) {
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: NavigationSidebar(
|
||||
index: selectedIndex,
|
||||
onSelected: (index) {
|
||||
final tile = sidebarTileList[index];
|
||||
ServiceUtils.pushNamed(context, tile.name);
|
||||
},
|
||||
children: [
|
||||
const NavigationLabel(child: Text("Spotube")),
|
||||
final navigationButtons = [
|
||||
NavigationLabel(
|
||||
child: mediaQuery.lgAndUp ? const Text("Spotube") : const Text(""),
|
||||
),
|
||||
for (final tile in sidebarTileList)
|
||||
NavigationButton(
|
||||
label: Text(tile.title),
|
||||
label: mediaQuery.lgAndUp ? Text(tile.title) : null,
|
||||
child: Badge(
|
||||
backgroundColor: context.theme.colorScheme.primary,
|
||||
isLabelVisible:
|
||||
tile.title == "Library" && downloadCount > 0,
|
||||
isLabelVisible: tile.title == "Library" && downloadCount > 0,
|
||||
label: Text(
|
||||
downloadCount.toString(),
|
||||
style: const TextStyle(
|
||||
@ -104,7 +91,32 @@ class Sidebar extends HookConsumerWidget {
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
];
|
||||
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: mediaQuery.lgAndUp
|
||||
? NavigationSidebar(
|
||||
index: selectedIndex,
|
||||
onSelected: (index) {
|
||||
final tile = sidebarTileList[index];
|
||||
ServiceUtils.pushNamed(context, tile.name);
|
||||
},
|
||||
children: navigationButtons,
|
||||
)
|
||||
: NavigationRail(
|
||||
alignment: NavigationRailAlignment.start,
|
||||
index: selectedIndex,
|
||||
onSelected: (index) {
|
||||
final tile = sidebarTileList[index];
|
||||
ServiceUtils.pushNamed(context, tile.name);
|
||||
},
|
||||
children: navigationButtons,
|
||||
),
|
||||
),
|
||||
const SidebarFooter(),
|
||||
@ -115,7 +127,6 @@ class Sidebar extends HookConsumerWidget {
|
||||
Expanded(child: child),
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user