diff options
author | Orangerot <purple@orangerot.dev> | 2025-01-07 03:35:33 +0100 |
---|---|---|
committer | Orangerot <purple@orangerot.dev> | 2025-01-07 03:35:33 +0100 |
commit | 0178eb5ffcc6ba798ab5f30c055d4be35610c655 (patch) | |
tree | a1aadf7b34190941e7077e86c829e096fb11f5b4 /lib/esense_connect_dialog.dart | |
parent | 36e859d2fe431a27b388ac9d8a13ade921a375a7 (diff) |
style: refactored ESenseConnectDialog into own Widget
Diffstat (limited to 'lib/esense_connect_dialog.dart')
-rw-r--r-- | lib/esense_connect_dialog.dart | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/lib/esense_connect_dialog.dart b/lib/esense_connect_dialog.dart new file mode 100644 index 0000000..b598174 --- /dev/null +++ b/lib/esense_connect_dialog.dart @@ -0,0 +1,52 @@ +import 'package:flutter/material.dart'; + +class ESenseConnectDialog extends StatefulWidget { + final void Function(String) connect; + final ValueNotifier<String> deviceStatus; + const ESenseConnectDialog( + {super.key, required this.deviceStatus, required this.connect}); + + @override + State<ESenseConnectDialog> createState() => _ESenseConnectDialogState(); +} + +class _ESenseConnectDialogState extends State<ESenseConnectDialog> { + String eSenseDeviceName = ''; + + @override + Widget build(BuildContext context) { + return AlertDialog( + title: const Text('Connect to ESense'), + content: Column(mainAxisSize: MainAxisSize.min, children: [ + TextField( + onChanged: (input) { + setState(() { + eSenseDeviceName = input; + }); + }, + decoration: InputDecoration( + border: OutlineInputBorder(), + hintText: 'eSense-xxxx', + labelText: 'Device name', + ), + ), + // Text(eSenseDeviceName), + ValueListenableBuilder( + valueListenable: widget.deviceStatus, + builder: (BuildContext context, String value, Widget? child) { + return Text(value); + }), + ]), + actions: <Widget>[ + TextButton( + onPressed: () => Navigator.pop(context, 'Cancel'), + child: const Text('Discard'), + ), + TextButton( + onPressed: () => widget.connect(eSenseDeviceName), + child: const Text('Connect'), + ), + ], + ); + } +} |