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,56 +66,67 @@ 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(
|
for (final tile in sidebarTileList)
|
||||||
child: Column(
|
NavigationButton(
|
||||||
children: [
|
label: mediaQuery.lgAndUp ? Text(tile.title) : null,
|
||||||
Expanded(
|
child: Badge(
|
||||||
child: NavigationSidebar(
|
backgroundColor: context.theme.colorScheme.primary,
|
||||||
index: selectedIndex,
|
isLabelVisible: tile.title == "Library" && downloadCount > 0,
|
||||||
onSelected: (index) {
|
label: Text(
|
||||||
final tile = sidebarTileList[index];
|
downloadCount.toString(),
|
||||||
ServiceUtils.pushNamed(context, tile.name);
|
style: const TextStyle(
|
||||||
},
|
color: Colors.white,
|
||||||
children: [
|
fontSize: 10,
|
||||||
const NavigationLabel(child: Text("Spotube")),
|
),
|
||||||
for (final tile in sidebarTileList)
|
|
||||||
NavigationButton(
|
|
||||||
label: Text(tile.title),
|
|
||||||
child: Badge(
|
|
||||||
backgroundColor: context.theme.colorScheme.primary,
|
|
||||||
isLabelVisible:
|
|
||||||
tile.title == "Library" && downloadCount > 0,
|
|
||||||
label: Text(
|
|
||||||
downloadCount.toString(),
|
|
||||||
style: const TextStyle(
|
|
||||||
color: Colors.white,
|
|
||||||
fontSize: 10,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Icon(tile.icon),
|
|
||||||
),
|
|
||||||
onChanged: (value) {
|
|
||||||
if (value) {
|
|
||||||
context.goNamed(tile.name);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SidebarFooter(),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
|
child: Icon(tile.icon),
|
||||||
),
|
),
|
||||||
const VerticalDivider(),
|
onChanged: (value) {
|
||||||
Expanded(child: child),
|
if (value) {
|
||||||
],
|
context.goNamed(tile.name);
|
||||||
);
|
}
|
||||||
});
|
},
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
|
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 VerticalDivider(),
|
||||||
|
Expanded(child: child),
|
||||||
|
],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user