Skip to content

Commit

Permalink
Merge pull request #119 from enrique-lozano/feat/new-nav
Browse files Browse the repository at this point in the history
Completely new navigation system
  • Loading branch information
enrique-lozano authored Feb 15, 2024
2 parents 1107d80 + bb28b01 commit 644a150
Show file tree
Hide file tree
Showing 57 changed files with 1,678 additions and 2,201 deletions.
2 changes: 0 additions & 2 deletions lib/app/accounts/account_form.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:auto_route/auto_route.dart';
import 'package:drift/drift.dart' as drift;
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
Expand All @@ -25,7 +24,6 @@ import 'package:monekin/core/utils/text_field_utils.dart';
import 'package:monekin/i18n/translations.g.dart';
import 'package:uuid/uuid.dart';

@RoutePage()
class AccountFormPage extends StatefulWidget {
const AccountFormPage({super.key, this.account});

Expand Down
9 changes: 5 additions & 4 deletions lib/app/accounts/all_accounts_balance.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import 'dart:async';
import 'dart:math';

import 'package:auto_route/auto_route.dart';
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
import 'package:monekin/app/accounts/account_form.dart';
import 'package:monekin/core/database/app_db.dart';
import 'package:monekin/core/database/services/account/account_service.dart';
import 'package:monekin/core/models/account/account.dart';
import 'package:monekin/core/presentation/widgets/animated_progress_bar.dart';
import 'package:monekin/core/presentation/widgets/card_with_header.dart';
import 'package:monekin/core/presentation/widgets/transaction_filter/transaction_filters.dart';
import 'package:monekin/core/routes/app_router.dart';
import 'package:monekin/core/routes/route_utils.dart';
import 'package:monekin/i18n/translations.g.dart';

import '../../core/database/services/currency/currency_service.dart';
Expand Down Expand Up @@ -130,8 +130,9 @@ class _AllAccountBalancePageState extends State<AllAccountBalancePage> {
return ListTile(
leading:
accountWithMoney.account.displayIcon(context),
onTap: () => context.pushRoute(
AccountFormRoute(
onTap: () => RouteUtils.pushRoute(
context,
AccountFormPage(
account: accountWithMoney.account),
),
title: Column(
Expand Down
19 changes: 12 additions & 7 deletions lib/app/accounts/all_accounts_page.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import 'package:auto_route/auto_route.dart';
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
import 'package:monekin/app/accounts/account_form.dart';
import 'package:monekin/app/accounts/details/account_details.dart';
import 'package:monekin/core/database/services/account/account_service.dart';
import 'package:monekin/core/presentation/app_colors.dart';
import 'package:monekin/core/presentation/widgets/monekin_reorderable_list.dart';
import 'package:monekin/core/presentation/widgets/tappable.dart';
import 'package:monekin/core/routes/app_router.dart';
import 'package:monekin/core/routes/route_utils.dart';
import 'package:monekin/i18n/translations.g.dart';

import '../../core/presentation/widgets/empty_indicator.dart';

@RoutePage()
class AllAccountsPage extends StatelessWidget {
const AllAccountsPage({super.key});

Expand All @@ -21,9 +21,10 @@ class AllAccountsPage extends StatelessWidget {
return Scaffold(
appBar: AppBar(title: Text(t.home.my_accounts)),
floatingActionButton: FloatingActionButton.extended(
heroTag: UniqueKey(),
icon: const Icon(Icons.add_rounded),
label: Text(t.account.form.create),
onPressed: () => context.pushRoute(AccountFormRoute()),
onPressed: () => RouteUtils.pushRoute(context, const AccountFormPage()),
),
body: StreamBuilder(
stream: AccountService.instance.getAccounts(),
Expand Down Expand Up @@ -51,8 +52,12 @@ class AllAccountsPage extends StatelessWidget {
final account = accounts.elementAt(index);

return Tappable(
onTap: () => context.pushRoute(
AccountDetailsRoute(account: account),
onTap: () => RouteUtils.pushRoute(
context,
AccountDetailsPage(
account: account,
accountIconHeroTag:
'all-accounts-page__account-icon-${account.id}'),
),
bgColor: AppColors.of(context).light,
margin: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
Expand All @@ -77,7 +82,7 @@ class AllAccountsPage extends StatelessWidget {
],
),
leading: Hero(
tag: 'account-icon-${account.id}',
tag: 'all-accounts-page__account-icon-${account.id}',
child: account.displayIcon(context),
),
subtitle: Text(
Expand Down
31 changes: 21 additions & 10 deletions lib/app/accounts/details/account_details.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import 'package:auto_route/auto_route.dart';
import 'package:drift/drift.dart' as drift;
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:intl/intl.dart';
import 'package:monekin/app/accounts/details/account_details_actions.dart';
import 'package:monekin/core/routes/route_utils.dart';
import 'package:monekin/app/transactions/transactions.page.dart';
import 'package:monekin/app/transactions/widgets/transaction_list.dart';
import 'package:monekin/core/database/services/account/account_service.dart';
import 'package:monekin/core/database/services/exchange-rate/exchange_rate_service.dart';
Expand All @@ -19,15 +20,19 @@ import 'package:monekin/core/presentation/widgets/modal_container.dart';
import 'package:monekin/core/presentation/widgets/monekin_quick_actions_buttons.dart';
import 'package:monekin/core/presentation/widgets/number_ui_formatters/currency_displayer.dart';
import 'package:monekin/core/presentation/widgets/transaction_filter/transaction_filters.dart';
import 'package:monekin/core/routes/app_router.dart';
import 'package:monekin/i18n/translations.g.dart';

@RoutePage()
class AccountDetailsPage extends StatefulWidget {
const AccountDetailsPage({super.key, required this.account});
const AccountDetailsPage({
super.key,
required this.account,
required this.accountIconHeroTag,
});

final Account account;

final Object? accountIconHeroTag;

@override
State<AccountDetailsPage> createState() => _AccountDetailsPageState();
}
Expand Down Expand Up @@ -157,8 +162,9 @@ class _AccountDetailsPageState extends State<AccountDetailsPage> {
],
),
Hero(
tag: 'account-icon-${widget.account.id}',
child: account.displayIcon(context, size: 48)),
tag: widget.accountIconHeroTag ?? UniqueKey(),
child: account.displayIcon(context, size: 48),
),
],
),
),
Expand Down Expand Up @@ -219,13 +225,16 @@ class _AccountDetailsPageState extends State<AccountDetailsPage> {
CardWithHeader(
title: t.home.last_transactions,
onHeaderButtonClick: () {
context.pushRoute(
TransactionsRoute(
RouteUtils.pushRoute(
context,
TransactionsPage(
filters: TransactionFilters(
accountsIDs: [widget.account.id])),
);
},
body: TransactionListComponent(
heroTagBuilder: (tr) =>
'account-details-page__tr-icon-${tr.id}',
filters: TransactionFilters(
status: TransactionStatus.notIn({
TransactionStatus.pending,
Expand All @@ -235,8 +244,10 @@ class _AccountDetailsPageState extends State<AccountDetailsPage> {
),
limit: 5,
showGroupDivider: false,
prevPage:
AccountDetailsPage(account: widget.account),
prevPage: AccountDetailsPage(
account: widget.account,
accountIconHeroTag:
widget.accountIconHeroTag),
onEmptyList: Padding(
padding: const EdgeInsets.all(24),
child: Text(
Expand Down
12 changes: 7 additions & 5 deletions lib/app/accounts/details/account_details_actions.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import 'package:auto_route/auto_route.dart';
import 'package:drift/drift.dart' as drift;
import 'package:flutter/material.dart';
import 'package:monekin/app/accounts/account_form.dart';
import 'package:monekin/app/accounts/details/account_details.dart';
import 'package:monekin/app/transactions/form/transaction_form.page.dart';
import 'package:monekin/core/database/services/account/account_service.dart';
import 'package:monekin/core/models/account/account.dart';
import 'package:monekin/core/models/transaction/transaction.dart';
import 'package:monekin/core/presentation/widgets/confirm_dialog.dart';
import 'package:monekin/core/routes/app_router.dart';
import 'package:monekin/core/routes/route_utils.dart';
import 'package:monekin/core/utils/list_tile_action_item.dart';
import 'package:monekin/i18n/translations.g.dart';

Expand All @@ -23,7 +23,8 @@ abstract class AccountDetailsActions {
ListTileActionItem(
label: t.general.edit,
icon: Icons.edit,
onClick: () => context.pushRoute(AccountFormRoute(account: account)),
onClick: () =>
RouteUtils.pushRoute(context, AccountFormPage(account: account)),
),
ListTileActionItem(
label: t.transfer.create,
Expand All @@ -39,8 +40,9 @@ abstract class AccountDetailsActions {
Text(t.transfer.need_two_accounts_warning_message)
]);

navigateToTransferForm() => context.pushRoute(
TransactionFormRoute(
navigateToTransferForm() => RouteUtils.pushRoute(
context,
TransactionFormPage(
fromAccount: account,
mode: TransactionFormMode.transfer,
),
Expand Down
11 changes: 6 additions & 5 deletions lib/app/budgets/budget_details_page.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'dart:async';

import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:monekin/app/budgets/budget_form_page.dart';
import 'package:monekin/app/budgets/budgets_page.dart';
import 'package:monekin/app/budgets/components/budget_evolution_chart.dart';
import 'package:monekin/app/transactions/widgets/transaction_list.dart';
Expand All @@ -17,14 +17,13 @@ import 'package:monekin/core/presentation/widgets/monekin_popup_menu_button.dart
import 'package:monekin/core/presentation/widgets/number_ui_formatters/currency_displayer.dart';
import 'package:monekin/core/presentation/widgets/skeleton.dart';
import 'package:monekin/core/presentation/widgets/transaction_filter/transaction_filters.dart';
import 'package:monekin/core/routes/app_router.dart';
import 'package:monekin/core/routes/route_utils.dart';
import 'package:monekin/core/utils/list_tile_action_item.dart';
import 'package:monekin/i18n/translations.g.dart';

import '../../core/presentation/app_colors.dart';
import '../../core/presentation/widgets/empty_indicator.dart';

@RoutePage()
class BudgetDetailsPage extends StatefulWidget {
const BudgetDetailsPage({super.key, required this.budget});

Expand Down Expand Up @@ -94,8 +93,9 @@ class _BudgetDetailsPageState extends State<BudgetDetailsPage> {
label: t.budgets.form.edit,
icon: Icons.edit,
onClick: () {
context.pushRoute(
BudgetFormRoute(
RouteUtils.pushRoute(
context,
BudgetFormPage(
prevPage: const BudgetsPage(),
budgetToEdit: budget),
);
Expand Down Expand Up @@ -261,6 +261,7 @@ class _BudgetDetailsPageState extends State<BudgetDetailsPage> {
),
SingleChildScrollView(
child: TransactionListComponent(
heroTagBuilder: (tr) => 'budgets-page__tr-icon-${tr.id}',
filters: TransactionFilters(
status: TransactionStatus.notIn({
TransactionStatus.pending,
Expand Down
2 changes: 0 additions & 2 deletions lib/app/budgets/budget_form_page.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:monekin/app/accounts/account_selector.dart';
Expand All @@ -19,7 +18,6 @@ import 'package:uuid/uuid.dart';
import '../../core/models/account/account.dart';
import '../../core/presentation/widgets/persistent_footer_button.dart';

@RoutePage()
class BudgetFormPage extends StatefulWidget {
const BudgetFormPage({super.key, this.budgetToEdit, required this.prevPage});

Expand Down
15 changes: 9 additions & 6 deletions lib/app/budgets/budgets_page.dart
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:monekin/app/budgets/budget_details_page.dart';
import 'package:monekin/app/budgets/budget_form_page.dart';
import 'package:monekin/core/database/services/budget/budget_service.dart';
import 'package:monekin/core/models/budget/budget.dart';
import 'package:monekin/core/presentation/widgets/animated_progress_bar.dart';
import 'package:monekin/core/presentation/widgets/empty_indicator.dart';
import 'package:monekin/core/presentation/widgets/number_ui_formatters/currency_displayer.dart';
import 'package:monekin/core/presentation/widgets/skeleton.dart';
import 'package:monekin/core/routes/app_router.dart';
import 'package:monekin/core/routes/route_utils.dart';
import 'package:monekin/i18n/translations.g.dart';

import '../../core/presentation/app_colors.dart';

@RoutePage()
class BudgetsPage extends StatelessWidget {
const BudgetsPage({super.key});

Widget buildBudgetCard(BuildContext context, Budget budget) {
return InkWell(
onTap: () => context.pushRoute(BudgetDetailsRoute(budget: budget)),
onTap: () =>
RouteUtils.pushRoute(context, BudgetDetailsPage(budget: budget)),
child: Container(
padding: const EdgeInsets.all(16),
child: Column(
Expand Down Expand Up @@ -106,10 +107,12 @@ class BudgetsPage extends StatelessWidget {
),
),
floatingActionButton: FloatingActionButton.extended(
heroTag: UniqueKey(),
icon: const Icon(Icons.add_rounded),
label: Text(t.budgets.form.create),
onPressed: () => context.pushRoute(
BudgetFormRoute(prevPage: const BudgetsPage()),
onPressed: () => RouteUtils.pushRoute(
context,
const BudgetFormPage(prevPage: BudgetsPage()),
)),
body: TabBarView(children: [
StreamBuilder(
Expand Down
11 changes: 5 additions & 6 deletions lib/app/categories/categories_list.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:monekin/app/categories/category_selector.dart';
import 'package:monekin/app/categories/form/category_form.dart';
import 'package:monekin/app/categories/subcategory_selector.dart';
import 'package:monekin/core/database/services/category/category_service.dart';
import 'package:monekin/core/models/category/category.dart';
import 'package:monekin/core/presentation/widgets/persistent_footer_button.dart';
import 'package:monekin/core/routes/app_router.dart';
import 'package:monekin/core/routes/route_utils.dart';
import 'package:monekin/core/utils/color_utils.dart';
import 'package:monekin/i18n/translations.g.dart';

Expand Down Expand Up @@ -38,7 +38,6 @@ Future<List<Category>?> showCategoryListModal(
);
}

@RoutePage()
class CategoriesListPage extends CategoriesList {
const CategoriesListPage()
: super(mode: CategoriesListMode.page, selectedCategories: const []);
Expand Down Expand Up @@ -110,8 +109,8 @@ class _CategoriesListState extends State<CategoriesList> {
return;
}

goToCategoryForm() =>
context.pushRoute(CategoryFormRoute(categoryUUID: category.id));
goToCategoryForm() => RouteUtils.pushRoute(
context, CategoryFormPage(categoryUUID: category.id));

if (widget.mode == CategoriesListMode.page) {
await goToCategoryForm();
Expand Down Expand Up @@ -182,7 +181,7 @@ class _CategoriesListState extends State<CategoriesList> {
PersistentFooterButton(
child: FilledButton.icon(
onPressed: () {
context.pushRoute(CategoryFormRoute());
RouteUtils.pushRoute(context, const CategoryFormPage());
},
icon: const Icon(Icons.add),
label: Text(t.categories.create),
Expand Down
4 changes: 0 additions & 4 deletions lib/app/categories/category_selector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ class _CategorySelectorState extends State<CategorySelector> {
if (!widget.multiSelection) {
selectedCategories = [categoryToDisplay];

print(selectedCategories);

setState(() {});

if (widget.onChange != null) {
Expand Down Expand Up @@ -137,8 +135,6 @@ class _CategorySelectorState extends State<CategorySelector> {
),
mainColor: AppColors.of(context).onBackground,
onTap: () {
print(selectedCategories);

if (selectedCategories == null) {
selectedCategories = [];
} else {
Expand Down
3 changes: 1 addition & 2 deletions lib/app/categories/form/category_form.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:auto_route/auto_route.dart';
import 'package:monekin/core/routes/route_utils.dart';
import 'package:drift/drift.dart' as drift;
import 'package:flutter/material.dart';
import 'package:monekin/app/categories/form/category_form_functions.dart';
Expand All @@ -16,7 +16,6 @@ import 'package:monekin/core/utils/text_field_utils.dart';
import 'package:monekin/i18n/translations.g.dart';
import 'package:uuid/uuid.dart';

@RoutePage()
class CategoryFormPage extends StatefulWidget {
const CategoryFormPage({super.key, this.categoryUUID});

Expand Down
Loading

0 comments on commit 644a150

Please sign in to comment.