Skip to content

Commit

Permalink
fix ui issues with backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
o-bagge committed May 24, 2024
1 parent 7e0d2a1 commit 571f17e
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 25 deletions.
6 changes: 4 additions & 2 deletions open_earable/lib/ble/ble_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class BluetoothController extends ChangeNotifier {

_connectionStateSubscriptionLeft =
_openEarableLeft.bleManager.connectionStateStream.listen((connected) {
_isV2 = _openEarableLeft.deviceHardwareVersion?.substring(0, 1) == "1";
_isV2 = _openEarableLeft.deviceHardwareVersion?.substring(0, 1) == "2";
_connectedLeft = connected;
if (connected) {
_getSOCLeft();
Expand Down Expand Up @@ -157,6 +157,8 @@ class BluetoothController extends ChangeNotifier {
prefs.setString("lastConnectedDeviceName" + otherSide, "");
}
prefs.setString("lastConnectedDeviceName" + side, device.name);
notifyListeners();
Future.microtask(() {
notifyListeners();
});
}
}
26 changes: 19 additions & 7 deletions open_earable/lib/controls_tab/views/v1_connect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,25 @@ class _ConnectCard extends State<V1ConnectCard> {
}

_connectButtonAction(BuildContext context) {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => Scaffold(
backgroundColor: Theme.of(context).colorScheme.background,
appBar: AppBar(
title: Text("Bluetooth Devices"),
),
body: BLEPage(_openEarable, 0))));
Navigator.of(context).push(Platform.isIOS
? CupertinoPageRoute(
builder: (context) => CupertinoPageScaffold(
backgroundColor:
CupertinoTheme.of(context).scaffoldBackgroundColor,
navigationBar: CupertinoNavigationBar(
middle: Text("Bluetooth Devices"),
),
child: BLEPage(
Provider.of<BluetoothController>(context, listen: false)
.openEarableLeft,
0)))
: MaterialPageRoute(
builder: (context) => Scaffold(
backgroundColor: Theme.of(context).colorScheme.background,
appBar: AppBar(
title: Text("Bluetooth Devices"),
),
body: BLEPage(_openEarable, 0))));
}

void _tryAutoconnect(
Expand Down
37 changes: 25 additions & 12 deletions open_earable/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -242,18 +242,31 @@ class _MyHomePageState extends State<MyHomePage> {
index: OpenEarableSettingsV2()
.selectedButtonIndex)));
} else {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => Scaffold(
backgroundColor:
Theme.of(context).colorScheme.background,
appBar: AppBar(
title: Text("Bluetooth Devices"),
),
body: BLEPage(
Provider.of<BluetoothController>(context,
listen: false)
.openEarableLeft,
0))));
Navigator.of(context).push(Platform.isIOS
? CupertinoPageRoute(
builder: (context) => CupertinoPageScaffold(
backgroundColor: CupertinoTheme.of(context)
.scaffoldBackgroundColor,
navigationBar: CupertinoNavigationBar(
middle: Text("Bluetooth Devices"),
),
child: BLEPage(
Provider.of<BluetoothController>(context,
listen: false)
.openEarableLeft,
0)))
: MaterialPageRoute(
builder: (context) => Scaffold(
backgroundColor:
Theme.of(context).colorScheme.background,
appBar: AppBar(
title: Text("Bluetooth Devices"),
),
body: BLEPage(
Provider.of<BluetoothController>(context,
listen: false)
.openEarableLeft,
0))));
}
},
),
Expand Down
15 changes: 11 additions & 4 deletions open_earable/lib/shared/earable_not_connected_warning.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,17 @@ class EarableNotConnectedWarning extends StatelessWidget {
SizedBox(height: 16),
Center(
child: Text(
"Not connected to\nOpenEarable " +
(OpenEarableSettingsV2().selectedButtonIndex == 0
? "(left)"
: "(right)"),
"Not connected to\nOpenEarable" +
((Provider.of<BluetoothController>(context)
.openEarableLeft
.deviceHardwareVersion ??
"1")
.substring(0, 1) ==
"1"
? ""
: (OpenEarableSettingsV2().selectedButtonIndex == 0
? " (left)"
: " (right)")),
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
Expand Down

0 comments on commit 571f17e

Please sign in to comment.