shlink-manager/lib/views/navigationbar_view.dart

41 lines
1.2 KiB
Dart
Raw Normal View History

2023-06-26 23:40:05 +02:00
import 'package:flutter/material.dart';
2024-01-27 23:07:06 +01:00
import 'package:shlink_app/views/settings_view.dart';
import 'package:shlink_app/views/home_view.dart';
import 'package:shlink_app/views/url_list_view.dart';
2023-06-26 23:40:05 +02:00
class NavigationBarView extends StatefulWidget {
2024-01-28 00:32:09 +01:00
const NavigationBarView({super.key});
2023-06-26 23:40:05 +02:00
@override
State<NavigationBarView> createState() => _NavigationBarViewState();
}
class _NavigationBarViewState extends State<NavigationBarView> {
2024-01-28 00:32:09 +01:00
final List<Widget> views = [
const HomeView(),
const URLListView(),
const SettingsView()
];
2023-06-26 23:40:05 +02:00
int _selectedView = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
2023-07-09 23:00:00 +02:00
body: views.elementAt(_selectedView),
2023-06-26 23:40:05 +02:00
bottomNavigationBar: NavigationBar(
2024-01-27 23:07:06 +01:00
destinations: const [
2023-06-26 23:40:05 +02:00
NavigationDestination(icon: Icon(Icons.home), label: "Home"),
2023-07-10 17:32:14 +02:00
NavigationDestination(icon: Icon(Icons.link), label: "Short URLs"),
NavigationDestination(icon: Icon(Icons.settings), label: "Settings")
2023-06-26 23:40:05 +02:00
],
selectedIndex: _selectedView,
onDestinationSelected: (int index) {
setState(() {
_selectedView = index;
});
},
),
);
}
}