cdb_ui/lib/pages/flow/end_flow_page.dart
2024-09-25 10:49:21 +02:00

59 lines
1.4 KiB
Dart

import 'package:cdb_ui/api.dart' as API;
import 'package:cdb_ui/api.dart';
import 'package:cdb_ui/pages/transaction.dart';
import 'package:flutter/material.dart';
class EndFlowWithProduce extends StatefulWidget {
final API.Flow flow;
final API.FlowInfo info;
const EndFlowWithProduce(this.flow, this.info, {super.key});
@override
State<EndFlowWithProduce> createState() => _EndFlowWithProduceState();
}
class _EndFlowWithProduceState extends State<EndFlowWithProduce> {
Map<String, int> produces = {};
List<Widget> addProduceButtons() {
List<Widget> ret = [];
for (var i in widget.info.produces!) {
ret.add(ElevatedButton(
onPressed: () {
// todo : implement adding
},
child: Text("Produced $i")));
}
return ret;
}
_endFlow() {
API.API().endFlow(widget.flow.id, produced: produces).then((x) {
Navigator.of(context).pop();
});
}
@override
Widget build(BuildContext context) {
// todo : show end screen with produce
return Scaffold(
appBar: AppBar(
title: Text("End ${widget.info.name} Flow"),
),
body: Column(
children: [
...addProduceButtons(),
const Divider(),
// todo : add produced list
const SizedBox(
height: 10,
),
ElevatedButton(onPressed: _endFlow, child: const Text("End Flow"))
],
),
);
}
}