Skip to content

Commit ffbc015

Browse files
committed
feat(router): implement named navigation
- Added names to routes - Added example sub-route - Updated Routes class
1 parent 378a1f9 commit ffbc015

File tree

5 files changed

+28
-3
lines changed

5 files changed

+28
-3
lines changed

lib/router/router.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,24 @@ final appRouter = GoRouter(
1414
routes: [
1515
GoRoute(
1616
path: Routes.headlinesFeed,
17+
name: Routes.headlinesFeedName,
1718
builder: (BuildContext context, GoRouterState state) {
1819
return const HeadlinesFeedPage();
1920
},
21+
routes: [
22+
GoRoute(
23+
path: 'article/:id',
24+
name: Routes.articleDetailsName,
25+
builder: (BuildContext context, GoRouterState state) {
26+
final id = state.pathParameters['id']!;
27+
return Placeholder(child: Text('Article ID: $id'));
28+
},
29+
),
30+
],
2031
),
2132
GoRoute(
2233
path: Routes.search,
34+
name: Routes.searchName,
2335
builder: (BuildContext context, GoRouterState state) {
2436
return const Placeholder(
2537
child: Center(
@@ -30,6 +42,7 @@ final appRouter = GoRouter(
3042
),
3143
GoRoute(
3244
path: Routes.account,
45+
name: Routes.accountName,
3346
builder: (BuildContext context, GoRouterState state) {
3447
return const Placeholder(
3548
child: Center(

lib/router/routes.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
abstract final class Routes {
22
static const home = '/';
3+
static const homeName = 'home';
34
static const headlinesFeed = '/headlines-feed';
5+
static const headlinesFeedName = 'headlinesFeed';
46
static const search = '/search';
7+
static const searchName = 'search';
58
static const account = '/account';
9+
static const accountName = 'account';
10+
static const articleDetailsName = 'articleDetails'; // For the sub-route
611
}

memory-bank/activeContext.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,14 @@ Initializing the memory bank. This involves creating the core files and populati
1717
- Updated `.clinerules` with the convention to document no-op operations.
1818
- Updated `.clinerules` with error handling best practices.
1919

20+
## Recent Changes
21+
- Refactored the router (`lib/router/router.dart` and `lib/router/routes.dart`):
22+
- Added `name` parameters to `GoRoute` definitions for named navigation.
23+
- Added an example sub-route (`article/:id`) to demonstrate detail page routing.
24+
- Updated the `Routes` class to include name constants.
25+
2026
## Next Steps
21-
- Update `progress.md`
27+
- Update `progress.md`.
2228

2329
## Active Decisions
2430

memory-bank/progress.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- BLoC pattern implementation for state management.
77
- Repository pattern for data access.
88
- Initial Memory Bank setup.
9+
- Router refactoring with named navigation and example sub-route.
910
- `headlines-feed` feature:
1011
- `HeadlinesFeedBloc` for managing headlines data and filtering.
1112
- `HeadlinesFeedPage` and `_HeadlinesFeedView` for displaying headlines.
@@ -17,7 +18,7 @@
1718

1819
- Integration with a real headlines API (currently using an in-memory client).
1920
- Full implementation of filtering functionality (UI is present, but API integration may be needed).
20-
- Navigation and routing (basic setup exists, but likely needs more work for navigating to article details, etc.).
21+
- Navigation and routing (basic setup exists, named navigation implemented, sub-routes need further implementation based on application needs).
2122
- Error handling and potentially loading states (basic widgets exist, but more robust handling may be needed).
2223
- Testing.
2324

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: ht_main
22
description: main headlines toolkit mobile app.
3-
version: 0.13.0
3+
version: 0.14.0
44
publish_to: none
55
repository: https://github.com/headlines-toolkit/ht-main
66
environment:

0 commit comments

Comments
 (0)