From cd061eceeb421d6bec5cd38bf9f315036ce88887 Mon Sep 17 00:00:00 2001 From: Orangerot Date: Sat, 11 Jan 2025 18:22:32 +0100 Subject: style: refactored into folder structure --- lib/widgets/esense_connect_dialog.dart | 52 ++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 lib/widgets/esense_connect_dialog.dart (limited to 'lib/widgets/esense_connect_dialog.dart') diff --git a/lib/widgets/esense_connect_dialog.dart b/lib/widgets/esense_connect_dialog.dart new file mode 100644 index 0000000..b598174 --- /dev/null +++ b/lib/widgets/esense_connect_dialog.dart @@ -0,0 +1,52 @@ +import 'package:flutter/material.dart'; + +class ESenseConnectDialog extends StatefulWidget { + final void Function(String) connect; + final ValueNotifier deviceStatus; + const ESenseConnectDialog( + {super.key, required this.deviceStatus, required this.connect}); + + @override + State createState() => _ESenseConnectDialogState(); +} + +class _ESenseConnectDialogState extends State { + 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: [ + TextButton( + onPressed: () => Navigator.pop(context, 'Cancel'), + child: const Text('Discard'), + ), + TextButton( + onPressed: () => widget.connect(eSenseDeviceName), + child: const Text('Connect'), + ), + ], + ); + } +} -- cgit v1.2.3