diff --git a/lib/pages/flow.dart b/lib/pages/flow.dart index a886e56..62ddb5b 100644 --- a/lib/pages/flow.dart +++ b/lib/pages/flow.dart @@ -36,6 +36,31 @@ class _FlowsPageState extends State { ); } + Widget listFlowInfoByActive( + BuildContext context, Map 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 infos) { return ListView( @@ -101,8 +126,6 @@ class _FlowsPageState extends State { @override Widget build(BuildContext context) { - // todo : list currently active - if (flowInfos == null) { return const CircularProgressIndicator(); } @@ -111,7 +134,12 @@ class _FlowsPageState extends State { 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 { 0 => listAllFlowInfos(context, flowInfos!), 1 => listFlowInfoByProduced(context, flowInfos!), 2 => listFlowInfoByDependant(context, flowInfos!), + 3 => listFlowInfoByActive(context, flowInfos!), _ => const Text("..."), }); }