diff --git a/lib/pages/flow.dart b/lib/pages/flow.dart index 67d0cfb..4e93535 100644 --- a/lib/pages/flow.dart +++ b/lib/pages/flow.dart @@ -235,13 +235,16 @@ class _FlowInfoPageState extends State { class CreateFlowPage extends StatelessWidget { final API.FlowInfo info; final Function refresh; - Map> depends = {}; + List depends = []; CreateFlowPage(this.info, this.refresh, {super.key}); void _create(BuildContext context) { // todo : input handling - API.API().startFlow(info.id, input: []).then((flowID) { + API + .API() + .startFlow(info.id, input: depends.map((x) => x.uuid).toList()) + .then((flowID) { refresh(); API.API().getFlow(flowID).then((flow) { Navigator.of(context).pushReplacement( @@ -257,21 +260,45 @@ class CreateFlowPage extends StatelessWidget { Navigator.of(context).push(MaterialPageRoute( builder: (context) { return TransactionSelectPage(transactions, onSelect: (t) { - depends.putIfAbsent(itemVariant, () { - return []; - }); - depends[itemVariant]!.add(t); - }, exclude: depends[itemVariant] ?? []); + if (!depends.contains(t)) { + depends.add(t); + } + }, exclude: depends); }, )); }); } + Widget buildInputSelection(BuildContext context) { + return Column( + children: info.depends.map((x) { + return ElevatedButton( + onPressed: () { + selectDependItems(context, x); + }, + child: Text("Add $x")); + }).toList()); + } + @override Widget build(BuildContext context) { - // todo : able to add transactions from depends return Scaffold( - body: null, + appBar: AppBar(title: Text("Create new ${info.name} Flow")), + body: Column( + children: [ + buildInputSelection(context), + const Divider(), + Card( + child: Column( + children: depends + .map((x) => TransactionCard(x, () {}, + onTap: (x) {}, onLongPress: (x) {})) + .toList())), + ElevatedButton( + onPressed: () => _create(context), + child: const Text("Create Flow")) + ], + ), ); } }