diff options
| author | xengineering <me@xengineering.eu> | 2026-03-08 17:27:52 +0100 |
|---|---|---|
| committer | xengineering <me@xengineering.eu> | 2026-03-08 17:27:52 +0100 |
| commit | 4bc034c7ab627c50aba7e2ce4da360c14465c150 (patch) | |
| tree | b4e2c5d497ff94ae1d8a32dcb32b5c01a66c2dfa /lib/ui.dart | |
| parent | ef8877ccffe0ebcc8f9f1c0bb6db372fa0886c2a (diff) | |
| download | sia-app-4bc034c7ab627c50aba7e2ce4da360c14465c150.tar sia-app-4bc034c7ab627c50aba7e2ce4da360c14465c150.tar.zst sia-app-4bc034c7ab627c50aba7e2ce4da360c14465c150.zip | |
Switch completely to connection state machine
This makes use of the state machine in the UI and implements all states
and transitions planned so far.
Diffstat (limited to 'lib/ui.dart')
| -rw-r--r-- | lib/ui.dart | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/lib/ui.dart b/lib/ui.dart index e14895b..7a97f32 100644 --- a/lib/ui.dart +++ b/lib/ui.dart @@ -98,18 +98,22 @@ class ConnectionStatus extends StatelessWidget { return SafeArea( child: Consumer<AppState>( builder: (BuildContext context, AppState state, Widget? child) { - Icon icon; - Text text; + Icon icon = const Icon(Icons.cloud_off, color: Colors.grey); + Text text = const Text('Disconnected'); - if (state.brokerConnected && state.serverConnected) { - icon = const Icon(Icons.cloud, color: Colors.green); - text = const Text('Connected'); - } else if (state.brokerConnected && !state.serverConnected) { - icon = const Icon(Icons.cloud_off, color: Colors.orange); - text = const Text('Connection issue'); - } else { - icon = const Icon(Icons.cloud_off, color: Colors.red); - text = const Text('Disconnected'); + switch (state.state) { + case MachineState.init: + icon = const Icon(Icons.cloud_off, color: Colors.grey); + text = const Text('Off'); + case MachineState.disconnected: + icon = const Icon(Icons.cloud_off, color: Colors.red); + text = const Text('Disconnected'); + case MachineState.unreachable: + icon = const Icon(Icons.cloud_off, color: Colors.orange); + text = const Text('Unreachable'); + case MachineState.reachable: + icon = const Icon(Icons.cloud, color: Colors.green); + text = const Text('Connected'); } MachineEvent event = MachineEvent.disconnect; |
