Skip to content

Commit

Permalink
move basket page
Browse files Browse the repository at this point in the history
  • Loading branch information
praslnx8 committed Jun 29, 2024
1 parent e8276ae commit 36d1a09
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 12 deletions.
3 changes: 3 additions & 0 deletions lib/app_router.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:wealth_wave/ui/nav_path.dart';
import 'package:wealth_wave/ui/pages/baskets_page.dart';
import 'package:wealth_wave/ui/pages/goal_page.dart';
import 'package:wealth_wave/ui/pages/investment_page.dart';
import 'package:wealth_wave/ui/pages/main_page.dart';
Expand All @@ -13,6 +14,8 @@ class AppRouter {
return InvestmentPage(investmentId: int.parse(uri.pathSegments[1]));
} else if (NavPath.isGoalPagePath(uri.pathSegments)) {
return GoalPage(goalId: int.parse(uri.pathSegments[1]));
} else if(NavPath.isBasketsPagePath(uri.pathSegments)) {
return const BasketsPage();
}
return const MainPage(path: []);
}
Expand Down
3 changes: 3 additions & 0 deletions lib/ui/nav_path.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class NavPath {
static String updateBasket({required final int id}) => '/baskets/$id/update';
static String investment({required final int id}) => '/investments/$id';
static String goal({required final int id}) => '/goals/$id';
static const String baskets = '/baskets';

static isMainPagePath(List<String> paths) => paths.isEmpty;

Expand All @@ -27,4 +28,6 @@ class NavPath {

static isGoalPagePath(List<String> paths) =>
paths.length == 2 && paths[0] == 'goals';

static isBasketsPagePath(List<String> paths) => paths.length == 1 && paths[0] == 'baskets';
}
4 changes: 4 additions & 0 deletions lib/ui/pages/baskets_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ class _BasketsPage
final BuildContext context, final BasketsViewState snapshot) {
List<BasketVO> basketVOs = snapshot.baskets;
return Scaffold(
appBar: AppBar(
title: const Text('Baskets'),
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
),
body: Center(
child: ListView.builder(
itemCount: basketVOs.length,
Expand Down
5 changes: 4 additions & 1 deletion lib/ui/pages/goal_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ class _GoalPage extends PageState<GoalViewState, GoalPage, GoalPresenter> {
}

return Scaffold(
appBar: AppBar(title: const Text('Goal')),
appBar: AppBar(
title: const Text('Goal'),
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
),
body: SingleChildScrollView(
child: _goalWidget(context: context, goalVO: goalVO)));
}
Expand Down
5 changes: 4 additions & 1 deletion lib/ui/pages/investment_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ class _InvestmentPage extends PageState<InvestmentViewState, InvestmentPage,
final BuildContext context, final InvestmentViewState snapshot) {
InvestmentVO? investmentVO = snapshot.investmentVO;
return Scaffold(
appBar: AppBar(title: const Text('Investment')),
appBar: AppBar(
title: const Text('Investment'),
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
),
body: SingleChildScrollView(
child: _investmentWidget(
context: context, investmentVO: investmentVO)));
Expand Down
19 changes: 9 additions & 10 deletions lib/ui/pages/main_page.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'package:wealth_wave/core/page_state.dart';
import 'package:wealth_wave/presentation/main_presenter.dart';
import 'package:wealth_wave/ui/pages/baskets_page.dart';
import 'package:wealth_wave/ui/pages/dashboard_page.dart';
import 'package:wealth_wave/ui/pages/goals_page.dart';
import 'package:wealth_wave/ui/pages/investments_page.dart';
Expand Down Expand Up @@ -52,18 +51,24 @@ class _MainPageState extends PageState<MainViewState, MainPage, MainPresenter> {
PopupMenuButton<int>(
onSelected: (value) {
if (value == 1) {
presenter.performBackup();
Navigator.of(context).pushNamed('/baskets');
} else if (value == 2) {
presenter.performBackup();
} else if (value == 3) {
presenter.performImportFile();
}
},
itemBuilder: (context) => [
const PopupMenuItem(
value: 1,
child: Text('Export'),
child: Text('Baskets'),
),
const PopupMenuItem(
value: 2,
child: Text('Export'),
),
const PopupMenuItem(
value: 3,
child: Text('Import'),
),
],
Expand All @@ -84,11 +89,7 @@ class _MainPageState extends PageState<MainViewState, MainPage, MainPresenter> {
NavigationDestination(
icon: Icon(Icons.flag),
label: 'Goals',
),
NavigationDestination(
icon: Icon(Icons.shopping_basket),
label: 'Baskets',
),
)
],
onDestinationSelected: (index) {
setState(() {
Expand All @@ -105,8 +106,6 @@ class _MainPageState extends PageState<MainViewState, MainPage, MainPresenter> {
return const InvestmentsPage();
case 2:
return const GoalsPage();
case 3:
return const BasketsPage();
default:
return Container();
}
Expand Down

0 comments on commit 36d1a09

Please sign in to comment.