105 lines
3.1 KiB
Dart
105 lines
3.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class SideMenu extends StatefulWidget {
|
|
final Widget body;
|
|
|
|
const SideMenu({Key? key, required this.body}) : super(key: key);
|
|
|
|
@override
|
|
State<SideMenu> createState() => _SideMenuState();
|
|
}
|
|
|
|
class _SideMenuState extends State<SideMenu> {
|
|
int _selectedIndex = 0;
|
|
|
|
void _onItemTapped(int index) {
|
|
setState(() {
|
|
_selectedIndex = index;
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
|
title: const Text('SkanTavels'),
|
|
),
|
|
drawer: Drawer(
|
|
child: ListView(
|
|
padding: EdgeInsets.zero,
|
|
children: [
|
|
const DrawerHeader(
|
|
decoration: BoxDecoration(
|
|
color: Colors.blue,
|
|
),
|
|
child: Text('Drawer Header'),
|
|
),
|
|
ListTile(
|
|
title: const Text('Home'),
|
|
leading: const Icon(Icons.home),
|
|
selected: _selectedIndex == 0,
|
|
onTap: () {
|
|
// Update the state of the app
|
|
_onItemTapped(0);
|
|
// Then close the drawer
|
|
Navigator.pushReplacementNamed(context, '/home');
|
|
},
|
|
),
|
|
ListTile(
|
|
title: const Text('Favourites'),
|
|
leading: const Icon(Icons.star),
|
|
selected: _selectedIndex == 1,
|
|
onTap: () {
|
|
// Update the state of the app
|
|
_onItemTapped(1);
|
|
// Then close the drawer
|
|
Navigator.pop(context);
|
|
},
|
|
),
|
|
ListTile(
|
|
title: const Text('Profile'),
|
|
leading: const Icon(Icons.person),
|
|
selected: _selectedIndex == 2,
|
|
onTap: () {
|
|
// Update the state of the app
|
|
_onItemTapped(2);
|
|
// Then close the drawer
|
|
Navigator.pushReplacementNamed(context, '/profile');
|
|
},
|
|
),
|
|
const Divider(
|
|
color: Colors.grey,
|
|
thickness: 2,
|
|
indent: 40,
|
|
),
|
|
ListTile(
|
|
title: const Text('Register'),
|
|
leading: const Icon(Icons.add_box_outlined),
|
|
selected: _selectedIndex == 3,
|
|
onTap: () {
|
|
// Update the state of the app
|
|
_onItemTapped(3);
|
|
// Then close the drawer
|
|
Navigator.pushReplacementNamed(context, '/register');
|
|
},
|
|
),
|
|
ListTile(
|
|
title: const Text('Login'),
|
|
leading: const Icon(Icons.login),
|
|
selected: _selectedIndex == 4,
|
|
onTap: () {
|
|
// Update the state of the app
|
|
_onItemTapped(4);
|
|
// Then close the drawer
|
|
Navigator.pushReplacementNamed(context, '/login');
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
body: widget.body,
|
|
);
|
|
}
|
|
}
|