Skip to content

Commit 9800282

Browse files
committed
Implemented STAC_MODIFIER to enabled UI Modifications
1 parent 5113e11 commit 9800282

File tree

2 files changed

+67
-39
lines changed

2 files changed

+67
-39
lines changed

lib/widgets/ai_ui_desginer_widgets.dart

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,25 @@ class _DialogContentsState extends ConsumerState<DialogContents> {
7777
return sduiCode['STAC'].toString();
7878
}
7979

80+
Future<void> modifySDUICode(String modificationRequest) async {
81+
setState(() {
82+
index = 1; //Induce Loading
83+
});
84+
final res = await APIDashAgentCaller.instance.stacModifer(
85+
ref,
86+
input: AgentInputs(variables: {
87+
'VAR_CODE': generatedSDUI,
88+
'VAR_CLIENT_REQUEST': modificationRequest,
89+
}),
90+
);
91+
92+
final SDUI = res['STAC'];
93+
setState(() {
94+
generatedSDUI = SDUI;
95+
index = 2;
96+
});
97+
}
98+
8099
@override
81100
Widget build(BuildContext context) {
82101
return IndexedStack(
@@ -98,24 +117,19 @@ class _DialogContentsState extends ConsumerState<DialogContents> {
98117
child: Center(
99118
child: Padding(
100119
padding: const EdgeInsets.only(top: 40.0),
101-
child: GestureDetector(
102-
onTap: () {
103-
// setState(() {
104-
// index = 2;
105-
// });
106-
},
107-
child: Container(
108-
height: 500,
109-
child: SendingWidget(
110-
startSendingTime: DateTime.now(),
111-
),
120+
child: Container(
121+
height: 500,
122+
child: SendingWidget(
123+
startSendingTime: DateTime.now(),
124+
showTimeElapsed: false,
112125
),
113126
),
114127
),
115128
),
116129
),
117130
SDUIPreviewPage(
118-
onNext: () {},
131+
key: ValueKey(generatedSDUI.hashCode),
132+
onModificationRequestMade: modifySDUICode,
119133
sduiCode: generatedSDUI,
120134
)
121135
],
@@ -241,16 +255,20 @@ class _FrameWorkSelectorPageState extends State<FrameWorkSelectorPage> {
241255

242256
class SDUIPreviewPage extends ConsumerStatefulWidget {
243257
final String sduiCode;
244-
final Function() onNext;
245-
const SDUIPreviewPage(
246-
{super.key, required this.onNext, required this.sduiCode});
258+
final Function(String) onModificationRequestMade;
259+
const SDUIPreviewPage({
260+
super.key,
261+
required this.onModificationRequestMade,
262+
required this.sduiCode,
263+
});
247264

248265
@override
249266
ConsumerState<SDUIPreviewPage> createState() => _SDUIPreviewPageState();
250267
}
251268

252269
class _SDUIPreviewPageState extends ConsumerState<SDUIPreviewPage> {
253270
bool exportingCode = false;
271+
String modificationRequest = "";
254272

255273
@override
256274
Widget build(BuildContext context) {
@@ -296,6 +314,11 @@ class _SDUIPreviewPageState extends ConsumerState<SDUIPreviewPage> {
296314
),
297315
),
298316
child: TextField(
317+
onChanged: (z) {
318+
setState(() {
319+
modificationRequest = z;
320+
});
321+
},
299322
maxLines: 3, // Makes the text box taller
300323
style: TextStyle(color: Colors.white), // White text
301324
decoration: InputDecoration(
@@ -364,7 +387,9 @@ class _SDUIPreviewPageState extends ConsumerState<SDUIPreviewPage> {
364387
minimumSize: const Size(44, 44),
365388
),
366389
onPressed: () {
367-
widget.onNext();
390+
if (modificationRequest.isNotEmpty) {
391+
widget.onModificationRequestMade(modificationRequest);
392+
}
368393
},
369394
icon: Icon(
370395
Icons.generating_tokens,

lib/widgets/widget_sending.dart

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ import 'package:apidash/consts.dart';
77

88
class SendingWidget extends StatefulWidget {
99
final DateTime? startSendingTime;
10+
final bool showTimeElapsed;
1011
const SendingWidget({
1112
super.key,
1213
required this.startSendingTime,
14+
this.showTimeElapsed = true,
1315
});
1416

1517
@override
@@ -51,33 +53,34 @@ class _SendingWidgetState extends State<SendingWidget> {
5153
Center(
5254
child: Lottie.asset(kAssetSendingLottie),
5355
),
54-
Padding(
55-
padding: kPh20t40,
56-
child: Visibility(
57-
visible: _millisecondsElapsed >= 0,
58-
child: Row(
59-
mainAxisAlignment: MainAxisAlignment.center,
60-
children: [
61-
Icon(
62-
Icons.alarm,
63-
color: Theme.of(context).colorScheme.onSurfaceVariant,
64-
),
65-
const SizedBox(
66-
width: 10,
67-
),
68-
Text(
69-
'Time elapsed: ${humanizeDuration(Duration(milliseconds: _millisecondsElapsed))}',
70-
textAlign: TextAlign.center,
71-
overflow: TextOverflow.fade,
72-
softWrap: false,
73-
style: kTextStyleButton.copyWith(
56+
if (widget.showTimeElapsed)
57+
Padding(
58+
padding: kPh20t40,
59+
child: Visibility(
60+
visible: _millisecondsElapsed >= 0,
61+
child: Row(
62+
mainAxisAlignment: MainAxisAlignment.center,
63+
children: [
64+
Icon(
65+
Icons.alarm,
7466
color: Theme.of(context).colorScheme.onSurfaceVariant,
7567
),
76-
),
77-
],
68+
const SizedBox(
69+
width: 10,
70+
),
71+
Text(
72+
'Time elapsed: ${humanizeDuration(Duration(milliseconds: _millisecondsElapsed))}',
73+
textAlign: TextAlign.center,
74+
overflow: TextOverflow.fade,
75+
softWrap: false,
76+
style: kTextStyleButton.copyWith(
77+
color: Theme.of(context).colorScheme.onSurfaceVariant,
78+
),
79+
),
80+
],
81+
),
7882
),
7983
),
80-
),
8184
],
8285
);
8386
}

0 commit comments

Comments
 (0)