flow update
This commit is contained in:
parent
080afe70ee
commit
6fb2d62a05
1 changed files with 36 additions and 9 deletions
|
@ -235,13 +235,16 @@ class _FlowInfoPageState extends State<FlowInfoPage> {
|
||||||
class CreateFlowPage extends StatelessWidget {
|
class CreateFlowPage extends StatelessWidget {
|
||||||
final API.FlowInfo info;
|
final API.FlowInfo info;
|
||||||
final Function refresh;
|
final Function refresh;
|
||||||
Map<String, List<API.Transaction>> depends = {};
|
List<API.Transaction> depends = [];
|
||||||
|
|
||||||
CreateFlowPage(this.info, this.refresh, {super.key});
|
CreateFlowPage(this.info, this.refresh, {super.key});
|
||||||
|
|
||||||
void _create(BuildContext context) {
|
void _create(BuildContext context) {
|
||||||
// todo : input handling
|
// 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();
|
refresh();
|
||||||
API.API().getFlow(flowID).then((flow) {
|
API.API().getFlow(flowID).then((flow) {
|
||||||
Navigator.of(context).pushReplacement(
|
Navigator.of(context).pushReplacement(
|
||||||
|
@ -257,21 +260,45 @@ class CreateFlowPage extends StatelessWidget {
|
||||||
Navigator.of(context).push(MaterialPageRoute(
|
Navigator.of(context).push(MaterialPageRoute(
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return TransactionSelectPage(transactions, onSelect: (t) {
|
return TransactionSelectPage(transactions, onSelect: (t) {
|
||||||
depends.putIfAbsent(itemVariant, () {
|
if (!depends.contains(t)) {
|
||||||
return [];
|
depends.add(t);
|
||||||
});
|
}
|
||||||
depends[itemVariant]!.add(t);
|
}, exclude: depends);
|
||||||
}, exclude: depends[itemVariant] ?? []);
|
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget buildInputSelection(BuildContext context) {
|
||||||
|
return Column(
|
||||||
|
children: info.depends.map((x) {
|
||||||
|
return ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
selectDependItems(context, x);
|
||||||
|
},
|
||||||
|
child: Text("Add $x"));
|
||||||
|
}).toList());
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// todo : able to add transactions from depends
|
|
||||||
return Scaffold(
|
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"))
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue