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:
@@ -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(),
|
||||
),
|
||||
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,33 +53,34 @@ class _SendingWidgetState extends State<SendingWidget> {
|
||||
Center(
|
||||
child: Lottie.asset(kAssetSendingLottie),
|
||||
),
|
||||
Padding(
|
||||
padding: kPh20t40,
|
||||
child: Visibility(
|
||||
visible: _millisecondsElapsed >= 0,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.alarm,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Text(
|
||||
'Time elapsed: ${humanizeDuration(Duration(milliseconds: _millisecondsElapsed))}',
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.fade,
|
||||
softWrap: false,
|
||||
style: kTextStyleButton.copyWith(
|
||||
if (widget.showTimeElapsed)
|
||||
Padding(
|
||||
padding: kPh20t40,
|
||||
child: Visibility(
|
||||
visible: _millisecondsElapsed >= 0,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.alarm,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Text(
|
||||
'Time elapsed: ${humanizeDuration(Duration(milliseconds: _millisecondsElapsed))}',
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.fade,
|
||||
softWrap: false,
|
||||
style: kTextStyleButton.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user