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.
|
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
|
@override
|
||||||
String get agentName => 'STAC_MODIFIER';
|
String get agentName => 'STAC_MODIFIER';
|
||||||
|
|
||||||
|
|||||||
@@ -84,6 +84,27 @@ class _DialogContentsState extends ConsumerState<DialogContents> {
|
|||||||
return sduiCode?['STAC']?.toString() ?? "<NONE>";
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return IndexedStack(
|
return IndexedStack(
|
||||||
@@ -105,24 +126,19 @@ class _DialogContentsState extends ConsumerState<DialogContents> {
|
|||||||
child: Center(
|
child: Center(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(top: 40.0),
|
padding: const EdgeInsets.only(top: 40.0),
|
||||||
child: GestureDetector(
|
child: Container(
|
||||||
onTap: () {
|
height: 500,
|
||||||
// setState(() {
|
child: SendingWidget(
|
||||||
// index = 2;
|
startSendingTime: DateTime.now(),
|
||||||
// });
|
showTimeElapsed: false,
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
height: 500,
|
|
||||||
child: SendingWidget(
|
|
||||||
startSendingTime: DateTime.now(),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SDUIPreviewPage(
|
SDUIPreviewPage(
|
||||||
onNext: () {},
|
key: ValueKey(generatedSDUI.hashCode),
|
||||||
|
onModificationRequestMade: modifySDUICode,
|
||||||
sduiCode: generatedSDUI,
|
sduiCode: generatedSDUI,
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
@@ -248,9 +264,12 @@ class _FrameWorkSelectorPageState extends State<FrameWorkSelectorPage> {
|
|||||||
|
|
||||||
class SDUIPreviewPage extends ConsumerStatefulWidget {
|
class SDUIPreviewPage extends ConsumerStatefulWidget {
|
||||||
final String sduiCode;
|
final String sduiCode;
|
||||||
final Function() onNext;
|
final Function(String) onModificationRequestMade;
|
||||||
const SDUIPreviewPage(
|
const SDUIPreviewPage({
|
||||||
{super.key, required this.onNext, required this.sduiCode});
|
super.key,
|
||||||
|
required this.onModificationRequestMade,
|
||||||
|
required this.sduiCode,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
ConsumerState<SDUIPreviewPage> createState() => _SDUIPreviewPageState();
|
ConsumerState<SDUIPreviewPage> createState() => _SDUIPreviewPageState();
|
||||||
@@ -258,6 +277,7 @@ class SDUIPreviewPage extends ConsumerStatefulWidget {
|
|||||||
|
|
||||||
class _SDUIPreviewPageState extends ConsumerState<SDUIPreviewPage> {
|
class _SDUIPreviewPageState extends ConsumerState<SDUIPreviewPage> {
|
||||||
bool exportingCode = false;
|
bool exportingCode = false;
|
||||||
|
String modificationRequest = "";
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -303,6 +323,11 @@ class _SDUIPreviewPageState extends ConsumerState<SDUIPreviewPage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: TextField(
|
child: TextField(
|
||||||
|
onChanged: (z) {
|
||||||
|
setState(() {
|
||||||
|
modificationRequest = z;
|
||||||
|
});
|
||||||
|
},
|
||||||
maxLines: 3, // Makes the text box taller
|
maxLines: 3, // Makes the text box taller
|
||||||
style: TextStyle(color: Colors.white), // White text
|
style: TextStyle(color: Colors.white), // White text
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
@@ -370,7 +395,9 @@ class _SDUIPreviewPageState extends ConsumerState<SDUIPreviewPage> {
|
|||||||
minimumSize: const Size(44, 44),
|
minimumSize: const Size(44, 44),
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
widget.onNext();
|
if (modificationRequest.isNotEmpty) {
|
||||||
|
widget.onModificationRequestMade(modificationRequest);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
Icons.generating_tokens,
|
Icons.generating_tokens,
|
||||||
|
|||||||
@@ -7,9 +7,11 @@ import 'package:apidash/consts.dart';
|
|||||||
|
|
||||||
class SendingWidget extends StatefulWidget {
|
class SendingWidget extends StatefulWidget {
|
||||||
final DateTime? startSendingTime;
|
final DateTime? startSendingTime;
|
||||||
|
final bool showTimeElapsed;
|
||||||
const SendingWidget({
|
const SendingWidget({
|
||||||
super.key,
|
super.key,
|
||||||
required this.startSendingTime,
|
required this.startSendingTime,
|
||||||
|
this.showTimeElapsed = true,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -51,33 +53,34 @@ class _SendingWidgetState extends State<SendingWidget> {
|
|||||||
Center(
|
Center(
|
||||||
child: Lottie.asset(kAssetSendingLottie),
|
child: Lottie.asset(kAssetSendingLottie),
|
||||||
),
|
),
|
||||||
Padding(
|
if (widget.showTimeElapsed)
|
||||||
padding: kPh20t40,
|
Padding(
|
||||||
child: Visibility(
|
padding: kPh20t40,
|
||||||
visible: _millisecondsElapsed >= 0,
|
child: Visibility(
|
||||||
child: Row(
|
visible: _millisecondsElapsed >= 0,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
child: Row(
|
||||||
children: [
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
Icon(
|
children: [
|
||||||
Icons.alarm,
|
Icon(
|
||||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
Icons.alarm,
|
||||||
),
|
|
||||||
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,
|
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