diff options
| author | xengineering <me@xengineering.eu> | 2026-03-07 13:03:24 +0100 |
|---|---|---|
| committer | xengineering <me@xengineering.eu> | 2026-03-07 13:03:24 +0100 |
| commit | 2e15dd323b7c3198e2af10f35f1186d91cc6cfaf (patch) | |
| tree | cd632240cb4313db5a304f6493ffc08c9cc269c7 /lib/ui.dart | |
| parent | a46cb6e94688a65a31248bc4585bccfbc22242f0 (diff) | |
| download | sia-app-2e15dd323b7c3198e2af10f35f1186d91cc6cfaf.tar sia-app-2e15dd323b7c3198e2af10f35f1186d91cc6cfaf.tar.zst sia-app-2e15dd323b7c3198e2af10f35f1186d91cc6cfaf.zip | |
Label button with '(dis)connect'
This does not yet work but the correct text based on the page is
displayed.
This is based on a state machine based implementation suitable to
implement the state handling cleanly.
Diffstat (limited to 'lib/ui.dart')
| -rw-r--r-- | lib/ui.dart | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/ui.dart b/lib/ui.dart index 73e532a..e14895b 100644 --- a/lib/ui.dart +++ b/lib/ui.dart @@ -13,7 +13,7 @@ class Sia extends StatelessWidget { child: MaterialApp( home: Consumer<AppState>( builder: (_, AppState provider, _) { - if (provider.onConnectionPage) { + if (provider.state == MachineState.init) { return const ConnectionPage(); } return const DevicesPage(); @@ -112,6 +112,13 @@ class ConnectionStatus extends StatelessWidget { text = const Text('Disconnected'); } + MachineEvent event = MachineEvent.disconnect; + String action = 'disconnect'; + if (state.state == MachineState.init) { + event = MachineEvent.connect; + action = 'connect'; + } + return Row( children: <Widget>[ Expanded( @@ -119,8 +126,10 @@ class ConnectionStatus extends StatelessWidget { leading: icon, title: text, trailing: ElevatedButton( - onPressed: state.togglePage, - child: const Text('switch view'), + onPressed: () { + state.process(event); + }, + child: Text(action), ), ), ), |
