-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0ce6c54
commit f0f45cb
Showing
15 changed files
with
126 additions
and
770 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_bluetooth_serial/flutter_bluetooth_serial.dart'; | ||
|
||
class BluetoothDeviceListEntry extends ListTile { | ||
BluetoothDeviceListEntry({super.key, | ||
required BluetoothDevice device, | ||
int? rssi, | ||
GestureTapCallback? onTap, | ||
GestureLongPressCallback? onLongPress, | ||
bool enabled = true, | ||
}) : super( | ||
onTap: onTap, | ||
onLongPress: onLongPress, | ||
enabled: enabled, | ||
leading: | ||
const Icon(Icons.devices), // @TODO . !BluetoothClass! class aware icon | ||
title: Text(device.name ?? ""), | ||
subtitle: Text(device.address.toString()), | ||
trailing: Row( | ||
mainAxisSize: MainAxisSize.min, | ||
children: <Widget>[ | ||
rssi != null | ||
? Container( | ||
margin: const EdgeInsets.all(8.0), | ||
// child: DefaultTextStyle( | ||
// style: _computeTextStyle(rssi), | ||
// child: Column( | ||
// mainAxisSize: MainAxisSize.min, | ||
// children: <Widget>[ | ||
// Text(rssi.toString()), | ||
// const Text('dBm'), | ||
// ], | ||
// ), | ||
// ), | ||
) | ||
: const SizedBox(width: 0, height: 0), | ||
device.isConnected | ||
? const Icon(Icons.import_export) | ||
: const SizedBox(width: 0, height: 0), | ||
device.isBonded | ||
? const Icon(Icons.link) | ||
: const SizedBox(width: 0, height: 0), | ||
], | ||
), | ||
); | ||
|
||
// static TextStyle _computeTextStyle(int rssi) { | ||
// /**/ if (rssi >= -35) { | ||
// return TextStyle(color: Colors.greenAccent[700]); | ||
// } else if (rssi >= -45) { | ||
// return TextStyle( | ||
// color: Color.lerp( | ||
// Colors.greenAccent[700], Colors.lightGreen, -(rssi + 35) / 10)); | ||
// } else if (rssi >= -55) { | ||
// return TextStyle( | ||
// color: Color.lerp( | ||
// Colors.lightGreen, Colors.lime[600], -(rssi + 45) / 10)); | ||
// } else if (rssi >= -65) { | ||
// return TextStyle( | ||
// color: Color.lerp(Colors.lime[600], Colors.amber, -(rssi + 55) / 10)); | ||
// } else if (rssi >= -75) { | ||
// return TextStyle( | ||
// color: Color.lerp( | ||
// Colors.amber, Colors.deepOrangeAccent, -(rssi + 65) / 10)); | ||
// } else if (rssi >= -85) { | ||
// return TextStyle( | ||
// color: Color.lerp( | ||
// Colors.deepOrangeAccent, Colors.redAccent, -(rssi + 75) / 10)); | ||
// } else { | ||
// return const TextStyle(color: Colors.redAccent); | ||
// } | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.