voyagehandbook/lib/util/drawer.dart
2023-04-03 19:09:51 +02:00

83 lines
2.9 KiB
Dart

import 'package:flutter/material.dart';
import 'package:voyagehandbook/views/home.dart';
import '../views/search.dart';
/*
Voyage Handbook - The open-source WikiVoyage reader
Copyright (C) 2023 Matyáš Caras
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3 as published by
the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/// Used to generate the drawer
///
/// Use `0` in `page` if you don't want any tile selected
Drawer genDrawer(int page, BuildContext context) => Drawer(
child: ListView(
children: [
DrawerHeader(
child: Column(
children: const [
Text(
"Voyage Handbook",
style: TextStyle(fontWeight: FontWeight.bold),
),
Text("Created by Matyáš Caras"),
Text("Not affiliated with WikiVoyage")
],
),
),
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(),
),
),
),
ListTile(
selected: page == 3,
title: const Text("About"),
leading: const Icon(Icons.info_outline),
onTap: () => page == 3
? Navigator.of(context).pop()
: Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => const LicensePage(
applicationName: "Voyage Handbook",
applicationLegalese:
"Copyright ©️ 2023 Matyáš Caras,\nReleased under the GNU GPL version 3",
),
),
),
),
],
),
);