sync api + ui refactor
This commit is contained in:
parent
a608c50447
commit
2f24e02696
12 changed files with 198 additions and 227 deletions
|
@ -67,17 +67,16 @@ class _ActiveFlowPageState extends State<ActiveFlowPage> {
|
|||
if (widget.info.next != null)
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
API.API().getFlowInfo(widget.info.next!).then((newInfo) {
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return CreateFlowPage(
|
||||
newInfo,
|
||||
() {},
|
||||
previousFlow: widget.flow,
|
||||
);
|
||||
},
|
||||
));
|
||||
});
|
||||
var newInfo = API.API().getFlowInfo(widget.info.next!);
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return CreateFlowPage(
|
||||
newInfo,
|
||||
() {},
|
||||
previousFlow: widget.flow,
|
||||
);
|
||||
},
|
||||
));
|
||||
},
|
||||
icon: const Icon(Icons.arrow_forward)),
|
||||
],
|
||||
|
|
|
@ -25,11 +25,10 @@ class _CreateFlowPageState extends State<CreateFlowPage> {
|
|||
input: depends.map((x) => x.uuid).toList())
|
||||
.then((x) {
|
||||
API.API().getFlow(x).then((flow) {
|
||||
API.API().getFlowInfo(flow.kind).then((info) {
|
||||
Navigator.of(context).pushReplacement(MaterialPageRoute(
|
||||
builder: (context) => ActiveFlowPage(flow, info),
|
||||
));
|
||||
});
|
||||
var info = API.API().getFlowInfo(flow.kind);
|
||||
Navigator.of(context).pushReplacement(MaterialPageRoute(
|
||||
builder: (context) => ActiveFlowPage(flow, info),
|
||||
));
|
||||
});
|
||||
});
|
||||
return;
|
||||
|
@ -73,11 +72,13 @@ class _CreateFlowPageState extends State<CreateFlowPage> {
|
|||
return [
|
||||
Column(
|
||||
children: widget.info.depends.map((x) {
|
||||
var (item, variant) = API.itemVariant(x);
|
||||
return ElevatedButton(
|
||||
onPressed: () {
|
||||
selectDependItems(context, x);
|
||||
},
|
||||
child: Text("Add $x"));
|
||||
child:
|
||||
Text("Add ${API.API().getItem(item).variants[variant]!.name}"));
|
||||
}).toList()),
|
||||
const Divider(),
|
||||
];
|
||||
|
@ -90,7 +91,7 @@ class _CreateFlowPageState extends State<CreateFlowPage> {
|
|||
Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(widget.previousFlow!.kind),
|
||||
child: Text(API.API().getFlowInfo(widget.previousFlow!.kind).name),
|
||||
),
|
||||
),
|
||||
Card(child: Icon(Icons.arrow_right)),
|
||||
|
|
|
@ -23,13 +23,7 @@ class _EndFlowWithProduceState extends State<EndFlowWithProduce> {
|
|||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
API.API().getLocations().then(
|
||||
(value) {
|
||||
setState(() {
|
||||
locations = value;
|
||||
});
|
||||
},
|
||||
);
|
||||
locations = API.API().getLocations();
|
||||
}
|
||||
|
||||
refresh() {
|
||||
|
@ -46,25 +40,24 @@ class _EndFlowWithProduceState extends State<EndFlowWithProduce> {
|
|||
List<Widget> ret = [];
|
||||
|
||||
for (var i in widget.info.produces!) {
|
||||
var (itemID, variant) = API.itemVariant(i);
|
||||
var item = API.API().getItem(itemID);
|
||||
ret.add(ElevatedButton(
|
||||
onPressed: () {
|
||||
var (itemID, variant) = API.itemVariant(i);
|
||||
API.API().getItem(itemID).then((item) {
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return SupplyPage(
|
||||
item,
|
||||
refresh,
|
||||
onlyVariants: [variant],
|
||||
forcePrice: "0.00",
|
||||
forceOrigin: "flow::${widget.flow.kind}::${widget.flow.id}",
|
||||
onCreate: addProduced,
|
||||
);
|
||||
},
|
||||
));
|
||||
});
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return SupplyPage(
|
||||
item,
|
||||
refresh,
|
||||
onlyVariants: [variant],
|
||||
forcePrice: "0.00",
|
||||
forceOrigin: "flow::${widget.flow.kind}::${widget.flow.id}",
|
||||
onCreate: addProduced,
|
||||
);
|
||||
},
|
||||
));
|
||||
},
|
||||
child: Text("Produced $i")));
|
||||
child: Text("Produced ${item.variants[variant]!.name}")));
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -24,13 +24,17 @@ class _FlowInfoPageState extends State<FlowInfoPage> {
|
|||
body: Column(
|
||||
children: [
|
||||
// todo : ui improve
|
||||
if (widget.info.next != null) Text("Next: ${widget.info.next}"),
|
||||
if (widget.info.next != null)
|
||||
Text("Next: ${API.API().getFlowInfo(widget.info.next!).name}"),
|
||||
if (widget.info.depends.isNotEmpty)
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
const Text("Flow can use: "),
|
||||
...widget.info.depends.map((x) => Text(x)).toList(),
|
||||
...widget.info.depends.map((x) {
|
||||
var (item, variant) = API.itemVariant(x);
|
||||
return Text(API.API().getItem(item).variants[variant]!.name);
|
||||
}).toList(),
|
||||
],
|
||||
),
|
||||
if (widget.info.produces?.isNotEmpty ?? false)
|
||||
|
@ -38,7 +42,10 @@ class _FlowInfoPageState extends State<FlowInfoPage> {
|
|||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
const Text("Flow can produce: "),
|
||||
...widget.info.produces!.map((x) => Text(x)).toList(),
|
||||
...widget.info.produces!.map((x) {
|
||||
var (item, variant) = API.itemVariant(x);
|
||||
return Text(API.API().getItem(item).variants[variant]!.name);
|
||||
}).toList(),
|
||||
],
|
||||
),
|
||||
const Divider(),
|
||||
|
|
|
@ -20,13 +20,7 @@ class _FlowsPageState extends State<FlowsPage> {
|
|||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
API.API().getFlows().then(
|
||||
(value) {
|
||||
setState(() {
|
||||
flowInfos = value;
|
||||
});
|
||||
},
|
||||
);
|
||||
flowInfos = API.API().getFlows();
|
||||
}
|
||||
|
||||
Widget flowTile(BuildContext context, API.FlowInfo x) {
|
||||
|
@ -94,7 +88,8 @@ class _FlowsPageState extends State<FlowsPage> {
|
|||
children: producedMapping[key]!.map((x) {
|
||||
return flowTile(context, x);
|
||||
}).toList());
|
||||
items.add(ExpandableListItem(body: flows, header: Text(key)));
|
||||
items.add(ExpandableListItem(
|
||||
body: flows, header: Text(API.API().getItem(key).name)));
|
||||
}
|
||||
|
||||
return ExpandableList(items);
|
||||
|
@ -122,7 +117,8 @@ class _FlowsPageState extends State<FlowsPage> {
|
|||
children: dependsMapping[key]!.map((x) {
|
||||
return flowTile(context, x);
|
||||
}).toList());
|
||||
items.add(ExpandableListItem(body: flows, header: Text(key)));
|
||||
items.add(ExpandableListItem(
|
||||
body: flows, header: Text(API.API().getItem(key).name)));
|
||||
}
|
||||
|
||||
return ExpandableList(items);
|
||||
|
@ -169,13 +165,12 @@ class _FlowsPageState extends State<FlowsPage> {
|
|||
code = code!.replaceFirst("Code scanned = ", "");
|
||||
|
||||
API.API().getFlow(code).then((flow) {
|
||||
API.API().getFlowInfo(flow.kind).then((info) {
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return ActiveFlowPage(flow, info);
|
||||
},
|
||||
));
|
||||
});
|
||||
var info = API.API().getFlowInfo(flow.kind);
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return ActiveFlowPage(flow, info);
|
||||
},
|
||||
));
|
||||
});
|
||||
},
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue