Skip to content

Commit a27caa2

Browse files
open_wearable/lib/widgets/devices/device_detail/device_detail_page.dart: added forget device button for system devices
1 parent 7e60ba7 commit a27caa2

2 files changed

Lines changed: 33 additions & 7 deletions

File tree

open_wearable/lib/widgets/devices/device_detail/device_detail_page.dart

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,38 @@ class _DeviceDetailPageState extends State<DeviceDetailPage> {
7575
),
7676
if (wearableIconPath != null)
7777
SvgPicture.asset(wearableIconPath, width: 100, height: 100),
78-
PlatformElevatedButton(
79-
child: PlatformText("Disconnect"),
80-
onPressed: () {
81-
widget.device.disconnect();
82-
Navigator.of(context).pop();
83-
},
78+
Row(
79+
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
80+
children: [
81+
if (widget.device is SystemDevice && (widget.device as SystemDevice).isConnectedViaSystem)
82+
PlatformElevatedButton(
83+
child: PlatformText("Forget Device"),
84+
onPressed: () {
85+
// Show an alert that the device has to be ignored via the system settings
86+
showPlatformDialog(
87+
context: context,
88+
builder: (_) => PlatformAlertDialog(
89+
title: PlatformText('Forget'),
90+
content: PlatformText('To disconnect this device permanently, please go to your system Bluetooth settings and ignore the device from there.'),
91+
actions: <Widget>[
92+
PlatformDialogAction(
93+
cupertino: (_, __) => CupertinoDialogActionData(isDefaultAction: true),
94+
child: PlatformText('OK'),
95+
onPressed: () => Navigator.of(context).pop(),
96+
),
97+
],
98+
),
99+
);
100+
},
101+
),
102+
PlatformElevatedButton(
103+
child: PlatformText("Disconnect"),
104+
onPressed: () {
105+
widget.device.disconnect();
106+
Navigator.of(context).pop();
107+
},
108+
),
109+
],
84110
),
85111
],
86112
),

open_wearable/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ packages:
445445
description:
446446
path: "."
447447
ref: HEAD
448-
resolved-ref: f37ed6acbe657bef079d25ada32f68284924fcc7
448+
resolved-ref: c20ece1d0936f3afeaae9978905d5d59a24a3e0d
449449
url: "https://github.com/OpenEarable/open_earable_flutter.git"
450450
source: git
451451
version: "0.1.0"

0 commit comments

Comments
 (0)