mirror of
https://github.com/foss42/apidash.git
synced 2025-12-03 03:17:00 +08:00
feat: enhance routing and state management in Dashbot components
This commit is contained in:
@@ -9,17 +9,27 @@ import 'package:flutter/material.dart';
|
||||
Route<dynamic>? generateRoute(RouteSettings settings) {
|
||||
switch (settings.name) {
|
||||
case (DashbotRoutes.dashbotHome):
|
||||
return MaterialPageRoute(builder: (context) => DashbotHomePage());
|
||||
return MaterialPageRoute(
|
||||
settings: const RouteSettings(name: DashbotRoutes.dashbotHome),
|
||||
builder: (context) => DashbotHomePage(),
|
||||
);
|
||||
case (DashbotRoutes.dashbotDefault):
|
||||
return MaterialPageRoute(builder: (context) => DashbotDefaultPage());
|
||||
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(builder: (context) => DashbotDefaultPage());
|
||||
return MaterialPageRoute(
|
||||
settings: const RouteSettings(name: DashbotRoutes.dashbotDefault),
|
||||
builder: (context) => DashbotDefaultPage(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,11 +6,7 @@ import '../providers/dashbot_window_notifier.dart';
|
||||
|
||||
/// Optionally pass provider overrides (e.g., dashbotRequestContextProvider)
|
||||
/// so the host app can feed live context into Dashbot.
|
||||
void showDashbotWindow(
|
||||
BuildContext context,
|
||||
WidgetRef ref, {
|
||||
List<Override>? overrides,
|
||||
}) {
|
||||
void showDashbotWindow(BuildContext context, WidgetRef ref) {
|
||||
final isDashbotActive = ref.read(dashbotWindowNotifierProvider).isActive;
|
||||
final isDashbotPopped = ref.read(dashbotWindowNotifierProvider).isPopped;
|
||||
final windowNotifier = ref.read(dashbotWindowNotifierProvider.notifier);
|
||||
@@ -21,7 +17,6 @@ void showDashbotWindow(
|
||||
|
||||
entry = OverlayEntry(
|
||||
builder: (context) => ProviderScope(
|
||||
overrides: overrides ?? const [],
|
||||
child: DashbotWindow(
|
||||
onClose: () {
|
||||
entry?.remove();
|
||||
|
||||
Reference in New Issue
Block a user