flows
This commit is contained in:
parent
c1906abc5b
commit
80895d4d71
3 changed files with 118 additions and 27 deletions
82
lib/pages/flow.dart
Normal file
82
lib/pages/flow.dart
Normal file
|
@ -0,0 +1,82 @@
|
|||
import 'package:cdb_ui/api.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class FlowsPage extends StatelessWidget {
|
||||
const FlowsPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// todo : flows by item produced
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text("Flows")),
|
||||
body: FutureBuilder(
|
||||
future: API().getFlows(),
|
||||
builder: (ctx, snap) {
|
||||
if (!snap.hasData) {
|
||||
return const CircularProgressIndicator();
|
||||
}
|
||||
|
||||
var data = snap.data!;
|
||||
|
||||
return ListView(
|
||||
children: data.values.map((x) {
|
||||
return ListTile(
|
||||
title: Text(x.name),
|
||||
onTap: () {
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (context) => FlowPage(x),
|
||||
));
|
||||
},
|
||||
);
|
||||
}).toList());
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
class FlowPage extends StatelessWidget {
|
||||
final FlowInfo info;
|
||||
|
||||
const FlowPage(this.info, {super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text(info.name)),
|
||||
body: Column(
|
||||
children: [
|
||||
// todo : ui improve
|
||||
if (info.next != null) Text("Next: ${info.next}"),
|
||||
if (info.depends.isNotEmpty)
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
const Text("Flow can use: "),
|
||||
...info.depends.map((x) => Text(x)).toList(),
|
||||
],
|
||||
),
|
||||
if (info.produces?.isNotEmpty ?? false)
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
const Text("Flow can produce: "),
|
||||
...info.produces!.map((x) => Text(x)).toList(),
|
||||
],
|
||||
),
|
||||
const Divider(),
|
||||
FutureBuilder(
|
||||
future: API().getActiveFlowsOf(info.id),
|
||||
builder: (context, snapshot) {
|
||||
if (!snapshot.hasData) {
|
||||
return const CircularProgressIndicator();
|
||||
}
|
||||
|
||||
var data = snapshot.data!;
|
||||
|
||||
return ListView(children: data.map((x) => Text(x.id)).toList());
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue