voyagehandbook/lib/util/drawer.dart

51 lines
1.5 KiB
Dart
Raw Normal View History

2023-03-18 16:55:08 +01:00
import 'package:flutter/material.dart';
import 'package:voyagehandbook/views/home.dart';
import '../views/search.dart';
2023-03-24 23:48:55 +01:00
/// Used to generate the drawer
///
/// Use `0` in `page` if you don't want any tile selected
2023-03-18 16:55:08 +01:00
Drawer genDrawer(int page, BuildContext context) => Drawer(
child: ListView(
children: [
DrawerHeader(
2023-03-24 23:48:55 +01:00
child: Column(
children: const [
Text(
"Voyage Handbook",
style: TextStyle(fontWeight: FontWeight.bold),
),
Text("Created by Matyáš Caras"),
Text("Thanks to WikiVoyage")
],
),
),
2023-03-18 16:55:08 +01:00
ListTile(
selected: page == 1,
title: const Text("Home"),
leading: const Icon(Icons.home),
onTap: () => page == 1
? Navigator.of(context).pop()
: Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => const HomeView(),
),
),
),
ListTile(
selected: page == 2,
title: const Text("Search"),
leading: const Icon(Icons.search),
onTap: () => page == 2
? Navigator.of(context).pop()
: Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => const SearchView(),
),
),
),
],
),
);