RhythmBox/lib/shells/nav_shell.dart

63 lines
1.8 KiB
Dart
Raw Normal View History

2024-08-26 05:29:17 +00:00
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:go_router/go_router.dart';
2024-08-27 06:35:16 +00:00
import 'package:rhythm_box/widgets/player/bottom_player.dart';
2024-08-26 05:29:17 +00:00
class Destination {
const Destination(this.title, this.page, this.icon);
final String title;
final String page;
final IconData icon;
}
class NavShell extends StatefulWidget {
final Widget child;
const NavShell({super.key, required this.child});
@override
State<NavShell> createState() => _NavShellState();
}
class _NavShellState extends State<NavShell> {
int _focusDestination = 0;
final List<Destination> _allDestinations = <Destination>[
Destination('explore'.tr, 'explore', Icons.explore),
2024-08-28 13:07:58 +00:00
Destination('search'.tr, 'search', Icons.search),
Destination('settings'.tr, 'settings', Icons.settings),
2024-08-26 05:29:17 +00:00
];
@override
Widget build(BuildContext context) {
return Scaffold(
body: widget.child,
2024-08-27 06:35:16 +00:00
bottomNavigationBar: Material(
elevation: 2,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
2024-08-28 12:34:35 +00:00
const BottomPlayer(key: Key('app-wide-bottom-player')),
2024-08-27 06:35:16 +00:00
const Divider(height: 0.3, thickness: 0.3),
BottomNavigationBar(
elevation: 0,
showUnselectedLabels: false,
currentIndex: _focusDestination,
items: _allDestinations
.map((x) => BottomNavigationBarItem(
icon: Icon(x.icon),
label: x.title,
))
.toList(),
onTap: (value) {
GoRouter.of(context).goNamed(_allDestinations[value].page);
setState(() => _focusDestination = value);
},
),
],
),
2024-08-26 05:29:17 +00:00
),
);
}
}