Skip to content

Commit c6a94c9

Browse files
committed
feat(navigation): update bottom navigation
- Updated navigation destinations - Navigates on index change - Removed search and account - Added settings page
1 parent 1e0b5eb commit c6a94c9

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

lib/app/view/app_scaffold.dart

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_adaptive_scaffold/flutter_adaptive_scaffold.dart';
33
import 'package:flutter_bloc/flutter_bloc.dart';
4+
import 'package:go_router/go_router.dart';
45
import 'package:ht_main/app/bloc/app_bloc.dart';
6+
import 'package:ht_main/router/routes.dart';
57

68
class AppScaffold extends StatelessWidget {
79
const AppScaffold({required this.child, super.key});
@@ -27,6 +29,11 @@ class AppScaffold extends StatelessWidget {
2729
context.read<AppBloc>().add(
2830
AppNavigationIndexChanged(index: index, context: context),
2931
);
32+
if (index == 0) {
33+
context.goNamed(Routes.headlinesFeedName);
34+
} else if (index == 1) {
35+
context.goNamed(Routes.settingsName);
36+
}
3037
},
3138
destinations: const [
3239
NavigationDestination(
@@ -35,14 +42,9 @@ class AppScaffold extends StatelessWidget {
3542
label: 'Headlines',
3643
),
3744
NavigationDestination(
38-
icon: Icon(Icons.search_outlined),
39-
selectedIcon: Icon(Icons.search),
40-
label: 'Search',
41-
),
42-
NavigationDestination(
43-
icon: Icon(Icons.account_circle_outlined),
44-
selectedIcon: Icon(Icons.account_circle),
45-
label: 'Account',
45+
icon: Icon(Icons.settings_outlined),
46+
selectedIcon: Icon(Icons.settings),
47+
label: 'Settings',
4648
),
4749
],
4850
);

lib/router/router.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ final appRouter = GoRouter(
3939
},
4040
),
4141
GoRoute(
42-
path: Routes.account,
43-
name: Routes.accountName,
42+
path: Routes.settings,
43+
name: Routes.settingsName,
4444
builder: (BuildContext context, GoRouterState state) {
4545
return const Placeholder(
46-
child: Center(child: Text('ACCOUNT PAGE')),
46+
child: Center(child: Text('SETTINGS PAGE')),
4747
);
4848
},
4949
),

lib/router/routes.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,16 @@ abstract final class Routes {
55
static const headlinesFeedName = 'headlinesFeed';
66
static const search = '/search';
77
static const searchName = 'search';
8-
static const account = '/account';
9-
static const accountName = 'account';
8+
static const settings = '/settings';
9+
static const settingsName = 'settings';
1010
static const articleDetailsName = 'articleDetails'; // For the sub-route
1111

1212
static String getRouteNameByIndex(int index) {
1313
switch (index) {
1414
case 0:
1515
return headlinesFeedName;
1616
case 1:
17-
return searchName;
18-
case 2:
19-
return accountName;
17+
return settingsName;
2018
default:
2119
throw ArgumentError('Invalid index: $index');
2220
}

0 commit comments

Comments
 (0)