diff --git a/lib/pages/workflow.dart b/lib/pages/workflow.dart index 5a8f04f..be0f6f1 100644 --- a/lib/pages/workflow.dart +++ b/lib/pages/workflow.dart @@ -87,15 +87,15 @@ final WorflowService _service = WorflowService(); if (objAbs.topic == "compute" ) { var compute = objAbs as ComputeItem; if (compute.technology == 0) { - return Icon(FontAwesomeIcons.docker, size: 18); + return Icon(FontAwesomeIcons.docker, size: 16); } else if (compute.technology == 1) { - return Icon(FontAwesomeIcons.lifeRing, size: 18); + return Icon(FontAwesomeIcons.lifeRing, size: 16); } else if (compute.technology == 2) { - return Icon(FontAwesomeIcons.cubes, size: 18); + return Icon(FontAwesomeIcons.cubes, size: 16); } else if (compute.technology == 3) { - return Icon(FontAwesomeIcons.hardDrive, size: 18); + return Icon(FontAwesomeIcons.hardDrive, size: 16); } else if (compute.technology == 4) { - return Icon(FontAwesomeIcons.v, size: 18); + return Icon(FontAwesomeIcons.v, size: 16); } } return null; @@ -105,15 +105,15 @@ final WorflowService _service = WorflowService(); var objAbs = obj as AbstractItem?; if (objAbs == null) { return null; } if (objAbs.topic == "processing" ) { - return Icon(FontAwesomeIcons.gear) ; + return Icon(FontAwesomeIcons.gear, size: 16); } else if (objAbs.topic == "data" ) { - return Icon(FontAwesomeIcons.file); + return Icon(FontAwesomeIcons.file, size: 16); } else if (objAbs.topic == "storage" ) { - return Icon(FontAwesomeIcons.database); + return Icon(FontAwesomeIcons.database, size: 16); } else if (objAbs.topic == "compute" ) { - return Icon(FontAwesomeIcons.microchip); + return Icon(FontAwesomeIcons.microchip, size: 16); } else if (objAbs.topic == "workflows" ) { - return Icon(FontAwesomeIcons.diagramProject); + return Icon(FontAwesomeIcons.diagramProject, size: 16); } return null; } @@ -290,6 +290,32 @@ final WorflowService _service = WorflowService(); dash.infoItemWidget = getForms; dash.infoWidget = getDashInfoForms; dash.widthOffset = 50; + dash.arrowStyleRules = [ + (dash) { + for (var arrow in dash.arrows) { + var from = dash.elements.firstWhere((element) => arrow.fromID.contains(element.id)).element; + var to = dash.elements.firstWhere((element) => arrow.toID.contains(element.id)).element; + if ((from is ProcessingItem && to is ComputeItem) || (to is ProcessingItem && from is ComputeItem)) { + arrow.params.color = Colors.orange; + arrow.params.dashSpace = 2; + arrow.params.dashWidth = 2; + } else if ((from is ProcessingItem && to is StorageItem) || (to is ProcessingItem && from is StorageItem)) { + arrow.params.color = redColor; + arrow.params.dashSpace = 2; + arrow.params.dashWidth = 2; + } else if ((from is ProcessingItem && to is DataItem) || (to is ProcessingItem && from is DataItem)) { + arrow.params.color = Colors.blue; + arrow.params.dashSpace = 2; + arrow.params.dashWidth = 2; + } else { + arrow.params.color = Colors.black; + arrow.params.dashSpace = 0; + arrow.params.dashWidth = 0; + } + } + return dash.arrows; + } + ]; dash.saveRules = [ (dash) { dash.error = null; diff --git a/lib/widgets/forms/scheduler_forms.dart b/lib/widgets/forms/scheduler_forms.dart index 668a963..8f69bd1 100644 --- a/lib/widgets/forms/scheduler_forms.dart +++ b/lib/widgets/forms/scheduler_forms.dart @@ -115,10 +115,10 @@ class SchedulerFormsWidgetState extends State { if (end.isBefore(DateTime.now())) { // get difference between now and start delayed = end.difference(DateTime.now()); + Future.delayed(delayed, () { + WorkflowFactory.key.currentState?.setState(() { }); + }); } - Future.delayed(delayed, () { - WorkflowFactory.key.currentState?.setState(() { }); - }); } List> formKeys = [GlobalKey(), GlobalKey(), GlobalKey(), GlobalKey()]; var shallow = ShallowTextInputWidget( diff --git a/library/flutter_flow_chart/lib/src/dashboard.dart b/library/flutter_flow_chart/lib/src/dashboard.dart index b01edab..5279fb4 100755 --- a/library/flutter_flow_chart/lib/src/dashboard.dart +++ b/library/flutter_flow_chart/lib/src/dashboard.dart @@ -61,6 +61,7 @@ class Dashboard extends ChangeNotifier { double widthOffset = 0; double heightOffset = 0; List saveRules = []; + List Function(Dashboard)> arrowStyleRules = []; String? error; @@ -152,7 +153,9 @@ class Dashboard extends ChangeNotifier { map['dashboardSizeWidth'] as double? ?? 0, map['dashboardSizeHeight'] as double? ?? 0, ); - + for (var f in d.arrowStyleRules) { + d.arrows = f(d); + } if (map['gridBackgroundParams'] != null) { d.gridBackgroundParams = GridBackgroundParams.fromMap( map['gridBackgroundParams'] as Map, @@ -179,6 +182,9 @@ class Dashboard extends ChangeNotifier { (x) => ArrowPainter.fromMap(x as Map), ), ); + for (var f in arrowStyleRules) { + arrows = f(this); + } elements = List.from( (map['elements'] as List).map( (x) => FlowElement.fromMap(this, x as Map), @@ -244,6 +250,9 @@ class Dashboard extends ChangeNotifier { for(var el in elements) { graph['elements'][el.id] = el.serialize(); } + for (var f in arrowStyleRules) { + arrows = f(this); + } graph['arrows'] = arrows.map((e) => e.serialize()).toList(); d["id"]=id; d["name"]=name; @@ -322,12 +331,18 @@ class Dashboard extends ChangeNotifier { void addArrows(ArrowPainter f) { arrows.add(f); + for (var f in arrowStyleRules) { + arrows = f(this); + } addChange = true; saveDash(id); } void removeArrows(bool Function(ArrowPainter) f) { arrows.removeWhere((element) => f(element)); + for (var f in arrowStyleRules) { + arrows = f(this); + } saveDash(id); } diff --git a/library/flutter_flow_chart/lib/src/ui/draw_arrow.dart b/library/flutter_flow_chart/lib/src/ui/draw_arrow.dart index 33a3410..22aea97 100755 --- a/library/flutter_flow_chart/lib/src/ui/draw_arrow.dart +++ b/library/flutter_flow_chart/lib/src/ui/draw_arrow.dart @@ -352,7 +352,7 @@ class DrawArrowState extends State { if ( widget.flow.widget.dashboard.arrows.where( (element) => element.fromID == "${widget.srcElement.id}_${widget.index}").isEmpty) { widget.flow.widget.dashboard.addArrows(painter); - widget.flow.widget.dashboard.save!(widget.flow.widget.dashboard.id); + widget.flow.widget.dashboard.saveDash(widget.flow.widget.dashboard.id); } else { var i = widget.flow.widget.dashboard.arrows.indexWhere( (element) => element.fromID == "${widget.srcElement.id}_${widget.index}");