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 {
|
||||
final API.FlowInfo info;
|
||||
final Function refresh;
|
||||
Map<String, List<API.Transaction>> depends = {};
|
||||
List<API.Transaction> 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"))
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue