Skip to content

Commit f0a8588

Browse files
committed
refactor(router): flatten content management routes
- Simplified routes structure - Improved navigation flow
1 parent 75064d4 commit f0a8588

File tree

2 files changed

+48
-87
lines changed

2 files changed

+48
-87
lines changed

lib/router/router.dart

Lines changed: 48 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -159,80 +159,59 @@ GoRouter createRouter({
159159
name: Routes.contentManagementName,
160160
builder: (context, state) => const ContentManagementPage(),
161161
routes: [
162+
// The create/edit routes are now direct children of
163+
// content-management, so navigating back will always land on
164+
// the ContentManagementPage with the correct AppBar/TabBar.
162165
GoRoute(
163-
path: Routes.headlines,
164-
name: Routes.headlinesName,
165-
builder: (context, state) => const HeadlinesPage(),
166-
routes: [
167-
GoRoute(
168-
path: Routes.createHeadline,
169-
name: Routes.createHeadlineName,
170-
builder: (context, state) =>
171-
const PlaceholderCreatePage(
172-
title: 'Create New Headline',
173-
), // Placeholder
174-
),
175-
GoRoute(
176-
path: Routes.editHeadline,
177-
name: Routes.editHeadlineName,
178-
builder: (context, state) {
179-
final id = state.pathParameters['id']!;
180-
return PlaceholderCreatePage(
181-
title: 'Edit Headline $id',
182-
); // Placeholder
183-
},
184-
),
185-
],
166+
path: Routes.createHeadline,
167+
name: Routes.createHeadlineName,
168+
builder: (context, state) => const PlaceholderCreatePage(
169+
title: 'Create New Headline',
170+
), // Placeholder
186171
),
187172
GoRoute(
188-
path: Routes.categories,
189-
name: Routes.categoriesName,
190-
builder: (context, state) => const CategoriesPage(),
191-
routes: [
192-
GoRoute(
193-
path: Routes.createCategory,
194-
name: Routes.createCategoryName,
195-
builder: (context, state) =>
196-
const PlaceholderCreatePage(
197-
title: 'Create New Category',
198-
), // Placeholder
199-
),
200-
GoRoute(
201-
path: Routes.editCategory,
202-
name: Routes.editCategoryName,
203-
builder: (context, state) {
204-
final id = state.pathParameters['id']!;
205-
return PlaceholderCreatePage(
206-
title: 'Edit Category $id',
207-
); // Placeholder
208-
},
209-
),
210-
],
173+
path: Routes.editHeadline,
174+
name: Routes.editHeadlineName,
175+
builder: (context, state) {
176+
final id = state.pathParameters['id']!;
177+
return PlaceholderCreatePage(
178+
title: 'Edit Headline $id',
179+
); // Placeholder
180+
},
211181
),
212182
GoRoute(
213-
path: Routes.sources,
214-
name: Routes.sourcesName,
215-
builder: (context, state) => const SourcesPage(),
216-
routes: [
217-
GoRoute(
218-
path: Routes.createSource,
219-
name: Routes.createSourceName,
220-
builder: (context, state) =>
221-
const PlaceholderCreatePage(
222-
title: 'Create New Source',
223-
), // Placeholder
224-
),
225-
GoRoute(
226-
path: Routes.editSource,
227-
name: Routes.editSourceName,
228-
builder: (context, state) {
229-
final id = state.pathParameters['id']!;
230-
return PlaceholderCreatePage(
231-
title: 'Edit Source $id',
232-
); // Placeholder
233-
},
234-
),
235-
],
183+
path: Routes.createCategory,
184+
name: Routes.createCategoryName,
185+
builder: (context, state) => const PlaceholderCreatePage(
186+
title: 'Create New Category',
187+
), // Placeholder
188+
),
189+
GoRoute(
190+
path: Routes.editCategory,
191+
name: Routes.editCategoryName,
192+
builder: (context, state) {
193+
final id = state.pathParameters['id']!;
194+
return PlaceholderCreatePage(
195+
title: 'Edit Category $id',
196+
); // Placeholder
197+
},
198+
),
199+
GoRoute(
200+
path: Routes.createSource,
201+
name: Routes.createSourceName,
202+
builder: (context, state) => const PlaceholderCreatePage(
203+
title: 'Create New Source',
204+
), // Placeholder
205+
),
206+
GoRoute(
207+
path: Routes.editSource,
208+
name: Routes.editSourceName,
209+
builder: (context, state) {
210+
final id = state.pathParameters['id']!;
211+
return PlaceholderCreatePage(
212+
title: 'Edit Source $id',
213+
); // Placeholder
214+
},
236215
),
237216
],
238217
),

lib/router/routes.dart

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,6 @@ abstract final class Routes {
4444
/// The name for the content management section route.
4545
static const String contentManagementName = 'contentManagement';
4646

47-
/// The path for the headlines page within content management.
48-
static const String headlines = 'headlines';
49-
50-
/// The name for the headlines page route.
51-
static const String headlinesName = 'headlines';
52-
5347
/// The path for creating a new headline.
5448
static const String createHeadline = 'create-headline';
5549

@@ -62,12 +56,6 @@ abstract final class Routes {
6256
/// The name for the edit headline page route.
6357
static const String editHeadlineName = 'editHeadline';
6458

65-
/// The path for the categories page within content management.
66-
static const String categories = 'categories';
67-
68-
/// The name for the categories page route.
69-
static const String categoriesName = 'categories';
70-
7159
/// The path for creating a new category.
7260
static const String createCategory = 'create-category';
7361

@@ -80,12 +68,6 @@ abstract final class Routes {
8068
/// The name for the edit category page route.
8169
static const String editCategoryName = 'editCategory';
8270

83-
/// The path for the sources page within content management.
84-
static const String sources = 'sources';
85-
86-
/// The name for the sources page route.
87-
static const String sourcesName = 'sources';
88-
8971
/// The path for creating a new source.
9072
static const String createSource = 'create-source';
9173

0 commit comments

Comments
 (0)