diff --git a/lib/pages/flow.dart b/lib/pages/flow.dart index 4e93535..3425c71 100644 --- a/lib/pages/flow.dart +++ b/lib/pages/flow.dart @@ -232,20 +232,25 @@ class _FlowInfoPageState extends State { } } -class CreateFlowPage extends StatelessWidget { +class CreateFlowPage extends StatefulWidget { final API.FlowInfo info; final Function refresh; + + const CreateFlowPage(this.info, this.refresh, {super.key}); + + @override + State createState() => _CreateFlowPageState(); +} + +class _CreateFlowPageState extends State { List depends = []; - CreateFlowPage(this.info, this.refresh, {super.key}); - void _create(BuildContext context) { - // todo : input handling API .API() - .startFlow(info.id, input: depends.map((x) => x.uuid).toList()) + .startFlow(widget.info.id, input: depends.map((x) => x.uuid).toList()) .then((flowID) { - refresh(); + widget.refresh(); API.API().getFlow(flowID).then((flow) { Navigator.of(context).pushReplacement( MaterialPageRoute(builder: (context) => ActiveFlowPage(flow))); @@ -261,7 +266,9 @@ class CreateFlowPage extends StatelessWidget { builder: (context) { return TransactionSelectPage(transactions, onSelect: (t) { if (!depends.contains(t)) { - depends.add(t); + setState(() { + depends.add(t); + }); } }, exclude: depends); }, @@ -271,7 +278,7 @@ class CreateFlowPage extends StatelessWidget { Widget buildInputSelection(BuildContext context) { return Column( - children: info.depends.map((x) { + children: widget.info.depends.map((x) { return ElevatedButton( onPressed: () { selectDependItems(context, x); @@ -283,7 +290,7 @@ class CreateFlowPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: Text("Create new ${info.name} Flow")), + appBar: AppBar(title: Text("Create new ${widget.info.name} Flow")), body: Column( children: [ buildInputSelection(context), @@ -344,15 +351,24 @@ class TransactionSelectPage extends StatelessWidget { } class ActiveFlowPage extends StatelessWidget { - late API.Flow flow; + final API.Flow flow; - ActiveFlowPage(this.flow); + const ActiveFlowPage(this.flow, {super.key}); @override Widget build(BuildContext context) { return Scaffold( body: Column( - children: [], + children: [ + Text("ID: ${flow.id}"), + Text("Started since: ${tsFormat(flow.started)}"), + ...flow.input!.map((x) => Text("Input: $x")).toList(), + if (flow.done != null) ...[ + Text("Ended: ${tsFormat(flow.done!.ended)}"), + if (flow.done!.next != null) Text("Next: ${flow.done!.next!}"), + ...flow.done!.produced!.map((x) => Text("Produced: $x")).toList(), + ] + ], )); } }