add active flow page

This commit is contained in:
JMARyA 2024-09-23 11:43:34 +02:00
parent 37757ee445
commit f4d81bc5ff
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263

View file

@ -36,6 +36,31 @@ class _FlowsPageState extends State<FlowsPage> {
);
}
Widget listFlowInfoByActive(
BuildContext context, Map<String, API.FlowInfo> infos) {
return FutureBuilder(future: () async {
var included = [];
for (var key in infos.keys) {
var active = await API.API().getActiveFlowsOf(key);
if (active.isNotEmpty) {
included.add(infos[key]);
}
}
return included;
}(), builder: (context, snapshot) {
if (!snapshot.hasData) {
return const CircularProgressIndicator();
}
var included = snapshot.data!;
return ListView(
children: included.map((x) => flowTile(context, x)).toList());
});
}
Widget listAllFlowInfos(
BuildContext context, Map<String, API.FlowInfo> infos) {
return ListView(
@ -101,8 +126,6 @@ class _FlowsPageState extends State<FlowsPage> {
@override
Widget build(BuildContext context) {
// todo : list currently active
if (flowInfos == null) {
return const CircularProgressIndicator();
}
@ -111,7 +134,12 @@ class _FlowsPageState extends State<FlowsPage> {
appBar: AppBar(
title: const Text("Flows"),
bottom: TabBar(
tabs: const [Text("All"), Text("Produces"), Text("Depends")],
tabs: const [
Text("All"),
Text("Produces"),
Text("Depends"),
Text("Active")
],
onTap: (value) {
setState(() {
tabSelection = value;
@ -122,6 +150,7 @@ class _FlowsPageState extends State<FlowsPage> {
0 => listAllFlowInfos(context, flowInfos!),
1 => listFlowInfoByProduced(context, flowInfos!),
2 => listFlowInfoByDependant(context, flowInfos!),
3 => listFlowInfoByActive(context, flowInfos!),
_ => const Text("..."),
});
}