37 lines
1.2 KiB
Dart
37 lines
1.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:sense_the_rhythm/utils/esense_input.dart';
|
|
import 'package:sense_the_rhythm/widgets/esense_connect_dialog.dart';
|
|
|
|
class ConnectionStatusButton extends StatelessWidget {
|
|
final String deviceStatus;
|
|
const ConnectionStatusButton(
|
|
this.deviceStatus, {
|
|
super.key,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return FilledButton.icon(
|
|
style: ButtonStyle(
|
|
backgroundColor: WidgetStateProperty.all(
|
|
ESenseInput.instance.connected ? Colors.green : Colors.grey),
|
|
padding:
|
|
WidgetStateProperty.all(EdgeInsets.symmetric(horizontal: 8.0))),
|
|
onPressed: () => showDialog(
|
|
context: context,
|
|
builder: (BuildContext context) {
|
|
return ESenseConnectDialog(
|
|
deviceStatus: ESenseInput.instance.deviceStatus,
|
|
connect: (String name) {
|
|
ESenseInput.instance.connectToESense(name);
|
|
});
|
|
},
|
|
),
|
|
label: Text(deviceStatus),
|
|
iconAlignment: IconAlignment.end,
|
|
icon: Icon(ESenseInput.instance.connected
|
|
? Icons.bluetooth_connected
|
|
: Icons.bluetooth));
|
|
}
|
|
}
|