mirror of
https://github.com/foss42/apidash.git
synced 2025-12-02 02:39:19 +08:00
Implemented STAC_MODIFIER to enabled UI Modifications
This commit is contained in:
@@ -15,7 +15,7 @@ DO NOT CHANGE ANYTHING UNLESS SPECIFICALLY ASKED TO
|
||||
ONLY FLutter-SDUI Representation NOTHING ELSE. DO NOT START OR END WITH TEXT, ONLY FLutter-SDUI Representatiin.
|
||||
""";
|
||||
|
||||
class SlacModifierBot extends APIDashAIAgent {
|
||||
class StacModifierBot extends APIDashAIAgent {
|
||||
@override
|
||||
String get agentName => 'STAC_MODIFIER';
|
||||
|
||||
|
||||
@@ -84,6 +84,27 @@ class _DialogContentsState extends ConsumerState<DialogContents> {
|
||||
return sduiCode?['STAC']?.toString() ?? "<NONE>";
|
||||
}
|
||||
|
||||
Future<void> modifySDUICode(String modificationRequest) async {
|
||||
setState(() {
|
||||
index = 1; //Induce Loading
|
||||
});
|
||||
|
||||
final res = await APIDashAgentCaller.instance.call(
|
||||
StacModifierBot(),
|
||||
ref: ref,
|
||||
input: AgentInputs(variables: {
|
||||
'VAR_CODE': generatedSDUI,
|
||||
'VAR_CLIENT_REQUEST': modificationRequest,
|
||||
}),
|
||||
);
|
||||
|
||||
final SDUI = res['STAC'];
|
||||
setState(() {
|
||||
generatedSDUI = SDUI;
|
||||
index = 2;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return IndexedStack(
|
||||
@@ -105,24 +126,19 @@ class _DialogContentsState extends ConsumerState<DialogContents> {
|
||||
child: Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 40.0),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
// setState(() {
|
||||
// index = 2;
|
||||
// });
|
||||
},
|
||||
child: Container(
|
||||
height: 500,
|
||||
child: SendingWidget(
|
||||
startSendingTime: DateTime.now(),
|
||||
),
|
||||
showTimeElapsed: false,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SDUIPreviewPage(
|
||||
onNext: () {},
|
||||
key: ValueKey(generatedSDUI.hashCode),
|
||||
onModificationRequestMade: modifySDUICode,
|
||||
sduiCode: generatedSDUI,
|
||||
)
|
||||
],
|
||||
@@ -248,9 +264,12 @@ class _FrameWorkSelectorPageState extends State<FrameWorkSelectorPage> {
|
||||
|
||||
class SDUIPreviewPage extends ConsumerStatefulWidget {
|
||||
final String sduiCode;
|
||||
final Function() onNext;
|
||||
const SDUIPreviewPage(
|
||||
{super.key, required this.onNext, required this.sduiCode});
|
||||
final Function(String) onModificationRequestMade;
|
||||
const SDUIPreviewPage({
|
||||
super.key,
|
||||
required this.onModificationRequestMade,
|
||||
required this.sduiCode,
|
||||
});
|
||||
|
||||
@override
|
||||
ConsumerState<SDUIPreviewPage> createState() => _SDUIPreviewPageState();
|
||||
@@ -258,6 +277,7 @@ class SDUIPreviewPage extends ConsumerStatefulWidget {
|
||||
|
||||
class _SDUIPreviewPageState extends ConsumerState<SDUIPreviewPage> {
|
||||
bool exportingCode = false;
|
||||
String modificationRequest = "";
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -303,6 +323,11 @@ class _SDUIPreviewPageState extends ConsumerState<SDUIPreviewPage> {
|
||||
),
|
||||
),
|
||||
child: TextField(
|
||||
onChanged: (z) {
|
||||
setState(() {
|
||||
modificationRequest = z;
|
||||
});
|
||||
},
|
||||
maxLines: 3, // Makes the text box taller
|
||||
style: TextStyle(color: Colors.white), // White text
|
||||
decoration: InputDecoration(
|
||||
@@ -370,7 +395,9 @@ class _SDUIPreviewPageState extends ConsumerState<SDUIPreviewPage> {
|
||||
minimumSize: const Size(44, 44),
|
||||
),
|
||||
onPressed: () {
|
||||
widget.onNext();
|
||||
if (modificationRequest.isNotEmpty) {
|
||||
widget.onModificationRequestMade(modificationRequest);
|
||||
}
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.generating_tokens,
|
||||
|
||||
@@ -7,9 +7,11 @@ import 'package:apidash/consts.dart';
|
||||
|
||||
class SendingWidget extends StatefulWidget {
|
||||
final DateTime? startSendingTime;
|
||||
final bool showTimeElapsed;
|
||||
const SendingWidget({
|
||||
super.key,
|
||||
required this.startSendingTime,
|
||||
this.showTimeElapsed = true,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -51,6 +53,7 @@ class _SendingWidgetState extends State<SendingWidget> {
|
||||
Center(
|
||||
child: Lottie.asset(kAssetSendingLottie),
|
||||
),
|
||||
if (widget.showTimeElapsed)
|
||||
Padding(
|
||||
padding: kPh20t40,
|
||||
child: Visibility(
|
||||
|
||||
Reference in New Issue
Block a user