implemented chat archive
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import 'package:bang_navigator/core/routing/dialog_page.dart';
|
||||
import 'package:bang_navigator/features/about/presentation/screens/about.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/search_browser/presentation/screens/browser.dart';
|
||||
import 'package:bang_navigator/features/settings/presentation/screens/settings.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -15,10 +17,6 @@ part 'routes.g.dart';
|
||||
name: 'AboutRoute',
|
||||
path: 'about',
|
||||
),
|
||||
TypedGoRoute<SettingsRoute>(
|
||||
name: 'SettingsRoute',
|
||||
path: 'settings',
|
||||
),
|
||||
],
|
||||
)
|
||||
class KagiRoute extends GoRouteData {
|
||||
@@ -30,6 +28,17 @@ class KagiRoute extends GoRouteData {
|
||||
}
|
||||
}
|
||||
|
||||
class AboutRoute extends GoRouteData {
|
||||
@override
|
||||
Page<void> buildPage(BuildContext context, GoRouterState state) {
|
||||
return DialogPage(builder: (_) => const AboutDialogScreen());
|
||||
}
|
||||
}
|
||||
|
||||
@TypedGoRoute<SettingsRoute>(
|
||||
name: 'SettingsRoute',
|
||||
path: '/settings',
|
||||
)
|
||||
class SettingsRoute extends GoRouteData {
|
||||
@override
|
||||
Widget build(BuildContext context, GoRouterState state) {
|
||||
@@ -37,9 +46,30 @@ class SettingsRoute extends GoRouteData {
|
||||
}
|
||||
}
|
||||
|
||||
class AboutRoute extends GoRouteData {
|
||||
@TypedGoRoute<ChatArchiveListRoute>(
|
||||
name: 'ChatArchiveListRoute',
|
||||
path: '/chat_archive',
|
||||
routes: [
|
||||
TypedGoRoute<ChatArchiveDetailRoute>(
|
||||
name: 'ChatArchiveDetailRoute',
|
||||
path: 'detail/:fileName',
|
||||
),
|
||||
],
|
||||
)
|
||||
class ChatArchiveListRoute extends GoRouteData {
|
||||
@override
|
||||
Page<void> buildPage(BuildContext context, GoRouterState state) {
|
||||
return DialogPage(builder: (_) => const AboutDialogScreen());
|
||||
Widget build(BuildContext context, GoRouterState state) {
|
||||
return const ChatArchiveListScreen();
|
||||
}
|
||||
}
|
||||
|
||||
class ChatArchiveDetailRoute extends GoRouteData {
|
||||
final String fileName;
|
||||
|
||||
const ChatArchiveDetailRoute({required this.fileName});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, GoRouterState state) {
|
||||
return ChatArchiveDetailScreen(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ part of 'routes.dart';
|
||||
|
||||
List<RouteBase> get $appRoutes => [
|
||||
$kagiRoute,
|
||||
$settingsRoute,
|
||||
$chatArchiveListRoute,
|
||||
];
|
||||
|
||||
RouteBase get $kagiRoute => GoRouteData.$route(
|
||||
@@ -20,11 +22,6 @@ RouteBase get $kagiRoute => GoRouteData.$route(
|
||||
name: 'AboutRoute',
|
||||
factory: $AboutRouteExtension._fromState,
|
||||
),
|
||||
GoRouteData.$route(
|
||||
path: 'settings',
|
||||
name: 'SettingsRoute',
|
||||
factory: $SettingsRouteExtension._fromState,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -62,6 +59,12 @@ extension $AboutRouteExtension on AboutRoute {
|
||||
void replace(BuildContext context) => context.replace(location);
|
||||
}
|
||||
|
||||
RouteBase get $settingsRoute => GoRouteData.$route(
|
||||
path: '/settings',
|
||||
name: 'SettingsRoute',
|
||||
factory: $SettingsRouteExtension._fromState,
|
||||
);
|
||||
|
||||
extension $SettingsRouteExtension on SettingsRoute {
|
||||
static SettingsRoute _fromState(GoRouterState state) => SettingsRoute();
|
||||
|
||||
@@ -78,3 +81,54 @@ extension $SettingsRouteExtension on SettingsRoute {
|
||||
|
||||
void replace(BuildContext context) => context.replace(location);
|
||||
}
|
||||
|
||||
RouteBase get $chatArchiveListRoute => GoRouteData.$route(
|
||||
path: '/chat_archive',
|
||||
name: 'ChatArchiveListRoute',
|
||||
factory: $ChatArchiveListRouteExtension._fromState,
|
||||
routes: [
|
||||
GoRouteData.$route(
|
||||
path: 'detail/:fileName',
|
||||
name: 'ChatArchiveDetailRoute',
|
||||
factory: $ChatArchiveDetailRouteExtension._fromState,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
extension $ChatArchiveListRouteExtension on ChatArchiveListRoute {
|
||||
static ChatArchiveListRoute _fromState(GoRouterState state) =>
|
||||
ChatArchiveListRoute();
|
||||
|
||||
String get location => GoRouteData.$location(
|
||||
'/chat_archive',
|
||||
);
|
||||
|
||||
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(
|
||||
fileName: state.pathParameters['fileName']!,
|
||||
);
|
||||
|
||||
String get location => GoRouteData.$location(
|
||||
'/chat_archive/detail/${Uri.encodeComponent(fileName)}',
|
||||
);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user