mirror of
https://github.com/foss42/apidash.git
synced 2025-12-05 04:18:56 +08:00
Refactor DashBot
This commit is contained in:
32
lib/dashbot/routes/dashbot_router.dart
Normal file
32
lib/dashbot/routes/dashbot_router.dart
Normal file
@@ -0,0 +1,32 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../constants.dart';
|
||||
import '../pages/pages.dart';
|
||||
import 'dashbot_routes.dart';
|
||||
|
||||
Route<dynamic>? generateRoute(RouteSettings settings) {
|
||||
switch (settings.name) {
|
||||
case (DashbotRoutes.dashbotHome):
|
||||
return MaterialPageRoute(
|
||||
settings: const RouteSettings(name: DashbotRoutes.dashbotHome),
|
||||
builder: (context) => DashbotHomePage(),
|
||||
);
|
||||
case (DashbotRoutes.dashbotDefault):
|
||||
return MaterialPageRoute(
|
||||
settings: const RouteSettings(name: DashbotRoutes.dashbotDefault),
|
||||
builder: (context) => DashbotDefaultPage(),
|
||||
);
|
||||
case (DashbotRoutes.dashbotChat):
|
||||
final arg = settings.arguments;
|
||||
ChatMessageType? initialTask;
|
||||
if (arg is ChatMessageType) initialTask = arg;
|
||||
return MaterialPageRoute(
|
||||
settings: const RouteSettings(name: DashbotRoutes.dashbotChat),
|
||||
builder: (context) => ChatScreen(initialTask: initialTask),
|
||||
);
|
||||
default:
|
||||
return MaterialPageRoute(
|
||||
settings: const RouteSettings(name: DashbotRoutes.dashbotDefault),
|
||||
builder: (context) => DashbotDefaultPage(),
|
||||
);
|
||||
}
|
||||
}
|
||||
6
lib/dashbot/routes/dashbot_routes.dart
Normal file
6
lib/dashbot/routes/dashbot_routes.dart
Normal file
@@ -0,0 +1,6 @@
|
||||
class DashbotRoutes {
|
||||
static const String dashbotHome = '/dashbothome';
|
||||
static const String dashbotDefault = '/dashbotdefault';
|
||||
static const String dashbotChat = '/dashbotchat';
|
||||
static const String dashbotUnknown = '/dashbotunknown';
|
||||
}
|
||||
2
lib/dashbot/routes/routes.dart
Normal file
2
lib/dashbot/routes/routes.dart
Normal file
@@ -0,0 +1,2 @@
|
||||
export 'dashbot_router.dart';
|
||||
export 'dashbot_routes.dart';
|
||||
Reference in New Issue
Block a user