mirror of
https://github.com/foss42/apidash.git
synced 2025-11-30 17:59:18 +08:00
feat: rearrange dashbot home buttons
This commit is contained in:
@@ -144,6 +144,10 @@ class DashbotWindow extends ConsumerWidget {
|
|||||||
.read(dashbotWindowNotifierProvider
|
.read(dashbotWindowNotifierProvider
|
||||||
.notifier)
|
.notifier)
|
||||||
.togglePopped();
|
.togglePopped();
|
||||||
|
ref
|
||||||
|
.read(dashbotWindowNotifierProvider
|
||||||
|
.notifier)
|
||||||
|
.toggleActive();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:apidash/providers/collection_providers.dart';
|
import 'package:apidash/providers/collection_providers.dart';
|
||||||
import 'package:apidash/screens/common_widgets/agentic_ui_features/ai_ui_designer/generate_ui_dialog.dart';
|
import 'package:apidash/screens/common_widgets/agentic_ui_features/ai_ui_designer/generate_ui_dialog.dart';
|
||||||
import 'package:apidash/screens/common_widgets/agentic_ui_features/tool_generation/generate_tool_dialog.dart';
|
import 'package:apidash/screens/common_widgets/agentic_ui_features/tool_generation/generate_tool_dialog.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
|
||||||
import '../../../../core/utils/dashbot_icons.dart';
|
import '../../../../core/utils/dashbot_icons.dart';
|
||||||
import '../../../../core/providers/dashbot_window_notifier.dart';
|
import '../../../../core/providers/dashbot_window_notifier.dart';
|
||||||
@@ -22,11 +23,11 @@ class DashbotHomePage extends ConsumerStatefulWidget {
|
|||||||
class _DashbotHomePageState extends ConsumerState<DashbotHomePage> {
|
class _DashbotHomePageState extends ConsumerState<DashbotHomePage> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final hasOkResponse = ref.watch(
|
// final hasOkResponse = ref.watch(
|
||||||
selectedRequestModelProvider.select((req) =>
|
// selectedRequestModelProvider.select((req) =>
|
||||||
req?.httpResponseModel?.statusCode != null &&
|
// req?.httpResponseModel?.statusCode != null &&
|
||||||
req?.httpResponseModel?.statusCode == 200),
|
// req?.httpResponseModel?.statusCode == 200),
|
||||||
);
|
// );
|
||||||
|
|
||||||
// ref.listen(
|
// ref.listen(
|
||||||
// selectedRequestModelProvider,
|
// selectedRequestModelProvider,
|
||||||
@@ -54,32 +55,16 @@ class _DashbotHomePageState extends ConsumerState<DashbotHomePage> {
|
|||||||
spacing: 8,
|
spacing: 8,
|
||||||
runSpacing: 8,
|
runSpacing: 8,
|
||||||
children: [
|
children: [
|
||||||
HomeScreenTaskButton(
|
if (kDebugMode) ...[
|
||||||
label: "🤖 Chat with Dashbot",
|
HomeScreenTaskButton(
|
||||||
onPressed: () {
|
label: "🤖 Chat with Dashbot",
|
||||||
Navigator.of(context).pushNamed(
|
onPressed: () {
|
||||||
DashbotRoutes.dashbotChat,
|
Navigator.of(context).pushNamed(
|
||||||
);
|
DashbotRoutes.dashbotChat,
|
||||||
},
|
);
|
||||||
),
|
},
|
||||||
HomeScreenTaskButton(
|
),
|
||||||
label: "📥 Import cURL",
|
],
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pushNamed(
|
|
||||||
DashbotRoutes.dashbotChat,
|
|
||||||
arguments: ChatMessageType.importCurl,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
HomeScreenTaskButton(
|
|
||||||
label: "📄 Import OpenAPI",
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pushNamed(
|
|
||||||
DashbotRoutes.dashbotChat,
|
|
||||||
arguments: ChatMessageType.importOpenApi,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
HomeScreenTaskButton(
|
HomeScreenTaskButton(
|
||||||
label: "🔎 Explain me this response",
|
label: "🔎 Explain me this response",
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
@@ -125,43 +110,59 @@ class _DashbotHomePageState extends ConsumerState<DashbotHomePage> {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
if (hasOkResponse) ...[
|
HomeScreenTaskButton(
|
||||||
HomeScreenTaskButton(
|
label: "📥 Import cURL",
|
||||||
label: "🛠️ Generate Tool",
|
onPressed: () {
|
||||||
onPressed: () async {
|
Navigator.of(context).pushNamed(
|
||||||
final notifier =
|
DashbotRoutes.dashbotChat,
|
||||||
ref.read(dashbotWindowNotifierProvider.notifier);
|
arguments: ChatMessageType.importCurl,
|
||||||
notifier.hide();
|
);
|
||||||
await GenerateToolDialog.show(context, ref);
|
},
|
||||||
notifier.show();
|
),
|
||||||
},
|
HomeScreenTaskButton(
|
||||||
),
|
label: "📄 Import OpenAPI",
|
||||||
HomeScreenTaskButton(
|
onPressed: () {
|
||||||
label: "📱 Generate UI",
|
Navigator.of(context).pushNamed(
|
||||||
onPressed: () async {
|
DashbotRoutes.dashbotChat,
|
||||||
final notifier =
|
arguments: ChatMessageType.importOpenApi,
|
||||||
ref.read(dashbotWindowNotifierProvider.notifier);
|
);
|
||||||
notifier.hide();
|
},
|
||||||
final model = ref.watch(selectedRequestModelProvider
|
),
|
||||||
.select((value) => value?.httpResponseModel));
|
HomeScreenTaskButton(
|
||||||
if (model == null) return;
|
label: "🛠️ Generate Tool",
|
||||||
|
onPressed: () async {
|
||||||
|
final notifier =
|
||||||
|
ref.read(dashbotWindowNotifierProvider.notifier);
|
||||||
|
notifier.hide();
|
||||||
|
await GenerateToolDialog.show(context, ref);
|
||||||
|
notifier.show();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
HomeScreenTaskButton(
|
||||||
|
label: "📱 Generate UI",
|
||||||
|
onPressed: () async {
|
||||||
|
final notifier =
|
||||||
|
ref.read(dashbotWindowNotifierProvider.notifier);
|
||||||
|
notifier.hide();
|
||||||
|
final model = ref.watch(selectedRequestModelProvider
|
||||||
|
.select((value) => value?.httpResponseModel));
|
||||||
|
if (model == null) return;
|
||||||
|
|
||||||
String data = "";
|
String data = "";
|
||||||
if (model.sseOutput != null) {
|
if (model.sseOutput != null) {
|
||||||
data = model.sseOutput!.join('');
|
data = model.sseOutput!.join('');
|
||||||
} else {
|
} else {
|
||||||
data = model.formattedBody ?? "<>";
|
data = model.formattedBody ?? "<>";
|
||||||
}
|
}
|
||||||
|
|
||||||
await showCustomDialog(
|
await showCustomDialog(
|
||||||
context,
|
context,
|
||||||
GenerateUIDialog(content: data),
|
GenerateUIDialog(content: data),
|
||||||
useRootNavigator: true,
|
useRootNavigator: true,
|
||||||
);
|
);
|
||||||
notifier.show();
|
notifier.show();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ class Dashboard extends ConsumerWidget {
|
|||||||
final railIdx = ref.watch(navRailIndexStateProvider);
|
final railIdx = ref.watch(navRailIndexStateProvider);
|
||||||
final isDashBotEnabled =
|
final isDashBotEnabled =
|
||||||
ref.watch(settingsProvider.select((value) => value.isDashBotEnabled));
|
ref.watch(settingsProvider.select((value) => value.isDashBotEnabled));
|
||||||
|
final isDashBotActive = ref
|
||||||
|
.watch(dashbotWindowNotifierProvider.select((value) => value.isActive));
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: Row(
|
child: Row(
|
||||||
@@ -127,7 +129,7 @@ class Dashboard extends ConsumerWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
floatingActionButton: isDashBotEnabled
|
floatingActionButton: isDashBotEnabled && !isDashBotActive
|
||||||
? FloatingActionButton(
|
? FloatingActionButton(
|
||||||
backgroundColor: Theme.of(context).colorScheme.primaryContainer,
|
backgroundColor: Theme.of(context).colorScheme.primaryContainer,
|
||||||
onPressed: () => showDashbotWindow(context, ref),
|
onPressed: () => showDashbotWindow(context, ref),
|
||||||
|
|||||||
Reference in New Issue
Block a user