update routing
This commit is contained in:
@@ -5,6 +5,7 @@ import 'package:bang_navigator/features/bangs/presentation/screens/list.dart';
|
||||
import 'package:bang_navigator/features/bangs/presentation/screens/search.dart';
|
||||
import 'package:bang_navigator/features/chat_archive/presentation/screens/detail.dart';
|
||||
import 'package:bang_navigator/features/chat_archive/presentation/screens/list.dart';
|
||||
import 'package:bang_navigator/features/chat_archive/presentation/screens/search.dart';
|
||||
import 'package:bang_navigator/features/search_browser/presentation/screens/browser.dart';
|
||||
import 'package:bang_navigator/features/settings/presentation/screens/settings.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -24,9 +25,13 @@ part 'routes.g.dart';
|
||||
name: 'BangRoute',
|
||||
path: 'bangs',
|
||||
routes: [
|
||||
TypedGoRoute<BangSearchRoute>(
|
||||
name: 'BangSearchRoute',
|
||||
path: 'search',
|
||||
),
|
||||
TypedGoRoute<BangCategoryRoute>(
|
||||
name: 'BangCategoryRoute',
|
||||
path: ':category',
|
||||
path: 'category/:category',
|
||||
routes: [
|
||||
TypedGoRoute<BangSubCategoryRoute>(
|
||||
name: 'BangSubCategoryRoute',
|
||||
@@ -36,10 +41,6 @@ part 'routes.g.dart';
|
||||
),
|
||||
],
|
||||
),
|
||||
TypedGoRoute<BangSearchRoute>(
|
||||
name: 'BangSearchRoute',
|
||||
path: 'bang_search',
|
||||
),
|
||||
],
|
||||
)
|
||||
class KagiRoute extends GoRouteData {
|
||||
@@ -111,6 +112,10 @@ class SettingsRoute extends GoRouteData {
|
||||
name: 'ChatArchiveListRoute',
|
||||
path: '/chat_archive',
|
||||
routes: [
|
||||
TypedGoRoute<ChatArchiveSearchRoute>(
|
||||
name: 'ChatArchiveSearchRoute',
|
||||
path: 'search',
|
||||
),
|
||||
TypedGoRoute<ChatArchiveDetailRoute>(
|
||||
name: 'ChatArchiveDetailRoute',
|
||||
path: 'detail/:fileName',
|
||||
@@ -124,6 +129,13 @@ class ChatArchiveListRoute extends GoRouteData {
|
||||
}
|
||||
}
|
||||
|
||||
class ChatArchiveSearchRoute extends GoRouteData {
|
||||
@override
|
||||
Widget build(BuildContext context, GoRouterState state) {
|
||||
return const ChatArchiveSearchScreen();
|
||||
}
|
||||
}
|
||||
|
||||
class ChatArchiveDetailRoute extends GoRouteData {
|
||||
final String fileName;
|
||||
|
||||
|
||||
@@ -28,7 +28,12 @@ RouteBase get $kagiRoute => GoRouteData.$route(
|
||||
factory: $BangCategoriesRouteExtension._fromState,
|
||||
routes: [
|
||||
GoRouteData.$route(
|
||||
path: ':category',
|
||||
path: 'search',
|
||||
name: 'BangSearchRoute',
|
||||
factory: $BangSearchRouteExtension._fromState,
|
||||
),
|
||||
GoRouteData.$route(
|
||||
path: 'category/:category',
|
||||
name: 'BangCategoryRoute',
|
||||
factory: $BangCategoryRouteExtension._fromState,
|
||||
routes: [
|
||||
@@ -41,11 +46,6 @@ RouteBase get $kagiRoute => GoRouteData.$route(
|
||||
),
|
||||
],
|
||||
),
|
||||
GoRouteData.$route(
|
||||
path: 'bang_search',
|
||||
name: 'BangSearchRoute',
|
||||
factory: $BangSearchRouteExtension._fromState,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -101,13 +101,30 @@ extension $BangCategoriesRouteExtension on BangCategoriesRoute {
|
||||
void replace(BuildContext context) => context.replace(location);
|
||||
}
|
||||
|
||||
extension $BangSearchRouteExtension on BangSearchRoute {
|
||||
static BangSearchRoute _fromState(GoRouterState state) => BangSearchRoute();
|
||||
|
||||
String get location => GoRouteData.$location(
|
||||
'/bangs/search',
|
||||
);
|
||||
|
||||
void go(BuildContext context) => context.go(location);
|
||||
|
||||
Future<T?> push<T>(BuildContext context) => context.push<T>(location);
|
||||
|
||||
void pushReplacement(BuildContext context) =>
|
||||
context.pushReplacement(location);
|
||||
|
||||
void replace(BuildContext context) => context.replace(location);
|
||||
}
|
||||
|
||||
extension $BangCategoryRouteExtension on BangCategoryRoute {
|
||||
static BangCategoryRoute _fromState(GoRouterState state) => BangCategoryRoute(
|
||||
category: state.pathParameters['category']!,
|
||||
);
|
||||
|
||||
String get location => GoRouteData.$location(
|
||||
'/bangs/${Uri.encodeComponent(category)}',
|
||||
'/bangs/category/${Uri.encodeComponent(category)}',
|
||||
);
|
||||
|
||||
void go(BuildContext context) => context.go(location);
|
||||
@@ -128,24 +145,7 @@ extension $BangSubCategoryRouteExtension on BangSubCategoryRoute {
|
||||
);
|
||||
|
||||
String get location => GoRouteData.$location(
|
||||
'/bangs/${Uri.encodeComponent(category)}/${Uri.encodeComponent(subCategory)}',
|
||||
);
|
||||
|
||||
void go(BuildContext context) => context.go(location);
|
||||
|
||||
Future<T?> push<T>(BuildContext context) => context.push<T>(location);
|
||||
|
||||
void pushReplacement(BuildContext context) =>
|
||||
context.pushReplacement(location);
|
||||
|
||||
void replace(BuildContext context) => context.replace(location);
|
||||
}
|
||||
|
||||
extension $BangSearchRouteExtension on BangSearchRoute {
|
||||
static BangSearchRoute _fromState(GoRouterState state) => BangSearchRoute();
|
||||
|
||||
String get location => GoRouteData.$location(
|
||||
'/bang_search',
|
||||
'/bangs/category/${Uri.encodeComponent(category)}/${Uri.encodeComponent(subCategory)}',
|
||||
);
|
||||
|
||||
void go(BuildContext context) => context.go(location);
|
||||
@@ -186,6 +186,11 @@ RouteBase get $chatArchiveListRoute => GoRouteData.$route(
|
||||
name: 'ChatArchiveListRoute',
|
||||
factory: $ChatArchiveListRouteExtension._fromState,
|
||||
routes: [
|
||||
GoRouteData.$route(
|
||||
path: 'search',
|
||||
name: 'ChatArchiveSearchRoute',
|
||||
factory: $ChatArchiveSearchRouteExtension._fromState,
|
||||
),
|
||||
GoRouteData.$route(
|
||||
path: 'detail/:fileName',
|
||||
name: 'ChatArchiveDetailRoute',
|
||||
@@ -212,6 +217,24 @@ extension $ChatArchiveListRouteExtension on ChatArchiveListRoute {
|
||||
void replace(BuildContext context) => context.replace(location);
|
||||
}
|
||||
|
||||
extension $ChatArchiveSearchRouteExtension on ChatArchiveSearchRoute {
|
||||
static ChatArchiveSearchRoute _fromState(GoRouterState state) =>
|
||||
ChatArchiveSearchRoute();
|
||||
|
||||
String get location => GoRouteData.$location(
|
||||
'/chat_archive/search',
|
||||
);
|
||||
|
||||
void go(BuildContext context) => context.go(location);
|
||||
|
||||
Future<T?> push<T>(BuildContext context) => context.push<T>(location);
|
||||
|
||||
void pushReplacement(BuildContext context) =>
|
||||
context.pushReplacement(location);
|
||||
|
||||
void replace(BuildContext context) => context.replace(location);
|
||||
}
|
||||
|
||||
extension $ChatArchiveDetailRouteExtension on ChatArchiveDetailRoute {
|
||||
static ChatArchiveDetailRoute _fromState(GoRouterState state) =>
|
||||
ChatArchiveDetailRoute(
|
||||
|
||||
Reference in New Issue
Block a user