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 Scaffold(child: child);
|
||||||
}
|
}
|
||||||
|
|
||||||
return LayoutBuilder(builder: (context, constrains) {
|
final navigationButtons = [
|
||||||
return Row(
|
NavigationLabel(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
child: mediaQuery.lgAndUp ? const Text("Spotube") : const Text(""),
|
||||||
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")),
|
|
||||||
for (final tile in sidebarTileList)
|
for (final tile in sidebarTileList)
|
||||||
NavigationButton(
|
NavigationButton(
|
||||||
label: Text(tile.title),
|
label: mediaQuery.lgAndUp ? Text(tile.title) : null,
|
||||||
child: Badge(
|
child: Badge(
|
||||||
backgroundColor: context.theme.colorScheme.primary,
|
backgroundColor: context.theme.colorScheme.primary,
|
||||||
isLabelVisible:
|
isLabelVisible: tile.title == "Library" && downloadCount > 0,
|
||||||
tile.title == "Library" && downloadCount > 0,
|
|
||||||
label: Text(
|
label: Text(
|
||||||
downloadCount.toString(),
|
downloadCount.toString(),
|
||||||
style: const TextStyle(
|
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(),
|
const SidebarFooter(),
|
||||||
@ -115,7 +127,6 @@ class Sidebar extends HookConsumerWidget {
|
|||||||
Expanded(child: child),
|
Expanded(child: child),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user