From 6db819211d66c4437abf54fee00fe2e1531bd781 Mon Sep 17 00:00:00 2001 From: YamiDoesDev Date: Sat, 14 Jan 2023 23:30:09 +0100 Subject: [PATCH] adding connection display --- lib/screens/bluetooth_device_settings.dart | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/screens/bluetooth_device_settings.dart b/lib/screens/bluetooth_device_settings.dart index 2896357..d8d09db 100644 --- a/lib/screens/bluetooth_device_settings.dart +++ b/lib/screens/bluetooth_device_settings.dart @@ -28,6 +28,11 @@ class BluetoothDeviceSettingsState extends State { backgroundColor: const Color(0xFFFDE100), // Text Color (Foreground color) ); + ButtonStyle buttonStyleDisabled = ElevatedButton.styleFrom( + foregroundColor: Colors.black, + backgroundColor: const Color(0xFF737373), // Text Color (Foreground color) + ); + @override Widget build(BuildContext context) { return Scaffold( @@ -51,7 +56,7 @@ class BluetoothDeviceSettingsState extends State { ListTile( title: const Text("Device Connection State"), subtitle: Text( - _bluetoothObject.isConnected ? "ConnectionState.DISCONNECTED" : "ConnectionState.CONNECTED"), + _bluetoothObject.isConnected ? "ConnectionState.CONNECTED" : "ConnectionState.DISCONNECTED"), ), ], ), @@ -66,7 +71,7 @@ class BluetoothDeviceSettingsState extends State { await _bluetoothObject.connectDevice(); } }, - style: buttonStyle, + style: _bluetoothObject.isConnected ? buttonStyleDisabled : buttonStyle, child: const Text("Connect"), )), const SizedBox(width: 16.0), @@ -77,7 +82,7 @@ class BluetoothDeviceSettingsState extends State { await _bluetoothObject.disconnectDevice(); } }, - style: buttonStyle, + style: _bluetoothObject.isConnected ? buttonStyle : buttonStyleDisabled, child: const Text("Disconnect"), )) ])),