intermediate

This commit is contained in:
mr
2024-08-08 08:42:32 +02:00
parent 593f03648b
commit ceeebfc964
74 changed files with 3784 additions and 634 deletions

View File

@@ -1,5 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_flow_chart/flutter_flow_chart.dart';
import 'package:oc_front/core/models/workspace_local.dart';
import 'package:oc_front/core/services/router.dart';
import 'package:oc_front/core/services/specialized_services/abstract_service.dart';
import 'package:oc_front/models/abstract.dart';
import 'package:oc_front/models/response.dart';
@@ -24,24 +26,47 @@ class NewBoxWidgetState<T extends SerializerDeserializer<dynamic>> extends State
widget._ctrl.value = TextEditingValue(text: widget.dash.defaultName);
return Container(
color: Colors.white,
padding: const EdgeInsets.all(20),
padding: const EdgeInsets.only( top: 0, bottom: 20, left: 20, right: 20),
child: Column(
children: [
Row(
Container(
alignment: Alignment.centerRight,
height: 50,
child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [
Padding(padding: const EdgeInsets.symmetric(horizontal: 10), child:
Text("load or create a new workflow", style: const TextStyle(color: Colors.grey, fontSize: 15)
)),
Padding ( padding: const EdgeInsets.symmetric(horizontal: 10), child:
Tooltip( message: "back", child: InkWell(
mouseCursor: SystemMouseCursors.click,
onTap: () {
AppRouter.catalog.go(context, {});
},
child: const Icon(Icons.arrow_back, color: Colors.black))),
),
widget.dash.isOpened ? Row ( mainAxisAlignment: MainAxisAlignment.end, children: [
Tooltip( message: "close", child: InkWell(
mouseCursor: SystemMouseCursors.click,
onTap: () { Navigator.pop(context); },
child: const Icon(Icons.close, color: Colors.black))),
]) : Container(),
],),
),
FutureBuilder<APIResponse<RawData>>(
future: (widget.service as AbstractService<T>).all(context),
builder: (context, snapshot) {
List<DropdownMenuItem> items = widget.getItems != null ? widget.getItems!(snapshot.data) : [];
if (widget._selected != null
&& !items.where((element) => element.value == widget._selected).isNotEmpty) {
items.add(DropdownMenuItem<String>(
value: widget._selected.toString(),
child: Text(widget._selected.toString()),
));
}
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children : [
FutureBuilder<APIResponse<T>>(
future: (widget.service as AbstractService<T>).all(context),
builder: (context, snapshot) {
List<DropdownMenuItem> items = widget.getItems != null ? widget.getItems!(snapshot.data) : [];
if (widget._selected != null
&& !items.where((element) => element.value == widget._selected).isNotEmpty) {
items.add(DropdownMenuItem<String>(
value: widget._selected.toString(),
child: Text(widget._selected.toString()),
));
}
return SizedBox( width: MediaQuery.of(context).size.width <= 540 ? MediaQuery.of(context).size.width - 140 : 400, height: 50,
SizedBox( width: MediaQuery.of(context).size.width <= 540 ? MediaQuery.of(context).size.width - 140 : 400, height: 50,
child: DropdownButtonFormField(
value: widget._selected,
isExpanded: true,
@@ -59,12 +84,12 @@ class NewBoxWidgetState<T extends SerializerDeserializer<dynamic>> extends State
border: OutlineInputBorder( borderRadius: BorderRadius.zero,
borderSide: BorderSide(color: Colors.grey.shade300, width: 0)),
),
items: items, onChanged: (value) {
items: items,
onChanged: (value) {
setState(() {
widget._selected = value.toString();
});
}));
}),
})),
Tooltip(
message: 'empty selection',
child: InkWell(
@@ -86,9 +111,13 @@ class NewBoxWidgetState<T extends SerializerDeserializer<dynamic>> extends State
child: InkWell(
mouseCursor: widget._selected == null || widget._selected!.isEmpty
? MouseCursor.defer : SystemMouseCursors.click,
onTap: () {
onTap: () async {
if (widget._selected == null || widget._selected!.isEmpty) { return; }
widget.dash.name = widget._selected ?? widget.dash.name;
if (widget._selected != null && widget.dash.load != null) {
await widget.dash.load!(widget._selected ?? "");
WorkspaceLocal.init(context, true);
}
widget.dash.isOpened = true;
widget.dash.notifyListeners();
Navigator.pop(context);
},
@@ -100,7 +129,8 @@ class NewBoxWidgetState<T extends SerializerDeserializer<dynamic>> extends State
)
)
)
]),
]);}),
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
@@ -115,7 +145,7 @@ class NewBoxWidgetState<T extends SerializerDeserializer<dynamic>> extends State
minLines: null,
cursorColor: const Color.fromARGB(38, 166, 154, 1),
controller: widget._ctrl,
onChanged: (value) => setState(() { widget._ctrl.value = TextEditingValue(text: value); }),
onChanged: (value) {},
validator: (value) => value == null || value.isEmpty ? "name is required" : null,
decoration: InputDecoration(
hintText: "name a new workflow...",
@@ -137,13 +167,19 @@ class NewBoxWidgetState<T extends SerializerDeserializer<dynamic>> extends State
mouseCursor: widget._ctrl.value.text.isEmpty ? MouseCursor.defer : SystemMouseCursors.click,
onTap: () async {
if (widget._ctrl.value.text.isNotEmpty) {
await widget.service.post(context, {}, { "workflowName" : widget._ctrl.value.text });
widget._selected = widget._ctrl.value.text;
widget._ctrl.value = const TextEditingValue(text: "");
widget.dash.name = widget._selected ?? widget.dash.name;
widget.dash.notifyListeners();
// ignore: use_build_context_synchronously
Navigator.pop(context);
await widget.service.post(context, { "name" : widget._ctrl.value.text }, {}).then(
(value) {
widget._selected = widget._ctrl.value.text;
widget._ctrl.value = const TextEditingValue(text: "");
widget.dash.id = value.data?.serialize()["id"];
widget.dash.name = widget._selected ?? "";
widget.dash.notifyListeners();
WorkspaceLocal.init(context, true);
widget.dash.isOpened = true;
// ignore: use_build_context_synchronously
Navigator.pop(context);
}
);
}
},
child: Container(