Skip to content

Commit ae36a8b

Browse files
committed
feat(router): add nested routes for create/edit
- Added create headline route - Added create/edit category routes - Added create/edit source routes
1 parent 7b77849 commit ae36a8b

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

lib/router/router.dart

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import 'package:ht_dashboard/dashboard/view/dashboard_page.dart';
1818
import 'package:ht_dashboard/l10n/l10n.dart';
1919
import 'package:ht_dashboard/router/routes.dart';
2020
import 'package:ht_dashboard/settings/view/settings_page.dart';
21+
import 'package:ht_dashboard/shared/widgets/placeholder_create_page.dart';
2122

2223
/// Creates and configures the GoRouter instance for the application.
2324
///
@@ -165,16 +166,66 @@ GoRouter createRouter({
165166
path: Routes.headlines,
166167
name: Routes.headlinesName,
167168
builder: (context, state) => const HeadlinesPage(),
169+
routes: [
170+
GoRoute(
171+
path: Routes.createHeadline,
172+
name: Routes.createHeadlineName,
173+
builder: (context, state) =>
174+
const PlaceholderCreatePage(
175+
title: 'Create New Headline',
176+
), // Placeholder
177+
),
178+
],
168179
),
169180
GoRoute(
170181
path: Routes.categories,
171182
name: Routes.categoriesName,
172183
builder: (context, state) => const CategoriesPage(),
184+
routes: [
185+
GoRoute(
186+
path: Routes.createCategory,
187+
name: Routes.createCategoryName,
188+
builder: (context, state) =>
189+
const PlaceholderCreatePage(
190+
title: 'Create New Category',
191+
), // Placeholder
192+
),
193+
GoRoute(
194+
path: Routes.editCategory,
195+
name: Routes.editCategoryName,
196+
builder: (context, state) {
197+
final id = state.pathParameters['id']!;
198+
return PlaceholderCreatePage(
199+
title: 'Edit Category $id',
200+
); // Placeholder
201+
},
202+
),
203+
],
173204
),
174205
GoRoute(
175206
path: Routes.sources,
176207
name: Routes.sourcesName,
177208
builder: (context, state) => const SourcesPage(),
209+
routes: [
210+
GoRoute(
211+
path: Routes.createSource,
212+
name: Routes.createSourceName,
213+
builder: (context, state) =>
214+
const PlaceholderCreatePage(
215+
title: 'Create New Source',
216+
), // Placeholder
217+
),
218+
GoRoute(
219+
path: Routes.editSource,
220+
name: Routes.editSourceName,
221+
builder: (context, state) {
222+
final id = state.pathParameters['id']!;
223+
return PlaceholderCreatePage(
224+
title: 'Edit Source $id',
225+
); // Placeholder
226+
},
227+
),
228+
],
178229
),
179230
],
180231
),

lib/router/routes.dart

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,48 @@ abstract final class Routes {
5050
/// The name for the headlines page route.
5151
static const String headlinesName = 'headlines';
5252

53+
/// The path for creating a new headline.
54+
static const String createHeadline = 'create-headline';
55+
56+
/// The name for the create headline page route.
57+
static const String createHeadlineName = 'createHeadline';
58+
5359
/// The path for the categories page within content management.
5460
static const String categories = 'categories';
5561

5662
/// The name for the categories page route.
5763
static const String categoriesName = 'categories';
5864

65+
/// The path for creating a new category.
66+
static const String createCategory = 'create-category';
67+
68+
/// The name for the create category page route.
69+
static const String createCategoryName = 'createCategory';
70+
71+
/// The path for editing an existing category.
72+
static const String editCategory = 'edit-category/:id';
73+
74+
/// The name for the edit category page route.
75+
static const String editCategoryName = 'editCategory';
76+
5977
/// The path for the sources page within content management.
6078
static const String sources = 'sources';
6179

6280
/// The name for the sources page route.
6381
static const String sourcesName = 'sources';
6482

83+
/// The path for creating a new source.
84+
static const String createSource = 'create-source';
85+
86+
/// The name for the create source page route.
87+
static const String createSourceName = 'createSource';
88+
89+
/// The path for editing an existing source.
90+
static const String editSource = 'edit-source/:id';
91+
92+
/// The name for the edit source page route.
93+
static const String editSourceName = 'editSource';
94+
6595
/// The path for the app configuration page.
6696
static const String appConfiguration = '/app-configuration';
6797

0 commit comments

Comments
 (0)