mirror of
https://github.com/foss42/apidash.git
synced 2025-12-01 18:28:25 +08:00
feat: move generation buttons to dashbot
This commit is contained in:
@@ -93,23 +93,37 @@ class _DashbotHomePageState extends ConsumerState<DashbotHomePage> {
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
if (currentRequest?.httpResponseModel?.statusCode != null &&
|
||||
currentRequest?.httpResponseModel?.statusCode == 200) ...[
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
children: const [
|
||||
Expanded(
|
||||
child: GenerateToolButton(),
|
||||
if (currentRequest?.httpResponseModel?.statusCode != null &&
|
||||
currentRequest?.httpResponseModel?.statusCode == 200) ...[
|
||||
HomeScreenTaskButton(
|
||||
label: "🛠️ Generate Tool",
|
||||
onPressed: () {
|
||||
GenerateToolDialog.show(context, ref);
|
||||
},
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: AIGenerateUIButton(),
|
||||
HomeScreenTaskButton(
|
||||
label: "📱 Generate UI",
|
||||
onPressed: () {
|
||||
final model = ref.watch(selectedRequestModelProvider
|
||||
.select((value) => value?.httpResponseModel));
|
||||
if (model == null) return;
|
||||
|
||||
String data = "";
|
||||
if (model.sseOutput != null) {
|
||||
data = model.sseOutput!.join('');
|
||||
} else {
|
||||
data = model.formattedBody ?? "<>";
|
||||
}
|
||||
|
||||
showCustomDialog(
|
||||
context,
|
||||
GenerateUIDialog(content: data),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import 'package:apidash/consts.dart';
|
||||
import 'package:apidash/providers/collection_providers.dart';
|
||||
import 'package:apidash/services/agentic_services/apidash_agent_calls.dart';
|
||||
import 'package:apidash/widgets/widget_sending.dart';
|
||||
import 'package:apidash_design_system/apidash_design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'framework_selector.dart';
|
||||
@@ -150,42 +147,3 @@ class _GenerateUIDialogState extends ConsumerState<GenerateUIDialog> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class AIGenerateUIButton extends ConsumerWidget {
|
||||
const AIGenerateUIButton({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
return FilledButton.tonalIcon(
|
||||
style: FilledButton.styleFrom(
|
||||
padding: kPh12,
|
||||
minimumSize: const Size(44, 44),
|
||||
),
|
||||
onPressed: () {
|
||||
final model = ref.watch(selectedRequestModelProvider
|
||||
.select((value) => value?.httpResponseModel));
|
||||
if (model == null) return;
|
||||
|
||||
String data = "";
|
||||
if (model.sseOutput != null) {
|
||||
data = model.sseOutput!.join('');
|
||||
} else {
|
||||
data = model.formattedBody ?? "<>";
|
||||
}
|
||||
|
||||
showCustomDialog(
|
||||
context,
|
||||
GenerateUIDialog(content: data),
|
||||
);
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.generating_tokens,
|
||||
),
|
||||
label: const SizedBox(
|
||||
child: Text(
|
||||
kLabelGenerateUI,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,31 +9,6 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'generated_tool_codecopy.dart';
|
||||
import 'tool_requirements_selector.dart';
|
||||
|
||||
class GenerateToolButton extends ConsumerWidget {
|
||||
const GenerateToolButton({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
return FilledButton.tonalIcon(
|
||||
style: FilledButton.styleFrom(
|
||||
padding: kPh12,
|
||||
minimumSize: const Size(44, 44),
|
||||
),
|
||||
onPressed: () async {
|
||||
GenerateToolDialog.show(context, ref);
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.token_outlined,
|
||||
),
|
||||
label: const SizedBox(
|
||||
child: Text(
|
||||
"Generate Tool",
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class GenerateToolDialog extends ConsumerStatefulWidget {
|
||||
final APIDashRequestDescription requestDesc;
|
||||
const GenerateToolDialog({
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
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_core/apidash_core.dart';
|
||||
import 'package:apidash_design_system/apidash_design_system.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
@@ -65,15 +63,6 @@ class _ResponseBodySuccessState extends State<ResponseBodySuccess> {
|
||||
padding: kP10,
|
||||
child: Column(
|
||||
children: [
|
||||
if (!widget.isPartOfHistory)
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Expanded(child: GenerateToolButton()),
|
||||
SizedBox(width: 10),
|
||||
Expanded(child: AIGenerateUIButton()),
|
||||
],
|
||||
),
|
||||
kVSpacer10,
|
||||
Row(
|
||||
children: [
|
||||
|
||||
Reference in New Issue
Block a user