finishing touches for a working version
This commit is contained in:
parent
079bc1bdad
commit
f8a1c38540
|
@ -1,5 +1,5 @@
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.6.10'
|
ext.kotlin_version = '1.7.20'
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|
|
@ -17,7 +17,9 @@ class BluetoothDeviceEntry extends ListTile {
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
onLongPress: onLongPress,
|
onLongPress: onLongPress,
|
||||||
enabled: enabled,
|
enabled: enabled,
|
||||||
leading: Icon(bluetoothObject.isConnected ? Icons.bluetooth_connected : Icons.bluetooth),
|
leading: bluetoothObject.isConnected
|
||||||
|
? const Icon(Icons.bluetooth_connected, color: Colors.blue)
|
||||||
|
: const Icon(Icons.bluetooth),
|
||||||
title: Text(bluetoothObject.name),
|
title: Text(bluetoothObject.name),
|
||||||
subtitle: Text(bluetoothObject.address.toString()),
|
subtitle: Text(bluetoothObject.address.toString()),
|
||||||
trailing: Row(
|
trailing: Row(
|
||||||
|
|
|
@ -21,6 +21,7 @@ class BluetoothObject {
|
||||||
late BluetoothConnection? _connection;
|
late BluetoothConnection? _connection;
|
||||||
late Stream<Uint8List> _connectionStream;
|
late Stream<Uint8List> _connectionStream;
|
||||||
late StreamSubscription<Uint8List> _connectionStreamSubscription;
|
late StreamSubscription<Uint8List> _connectionStreamSubscription;
|
||||||
|
late BuildContext _context;
|
||||||
|
|
||||||
final CloudServiceAPI _cloudServiceAPI = CloudServiceAPI();
|
final CloudServiceAPI _cloudServiceAPI = CloudServiceAPI();
|
||||||
|
|
||||||
|
@ -69,7 +70,7 @@ class BluetoothObject {
|
||||||
_connection = null;
|
_connection = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> bondDevice() async {
|
Future<void> bondDevice(BuildContext context) async {
|
||||||
try {
|
try {
|
||||||
bool bonded = false;
|
bool bonded = false;
|
||||||
if (_device.isBonded) {
|
if (_device.isBonded) {
|
||||||
|
@ -81,22 +82,7 @@ class BluetoothObject {
|
||||||
bonded = (await FlutterBluetoothSerial.instance.bondDeviceAtAddress(_address))!;
|
bonded = (await FlutterBluetoothSerial.instance.bondDeviceAtAddress(_address))!;
|
||||||
debugPrint('Bonding with $_address has ${bonded ? 'succed' : 'failed'}.');
|
debugPrint('Bonding with $_address has ${bonded ? 'succed' : 'failed'}.');
|
||||||
}
|
}
|
||||||
/*setState(() {
|
|
||||||
_discoveryResults[_discoveryResults.indexOf(
|
|
||||||
result)] =
|
|
||||||
BluetoothDiscoveryResult(
|
|
||||||
device: BluetoothDevice(
|
|
||||||
name: device.name ?? '',
|
|
||||||
address: address,
|
|
||||||
type: device.type,
|
|
||||||
bondState: bonded
|
|
||||||
? BluetoothBondState.bonded
|
|
||||||
: BluetoothBondState.none,
|
|
||||||
),
|
|
||||||
rssi: result.rssi);
|
|
||||||
});*/
|
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
/*
|
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
|
@ -114,7 +100,7 @@ class BluetoothObject {
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);*/
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,12 +119,15 @@ class BluetoothObject {
|
||||||
_connection = null;
|
_connection = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
_connection = await BluetoothConnection.toAddress(_address);
|
try {
|
||||||
debugPrint("Connected to the device");
|
_connection = await BluetoothConnection.toAddress(_address);
|
||||||
|
debugPrint("Connected to the device");
|
||||||
_connectionStream = _connection!.input!;
|
_connectionStream = _connection!.input!;
|
||||||
_connectionStreamSubscription = _connectionStream.listen(_connectionOnListen);
|
_connectionStreamSubscription = _connectionStream.listen(_connectionOnListen);
|
||||||
_connectionStreamSubscription.onDone(_connectionOnDone);
|
_connectionStreamSubscription.onDone(_connectionOnDone);
|
||||||
|
} catch (ex) {
|
||||||
|
debugPrint("$ex");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _connectionOnDone() {
|
void _connectionOnDone() {
|
||||||
|
@ -151,111 +140,58 @@ class BluetoothObject {
|
||||||
|
|
||||||
Future<void> _connectionOnListen(Uint8List data) async {
|
Future<void> _connectionOnListen(Uint8List data) async {
|
||||||
final String dataDecoded = const AsciiDecoder().convert(data);
|
final String dataDecoded = const AsciiDecoder().convert(data);
|
||||||
|
|
||||||
debugPrint("received: $data");
|
|
||||||
debugPrint("received decoded: $dataDecoded");
|
debugPrint("received decoded: $dataDecoded");
|
||||||
|
|
||||||
_messageBufferChars += dataDecoded;
|
_messageBufferChars += dataDecoded;
|
||||||
|
|
||||||
if (data[data.length - 1] == 10) {
|
if (!(data[data.length - 1] == 10)) {
|
||||||
debugPrint("received buffer: $_messageBufferChars");
|
return;
|
||||||
int spaceIndex = _messageBufferChars.indexOf(" ");
|
}
|
||||||
String firstParameter = "";
|
if (!_messageBufferChars.contains(" ")) {
|
||||||
String secondParameter = "";
|
|
||||||
try {
|
|
||||||
firstParameter = _messageBufferChars.substring(0, spaceIndex);
|
|
||||||
secondParameter = _messageBufferChars.substring(spaceIndex + 1, _messageBufferChars.length - 2);
|
|
||||||
} catch (ex) {
|
|
||||||
debugPrint(ex.toString());
|
|
||||||
}
|
|
||||||
debugPrint("we still go on!");
|
|
||||||
_messageBufferChars = "";
|
_messageBufferChars = "";
|
||||||
debugPrint("first: $firstParameter");
|
return;
|
||||||
debugPrint("second: $secondParameter");
|
|
||||||
if (firstParameter == "fingerprint") {
|
|
||||||
debugPrint("received final buffer: $secondParameter");
|
|
||||||
_primaryThumbprint = secondParameter;
|
|
||||||
debugPrint("{ _secondaryThumbprint: $_secondaryThumbprint }");
|
|
||||||
debugPrint("{ id: $id, _primaryThumbprint: $_primaryThumbprint, _secondaryThumbprint: $_secondaryThumbprint }");
|
|
||||||
await _registerDevice();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
List<String> input = _messageBufferChars.split(" ");
|
||||||
// Allocate buffer for parsed data
|
if (input[0] == "fingerprint") {
|
||||||
int backspacesCounter = 0;
|
_primaryThumbprint = input[1].trim();
|
||||||
for (var byte in data) {
|
debugPrint("_primaryThumbprint: ${const AsciiEncoder().convert(_primaryThumbprint)}");
|
||||||
if (byte == 8 || byte == 127) {
|
debugPrint("id: ${const AsciiEncoder().convert(id)}");
|
||||||
backspacesCounter++;
|
debugPrint("_secondaryThumbprint: $_secondaryThumbprint");
|
||||||
}
|
await _registerDevice();
|
||||||
}
|
}
|
||||||
Uint8List buffer = Uint8List(data.length - backspacesCounter);
|
_messageBufferChars = "";
|
||||||
int bufferIndex = buffer.length;
|
|
||||||
|
|
||||||
// Apply backspace control character
|
|
||||||
backspacesCounter = 0;
|
|
||||||
for (int i = data.length - 1; i >= 0; i--) {
|
|
||||||
if (data[i] == 8 || data[i] == 127) {
|
|
||||||
backspacesCounter++;
|
|
||||||
} else {
|
|
||||||
if (backspacesCounter > 0) {
|
|
||||||
backspacesCounter--;
|
|
||||||
} else {
|
|
||||||
buffer[--bufferIndex] = data[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create message if there is new line character
|
|
||||||
String dataString = String.fromCharCodes(buffer);
|
|
||||||
int index = buffer.indexOf(13);
|
|
||||||
if (~index != 0) {
|
|
||||||
_messageBuffer = dataString.substring(index);
|
|
||||||
} else {
|
|
||||||
_messageBuffer = (backspacesCounter > 0
|
|
||||||
? _messageBuffer.substring(0, _messageBuffer.length - backspacesCounter)
|
|
||||||
: _messageBuffer + dataString);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> sendData(String output) async {
|
Future<void> sendData(BuildContext context, String output) async {
|
||||||
if (_connection == null) return;
|
if (_connection == null) return;
|
||||||
bool nameAvailable = await _cloudServiceAPI.checkNameAvailability(output);
|
bool nameAvailable = await _cloudServiceAPI.checkNameAvailability(output);
|
||||||
if (!nameAvailable) return;
|
if (!nameAvailable) return;
|
||||||
id = output;
|
id = output;
|
||||||
_connection!.output.add(Uint8List.fromList(const AsciiEncoder().convert("$output \r\n")));
|
_connection!.output.add(Uint8List.fromList(const AsciiEncoder().convert("$output \r\n")));
|
||||||
await _connection!.output.allSent;
|
await _connection!.output.allSent;
|
||||||
|
_context = context;
|
||||||
debugPrint("sent: $output");
|
debugPrint("sent: $output");
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _registerDevice() async {
|
Future<void> _registerDevice() async {
|
||||||
bool registered = false;
|
bool registered = false;
|
||||||
registered = await _cloudServiceAPI.createDevice(id, _primaryThumbprint, "");
|
registered = await _cloudServiceAPI.createDevice(id, _primaryThumbprint, "");
|
||||||
|
_confirmRegistration(registered);
|
||||||
|
}
|
||||||
|
|
||||||
String statusText =
|
void _confirmRegistration(bool registered) {
|
||||||
registered ? "das Gerät wurde erfolgreich registriert" : "das Gerät konnte nicht registriert werden";
|
showDialog<String>(
|
||||||
Fluttertoast.showToast(
|
context: _context,
|
||||||
msg: statusText,
|
builder: (BuildContext context) => AlertDialog(
|
||||||
toastLength: Toast.LENGTH_SHORT,
|
title: const Text('Device Info'),
|
||||||
gravity: ToastGravity.BOTTOM,
|
content: Text(registered ? "das Gerät wurde erfolgreich registriert" : "das Gerät konnte nicht registriert werden"),
|
||||||
timeInSecForIosWeb: 2,
|
backgroundColor: Colors.white,
|
||||||
backgroundColor: Colors.grey[200],
|
actions: <Widget>[
|
||||||
textColor: Colors.black,
|
TextButton(onPressed: () => Navigator.pop(context, 'Cancel'),
|
||||||
fontSize: 16.0);
|
child: const Text('OK'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*setState(() {
|
|
||||||
_discoveryResults[_discoveryResults.indexOf(
|
|
||||||
result)] =
|
|
||||||
BluetoothDiscoveryResult(
|
|
||||||
device: BluetoothDevice(
|
|
||||||
name: device.name ?? '',
|
|
||||||
address: address,
|
|
||||||
type: device.type,
|
|
||||||
isConnected: connected,
|
|
||||||
),
|
|
||||||
rssi: result.rssi);
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
|
|
|
@ -133,7 +133,7 @@ class CloudServiceAPI {
|
||||||
String statusText = status ? "die eingegebene ID ist verfügbar" : "die eingegebene ID ist nicht verfügbar";
|
String statusText = status ? "die eingegebene ID ist verfügbar" : "die eingegebene ID ist nicht verfügbar";
|
||||||
Fluttertoast.showToast(
|
Fluttertoast.showToast(
|
||||||
msg: statusText,
|
msg: statusText,
|
||||||
toastLength: Toast.LENGTH_SHORT,
|
toastLength: Toast.LENGTH_LONG,
|
||||||
gravity: ToastGravity.BOTTOM,
|
gravity: ToastGravity.BOTTOM,
|
||||||
timeInSecForIosWeb: 2,
|
timeInSecForIosWeb: 2,
|
||||||
backgroundColor: Colors.grey[200],
|
backgroundColor: Colors.grey[200],
|
||||||
|
|
|
@ -14,6 +14,7 @@ class BluetoothDeviceSettings extends StatefulWidget {
|
||||||
|
|
||||||
class BluetoothDeviceSettingsState extends State<BluetoothDeviceSettings> {
|
class BluetoothDeviceSettingsState extends State<BluetoothDeviceSettings> {
|
||||||
late BluetoothObject _bluetoothObject;
|
late BluetoothObject _bluetoothObject;
|
||||||
|
bool _isRegistering = false;
|
||||||
String _textInput = ""; // 0123456789 abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
String _textInput = ""; // 0123456789 abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -49,8 +50,8 @@ class BluetoothDeviceSettingsState extends State<BluetoothDeviceSettings> {
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
title: const Text("Device Connection State"),
|
title: const Text("Device Connection State"),
|
||||||
subtitle:
|
subtitle: Text(
|
||||||
Text(_bluetoothObject.isConnected ? "ConnectionState.DISCONECTED" : "ConnectionState.CONNECED"),
|
_bluetoothObject.isConnected ? "ConnectionState.DISCONNECTED" : "ConnectionState.CONNECTED"),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -81,33 +82,48 @@ class BluetoothDeviceSettingsState extends State<BluetoothDeviceSettings> {
|
||||||
))
|
))
|
||||||
])),
|
])),
|
||||||
const Divider(),
|
const Divider(),
|
||||||
Padding(
|
SingleSection(title: "Cloud Registration", children: [
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 0.0),
|
Padding(
|
||||||
child:
|
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 0.0),
|
||||||
SizedBox(
|
child: TextFormField(
|
||||||
width: double.infinity,
|
obscureText: false,
|
||||||
child:
|
decoration: InputDecoration(
|
||||||
ElevatedButton(
|
border: const OutlineInputBorder(),
|
||||||
onPressed: () async {
|
hintText: 'Enter the device name',
|
||||||
_bluetoothObject.sendData(_textInput);
|
labelText: "Device Name",
|
||||||
},
|
filled: false,
|
||||||
style: buttonStyle,
|
suffixIcon: _isRegistering
|
||||||
child: const Text("Send Data"),
|
? FittedBox(
|
||||||
),
|
child: Container(
|
||||||
)
|
height: 10,
|
||||||
),
|
width: 10,
|
||||||
Padding(
|
margin: const EdgeInsets.all(8.0),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
|
child: const CircularProgressIndicator(
|
||||||
child: TextField(
|
strokeWidth: 2.0,
|
||||||
decoration: const InputDecoration(
|
),
|
||||||
border: OutlineInputBorder(),
|
),
|
||||||
hintText: 'Enter the device name',
|
) // : const I
|
||||||
|
: IconButton(
|
||||||
|
icon: const Icon(Icons.login),
|
||||||
|
onPressed: () async {
|
||||||
|
FocusScopeNode currentFocus = FocusScope.of(context);
|
||||||
|
currentFocus.unfocus();
|
||||||
|
setState(() {
|
||||||
|
_isRegistering = true;
|
||||||
|
});
|
||||||
|
await _bluetoothObject.sendData(context, _textInput);
|
||||||
|
setState(() {
|
||||||
|
_isRegistering = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
)),
|
||||||
|
keyboardType: TextInputType.text,
|
||||||
|
onChanged: (String newValue) {
|
||||||
|
_textInput = newValue;
|
||||||
|
},
|
||||||
),
|
),
|
||||||
onChanged: (String newValue) {
|
|
||||||
_textInput = newValue;
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
]),
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
));
|
));
|
||||||
|
|
|
@ -54,21 +54,31 @@ class _BluetoothScreen extends State<BluetoothScreen> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
// Avoid memory leak (`setState` after dispose) and cancel discovery
|
|
||||||
_streamSubscription?.cancel();
|
|
||||||
_activeObject?.disconnectDevice();
|
|
||||||
super.dispose();
|
|
||||||
debugPrint("called dispose");
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _initAsync() async {
|
Future<void> _initAsync() async {
|
||||||
await _enablePermissions();
|
await _enablePermissions();
|
||||||
await _enableBluetooth();
|
await _enableBluetooth();
|
||||||
await _startDiscovery();
|
await _startDiscovery();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
// Avoid memory leak (`setState` after dispose) and cancel discovery
|
||||||
|
debugPrint("called dispose");
|
||||||
|
_disposeAsync();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _disposeAsync() async {
|
||||||
|
await _streamSubscription?.cancel();
|
||||||
|
await _activeObject?.disconnectDevice();
|
||||||
|
List<BluetoothDevice> bondedDevices = await FlutterBluetoothSerial.instance.getBondedDevices();
|
||||||
|
debugPrint(bondedDevices.toString());
|
||||||
|
super.dispose();
|
||||||
|
debugPrint("called dispose");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Future<void> _enablePermissions() async {
|
Future<void> _enablePermissions() async {
|
||||||
PermissionStatus bluetoothScan = await Permission.bluetoothScan.request();
|
PermissionStatus bluetoothScan = await Permission.bluetoothScan.request();
|
||||||
PermissionStatus bluetoothConnect = await Permission.bluetoothConnect.request();
|
PermissionStatus bluetoothConnect = await Permission.bluetoothConnect.request();
|
||||||
|
@ -183,6 +193,7 @@ class _BluetoothScreen extends State<BluetoothScreen> {
|
||||||
CustomListTile(
|
CustomListTile(
|
||||||
title: _enabledBluetooth ? "Bluetooth Enabled" : "Please Enable Bluetooth (click me)",
|
title: _enabledBluetooth ? "Bluetooth Enabled" : "Please Enable Bluetooth (click me)",
|
||||||
icon: _enabledBluetooth ? Icons.check_circle_outline_rounded : Icons.info_outline_rounded,
|
icon: _enabledBluetooth ? Icons.check_circle_outline_rounded : Icons.info_outline_rounded,
|
||||||
|
iconColor: _enabledPermissions ? Colors.green : Colors.red,
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
await _enableBluetooth();
|
await _enableBluetooth();
|
||||||
},
|
},
|
||||||
|
@ -190,6 +201,7 @@ class _BluetoothScreen extends State<BluetoothScreen> {
|
||||||
CustomListTile(
|
CustomListTile(
|
||||||
title: _enabledPermissions ? "Permissions Granted" : "Please Grant Permissions (click me)",
|
title: _enabledPermissions ? "Permissions Granted" : "Please Grant Permissions (click me)",
|
||||||
icon: _enabledPermissions ? Icons.check_circle_outline_rounded : Icons.info_outline_rounded,
|
icon: _enabledPermissions ? Icons.check_circle_outline_rounded : Icons.info_outline_rounded,
|
||||||
|
iconColor: _enabledPermissions ? Colors.green : Colors.red,
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
await _enablePermissions();
|
await _enablePermissions();
|
||||||
},
|
},
|
||||||
|
@ -203,38 +215,6 @@ class _BluetoothScreen extends State<BluetoothScreen> {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
|
||||||
child: Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [
|
|
||||||
// const EdgeInsets defaultContentPadding = EdgeInsets.symmetric(horizontal: 16.0);
|
|
||||||
Expanded(
|
|
||||||
child: ElevatedButton(
|
|
||||||
onPressed: () async {
|
|
||||||
/*await Permission.bluetoothConnect.request();
|
|
||||||
await Permission.bluetoothScan.request();
|
|
||||||
if (await Permission.bluetoothScan.request().isGranted) {
|
|
||||||
// Either the permission was already granted before or the user just granted it.
|
|
||||||
debugPrint("Location Permission is granted");
|
|
||||||
} else {
|
|
||||||
debugPrint("Location Permission is denied.");
|
|
||||||
}*/
|
|
||||||
},
|
|
||||||
style: buttonStyle,
|
|
||||||
child: const Text("Get BT Permissions"),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 16.0),
|
|
||||||
Expanded(
|
|
||||||
child: ElevatedButton(
|
|
||||||
onPressed: () async {
|
|
||||||
_restartDiscovery();
|
|
||||||
},
|
|
||||||
style: buttonStyle,
|
|
||||||
child: const Text("Restart Scan"),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
]),
|
|
||||||
),
|
|
||||||
const Divider(),
|
const Divider(),
|
||||||
SingleSection(
|
SingleSection(
|
||||||
title: "Bluetooth Devices",
|
title: "Bluetooth Devices",
|
||||||
|
@ -262,9 +242,11 @@ class _BluetoothScreen extends State<BluetoothScreen> {
|
||||||
bluetoothObject: bluetoothObject,
|
bluetoothObject: bluetoothObject,
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
await _toggleConnection(bluetoothObject);
|
await _toggleConnection(bluetoothObject);
|
||||||
|
await _restartDiscovery();
|
||||||
},
|
},
|
||||||
onLongPress: () async {
|
onLongPress: () async {
|
||||||
await bluetoothObject.bondDevice();
|
await bluetoothObject.bondDevice(context);
|
||||||
|
await _restartDiscovery();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -124,7 +124,7 @@ class _RegisteredDevicesScreen extends State<RegisteredDevicesScreen> {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
filled: true,
|
filled: false,
|
||||||
),
|
),
|
||||||
keyboardType: TextInputType.text,
|
keyboardType: TextInputType.text,
|
||||||
onChanged: (String newValue) {
|
onChanged: (String newValue) {
|
||||||
|
@ -151,13 +151,13 @@ class _RegisteredDevicesScreen extends State<RegisteredDevicesScreen> {
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) => AlertDialog(
|
builder: (BuildContext context) => AlertDialog(
|
||||||
title: const Text('Device Info'),
|
title: const Text('Device Info'),
|
||||||
content: Text("${entry.id} "
|
content: Text("ID: ${entry.id} "
|
||||||
"\nentrypoint: ${entry.endpoint} "
|
"\n\nentrypoint: ${entry.endpoint} "
|
||||||
"\nstatus: ${entry.status} "
|
"\n\nstatus: ${entry.status} "
|
||||||
"\nconnection: ${entry.connectionState} "
|
"\n\nconnection: ${entry.connectionState} "
|
||||||
"\nlast activity: ${entry.lastActivityTime}"
|
"\n\nlast activity: ${entry.lastActivityTime}"
|
||||||
"\nprimaryThumbprint: ${entry.primaryThumbprint}"),
|
"\n\nprimaryThumbprint: ${entry.primaryThumbprint}"),
|
||||||
backgroundColor: Colors.white70,
|
backgroundColor: Colors.white,
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
TextButton(onPressed: () => Navigator.pop(context, 'Cancel'),
|
TextButton(onPressed: () => Navigator.pop(context, 'Cancel'),
|
||||||
child: const Text('Cancel'),
|
child: const Text('Cancel'),
|
||||||
|
|
|
@ -85,6 +85,7 @@ class _SettingsState extends State<Settings> {
|
||||||
border: const OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
hintText: 'Enter the server password',
|
hintText: 'Enter the server password',
|
||||||
labelText: "Password",
|
labelText: "Password",
|
||||||
|
filled: false,
|
||||||
suffixIcon: IconButton(
|
suffixIcon: IconButton(
|
||||||
icon: Icon(_passwordVisible ? Icons.visibility : Icons.visibility_off),
|
icon: Icon(_passwordVisible ? Icons.visibility : Icons.visibility_off),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
@ -93,7 +94,6 @@ class _SettingsState extends State<Settings> {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
filled: true,
|
|
||||||
),
|
),
|
||||||
initialValue: Settings.password,
|
initialValue: Settings.password,
|
||||||
keyboardType: TextInputType.text,
|
keyboardType: TextInputType.text,
|
||||||
|
|
|
@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||||
class CustomListTile extends StatelessWidget {
|
class CustomListTile extends StatelessWidget {
|
||||||
final String title;
|
final String title;
|
||||||
final IconData icon;
|
final IconData icon;
|
||||||
|
final Color? iconColor;
|
||||||
final VoidCallback? onTap;
|
final VoidCallback? onTap;
|
||||||
|
|
||||||
//final Widget? trailing;
|
//final Widget? trailing;
|
||||||
|
@ -11,6 +12,7 @@ class CustomListTile extends StatelessWidget {
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.title,
|
required this.title,
|
||||||
required this.icon,
|
required this.icon,
|
||||||
|
this.iconColor,
|
||||||
this.onTap,
|
this.onTap,
|
||||||
//this.trailing,
|
//this.trailing,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
@ -19,7 +21,7 @@ class CustomListTile extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text(title),
|
title: Text(title),
|
||||||
leading: Icon(icon),
|
leading: Icon(icon, color: iconColor),
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
//trailing: trailing,
|
//trailing: trailing,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue