Skip to content

Commit

Permalink
BLE settings, GUI overflow fixes (#215)
Browse files Browse the repository at this point in the history
BLE settings and some overflow fixes. Also made card icons change depending on hf / lf and fixed a bit of overflow

---------

Co-authored-by: GameTec_live <[email protected]>
  • Loading branch information
Foxushka and GameTec-live authored Sep 5, 2023
1 parent ab8e73d commit 594a994
Show file tree
Hide file tree
Showing 12 changed files with 498 additions and 224 deletions.
19 changes: 19 additions & 0 deletions chameleonultragui/lib/bridge/chameleon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ enum ChameleonCommand {
getLongButtonPressConfig(1028),
setLongButtonPressConfig(1029),

// BLE
bleSetConnectKey(1030),
bleGetConnectKey(1031),
bleClearBondedDevices(1032),

// hf reader commands
scan14ATag(2000),
mf1SupportDetect(2001),
Expand Down Expand Up @@ -880,4 +885,18 @@ class ChameleonCommunicator {
await sendCmd(ChameleonCommand.setLongButtonPressConfig,
data: Uint8List.fromList([type.value, mode.value]));
}

Future<void> clearBLEBoundedDevices() async {
await sendCmd(ChameleonCommand.bleClearBondedDevices, skipReceive: true);
}

Future<String> getBLEConnectionKey() async {
var resp = await sendCmd(ChameleonCommand.bleGetConnectKey);
return utf8.decode(resp!.data, allowMalformed: true);
}

Future<void> setBLEConnectKey(String key) async {
await sendCmd(ChameleonCommand.bleSetConnectKey,
data: Uint8List.fromList(utf8.encode(key)));
}
}
39 changes: 21 additions & 18 deletions chameleonultragui/lib/gui/component/toggle_buttons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,26 @@ class ToggleButtonsState extends State<ToggleButtonsWrapper> {

@override
Widget build(BuildContext context) {
return ToggleButtons(
direction: Axis.horizontal,
onPressed: (int index) async {
setState(() {
for (int i = 0; i < values.length; i++) {
values[i] = i == index;
}
});
await widget.onChange(index);
},
borderRadius: const BorderRadius.all(Radius.circular(8)),
constraints: const BoxConstraints(
minHeight: 40.0,
minWidth: 80.0,
),
isSelected: values,
children: textItems,
);
return FittedBox(
alignment: Alignment.centerRight,
fit: BoxFit.scaleDown,
child: ToggleButtons(
direction: Axis.horizontal,
onPressed: (int index) async {
setState(() {
for (int i = 0; i < values.length; i++) {
values[i] = i == index;
}
});
await widget.onChange(index);
},
borderRadius: const BorderRadius.all(Radius.circular(32)),
constraints: const BoxConstraints(
minHeight: 40.0,
minWidth: 80.0,
),
isSelected: values,
children: textItems,
));
}
}
7 changes: 6 additions & 1 deletion chameleonultragui/lib/gui/menu/card_edit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ class CardEditMenuState extends State<CardEditMenu> {
labelText: localizations.name,
hintText: localizations.enter_name,
prefix: IconButton(
icon: Icon(Icons.nfc, color: currentColor),
icon: Icon(
(chameleonTagToFrequency(widget.tagSave.tag) ==
TagFrequency.hf)
? Icons.credit_card
: Icons.wifi,
color: currentColor),
onPressed: () async {
showDialog(
context: context,
Expand Down
Loading

0 comments on commit 594a994

Please sign in to comment.