adding connection display

This commit is contained in:
YamiDoesDev 2023-01-14 23:30:09 +01:00
parent 449c0c73c7
commit 6db819211d
1 changed files with 8 additions and 3 deletions

View File

@ -28,6 +28,11 @@ class BluetoothDeviceSettingsState extends State<BluetoothDeviceSettings> {
backgroundColor: const Color(0xFFFDE100), // Text Color (Foreground color) backgroundColor: const Color(0xFFFDE100), // Text Color (Foreground color)
); );
ButtonStyle buttonStyleDisabled = ElevatedButton.styleFrom(
foregroundColor: Colors.black,
backgroundColor: const Color(0xFF737373), // Text Color (Foreground color)
);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@ -51,7 +56,7 @@ class BluetoothDeviceSettingsState extends State<BluetoothDeviceSettings> {
ListTile( ListTile(
title: const Text("Device Connection State"), title: const Text("Device Connection State"),
subtitle: Text( subtitle: Text(
_bluetoothObject.isConnected ? "ConnectionState.DISCONNECTED" : "ConnectionState.CONNECTED"), _bluetoothObject.isConnected ? "ConnectionState.CONNECTED" : "ConnectionState.DISCONNECTED"),
), ),
], ],
), ),
@ -66,7 +71,7 @@ class BluetoothDeviceSettingsState extends State<BluetoothDeviceSettings> {
await _bluetoothObject.connectDevice(); await _bluetoothObject.connectDevice();
} }
}, },
style: buttonStyle, style: _bluetoothObject.isConnected ? buttonStyleDisabled : buttonStyle,
child: const Text("Connect"), child: const Text("Connect"),
)), )),
const SizedBox(width: 16.0), const SizedBox(width: 16.0),
@ -77,7 +82,7 @@ class BluetoothDeviceSettingsState extends State<BluetoothDeviceSettings> {
await _bluetoothObject.disconnectDevice(); await _bluetoothObject.disconnectDevice();
} }
}, },
style: buttonStyle, style: _bluetoothObject.isConnected ? buttonStyle : buttonStyleDisabled,
child: const Text("Disconnect"), child: const Text("Disconnect"),
)) ))
])), ])),