@@ -51,87 +51,95 @@ class _ScanForNewDevice extends State<ScanForNewDevice> {
5151 ),
5252 ),
5353 ScanGearList (),
54- if (HiveProxy .getOrDefault (
55- settings,
56- showDebugging,
57- defaultValue: showDemoGearDefault,
58- )) ...[
59- ExpansionTile (
60- title: Text (convertToUwU (scanDemoGear ())),
61- children: [
62- PageInfoCard (text: scanDemoGearTip ()),
63- ListTile (
64- leading: const Icon (Icons .add),
65- subtitle: DropdownMenu <BaseDeviceDefinition >(
66- initialSelection: null ,
67- expandedInsets: EdgeInsets .zero,
68- label: Text (convertToUwU (scanAddDemoGear ())),
69- onSelected: (value) async {
70- if (value != null ) {
71- setState (() {
72- BaseStoredDevice baseStoredDevice;
73- BaseStatefulDevice statefulDevice;
74- baseStoredDevice = BaseStoredDevice (
75- value.uuid,
76- "DEV${value .deviceType .translatedName }" ,
77- value.deviceType.color ().toARGB32 (),
78- )..name = getNameFromBTName (value.btName);
79- statefulDevice = BaseStatefulDevice (
80- value,
81- baseStoredDevice,
82- );
83- statefulDevice.deviceConnectionState.value =
84- ConnectivityState .connected;
85- if (value.deviceType == DeviceType .ears) {
86- statefulDevice.bluetoothUartService.value =
87- uartServices.firstWhere (
88- (element) =>
89- element.label == "Legacy Ears" ,
90- );
91- } else {
92- statefulDevice.bluetoothUartService.value =
93- uartServices.firstWhere (
94- (element) =>
95- element.label == "TailCoNTROL" ,
96- );
97- }
98- if (! KnownDevices .instance.state.containsKey (
99- baseStoredDevice.btMACAddress,
100- )) {
101- KnownDevices .instance.add (statefulDevice);
102- }
103- context.pop ();
104- });
105- }
106- },
107- dropdownMenuEntries: DeviceRegistry .allDevices
108- .map (
109- (e) => DropdownMenuEntry (
110- value: e,
111- label: getNameFromBTName (e.btName),
112- ),
113- )
114- .toList (),
115- ),
116- ),
117- ListTile (
118- title: Text (convertToUwU (scanRemoveDemoGear ())),
119- leading: const Icon (Icons .delete),
120- onTap: () async {
121- KnownDevices .instance.removeDevGear ();
122- if (KnownDevices .instance.state.values
123- .where (
124- (element) =>
125- element.deviceConnectionState.value ==
126- ConnectivityState .connected,
127- )
128- .isEmpty) {}
129- context.pop ();
54+ ExpansionTile (
55+ title: Text (convertToUwU (scanDemoGear ())),
56+ children: [
57+ PageInfoCard (text: scanDemoGearTip ()),
58+ ListTile (
59+ leading: const Icon (Icons .add),
60+ subtitle: DropdownMenu <BaseDeviceDefinition >(
61+ initialSelection: null ,
62+ expandedInsets: EdgeInsets .zero,
63+ label: Text (convertToUwU (scanAddDemoGear ())),
64+ onSelected: (value) async {
65+ if (value != null ) {
66+ setState (() {
67+ BaseStoredDevice baseStoredDevice;
68+ BaseStatefulDevice statefulDevice;
69+ baseStoredDevice = BaseStoredDevice (
70+ value.uuid,
71+ "DEV${value .deviceType .translatedName }" ,
72+ value.deviceType.color ().toARGB32 (),
73+ )..name = getNameFromBTName (value.btName);
74+ statefulDevice = BaseStatefulDevice (
75+ value,
76+ baseStoredDevice,
77+ );
78+ statefulDevice.deviceConnectionState.value =
79+ ConnectivityState .connected;
80+ if (value.deviceType == DeviceType .ears) {
81+ statefulDevice.bluetoothUartService.value =
82+ uartServices.firstWhere (
83+ (element) =>
84+ element.label == "Legacy Ears" ,
85+ );
86+ } else {
87+ statefulDevice.bluetoothUartService.value =
88+ uartServices.firstWhere (
89+ (element) =>
90+ element.label == "TailCoNTROL" ,
91+ );
92+ }
93+ if (! KnownDevices .instance.state.containsKey (
94+ baseStoredDevice.btMACAddress,
95+ )) {
96+ KnownDevices .instance.add (statefulDevice);
97+ }
98+ context.pop ();
99+ });
100+ }
130101 },
102+ dropdownMenuEntries: DeviceRegistry .allDevices
103+ .where ((element) {
104+ if (HiveProxy .getOrDefault (
105+ settings,
106+ showDebugging,
107+ defaultValue: showDemoGearDefault,
108+ )) {
109+ return true ;
110+ } else {
111+ return [
112+ "EG2" ,
113+ "MiTail" ,
114+ ].contains (element.btName);
115+ }
116+ })
117+ .map (
118+ (e) => DropdownMenuEntry (
119+ value: e,
120+ label: getNameFromBTName (e.btName),
121+ ),
122+ )
123+ .toList (),
131124 ),
132- ],
133- ),
134- ],
125+ ),
126+ ListTile (
127+ title: Text (convertToUwU (scanRemoveDemoGear ())),
128+ leading: const Icon (Icons .delete),
129+ onTap: () async {
130+ KnownDevices .instance.removeDevGear ();
131+ if (KnownDevices .instance.state.values
132+ .where (
133+ (element) =>
134+ element.deviceConnectionState.value ==
135+ ConnectivityState .connected,
136+ )
137+ .isEmpty) {}
138+ context.pop ();
139+ },
140+ ),
141+ ],
142+ ),
135143 ],
136144 );
137145 } else {
0 commit comments