2024-06-30 20:25:36 +02:00
|
|
|
// SPDX-FileCopyrightText: (C) 2024 Matyáš Caras
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2023-11-21 20:23:14 +01:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|
|
|
import 'package:prasule/pw/platformroute.dart';
|
2024-07-19 17:34:45 +02:00
|
|
|
import 'package:prasule/views/debts/debt_view.dart';
|
2024-07-18 14:44:07 +02:00
|
|
|
import 'package:prasule/views/graphs/graph_view.dart';
|
2023-11-21 20:23:14 +01:00
|
|
|
import 'package:prasule/views/home.dart';
|
2024-07-18 14:44:07 +02:00
|
|
|
import 'package:prasule/views/recurring/recurring_view.dart';
|
2023-11-21 20:23:14 +01:00
|
|
|
|
|
|
|
/// Makes the drawer because I won't enter the same code in every view
|
2024-07-19 17:34:45 +02:00
|
|
|
Drawer makeDrawer(BuildContext context, Pages page) => Drawer(
|
2023-11-21 20:23:14 +01:00
|
|
|
child: ListView(
|
|
|
|
children: [
|
|
|
|
const DrawerHeader(child: Text("Prašule")),
|
|
|
|
ListTile(
|
|
|
|
leading: const Icon(Icons.home),
|
|
|
|
title: Text(
|
2023-12-25 19:03:52 +01:00
|
|
|
AppLocalizations.of(context).home,
|
2023-11-21 20:23:14 +01:00
|
|
|
),
|
2024-07-19 17:34:45 +02:00
|
|
|
selected: page == Pages.home,
|
2023-11-21 20:23:14 +01:00
|
|
|
onTap: () {
|
2024-07-19 17:34:45 +02:00
|
|
|
if (page == Pages.home) {
|
2023-11-21 20:23:14 +01:00
|
|
|
Navigator.of(context).pop();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Navigator.of(context)
|
|
|
|
.pushReplacement(platformRoute((p0) => const HomeView()));
|
|
|
|
},
|
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
leading: const Icon(Icons.bar_chart),
|
|
|
|
title: Text(
|
2023-12-25 19:03:52 +01:00
|
|
|
AppLocalizations.of(context).graphs,
|
2023-11-21 20:23:14 +01:00
|
|
|
),
|
2024-07-19 17:34:45 +02:00
|
|
|
selected: page == Pages.graphs,
|
2023-11-21 20:23:14 +01:00
|
|
|
onTap: () {
|
2024-07-19 17:34:45 +02:00
|
|
|
if (page == Pages.graphs) {
|
2023-11-21 20:23:14 +01:00
|
|
|
Navigator.of(context).pop();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Navigator.of(context)
|
|
|
|
.pushReplacement(platformRoute((p0) => const GraphView()));
|
|
|
|
},
|
|
|
|
),
|
2024-01-08 21:19:15 +01:00
|
|
|
ListTile(
|
|
|
|
leading: const Icon(Icons.repeat),
|
|
|
|
title: Text(
|
|
|
|
AppLocalizations.of(context).recurringPayments,
|
|
|
|
),
|
2024-07-19 17:34:45 +02:00
|
|
|
selected: page == Pages.recurringEntries,
|
2024-01-08 21:19:15 +01:00
|
|
|
onTap: () {
|
2024-07-19 17:34:45 +02:00
|
|
|
if (page == Pages.recurringEntries) {
|
2024-01-08 21:19:15 +01:00
|
|
|
Navigator.of(context).pop();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Navigator.of(context).pushReplacement(
|
|
|
|
platformRoute((p0) => const RecurringEntriesView()),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
2024-07-19 17:34:45 +02:00
|
|
|
ListTile(
|
|
|
|
leading: const Icon(Icons.people),
|
|
|
|
title: Text(
|
|
|
|
AppLocalizations.of(context).debts,
|
|
|
|
),
|
|
|
|
selected: page == Pages.debts,
|
|
|
|
onTap: () {
|
|
|
|
if (page == Pages.debts) {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Navigator.of(context).pushReplacement(
|
|
|
|
platformRoute((p0) => const DebtView()),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
2023-11-21 20:23:14 +01:00
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
2024-07-19 17:34:45 +02:00
|
|
|
|
|
|
|
/// All the pages that drawer can navigate to
|
|
|
|
enum Pages {
|
|
|
|
/// [HomeView]
|
|
|
|
home,
|
|
|
|
|
|
|
|
/// [GraphView]
|
|
|
|
graphs,
|
|
|
|
|
|
|
|
/// [RecurringEntriesView]
|
|
|
|
recurringEntries,
|
|
|
|
|
|
|
|
/// [DebtView]
|
|
|
|
debts
|
|
|
|
}
|