From fdaaf122b4d40170d167d3701ff6ed9b59022072 Mon Sep 17 00:00:00 2001 From: Jonas Greifenhain Date: Tue, 17 Sep 2024 14:26:50 +0200 Subject: [PATCH 01/10] Create compatibility with `youtube_player_flutter` --- open_earable/web/index.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/open_earable/web/index.html b/open_earable/web/index.html index 4458f60..0ec58c8 100644 --- a/open_earable/web/index.html +++ b/open_earable/web/index.html @@ -35,6 +35,7 @@ var serviceWorkerVersion = null; + @@ -56,6 +57,5 @@ }); }); - - - \ No newline at end of file + + From b353978c519752f83069b14ede5ece80df74406b Mon Sep 17 00:00:00 2001 From: Jonas Greifenhain Date: Tue, 17 Sep 2024 14:41:16 +0200 Subject: [PATCH 02/10] Change OpenEarable lib dependency --- open_earable/pubspec.lock | 188 ++++++++++++++++++++++++-------------- open_earable/pubspec.yaml | 6 +- 2 files changed, 121 insertions(+), 73 deletions(-) diff --git a/open_earable/pubspec.lock b/open_earable/pubspec.lock index 27b9ff8..a9ddc2b 100644 --- a/open_earable/pubspec.lock +++ b/open_earable/pubspec.lock @@ -49,6 +49,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.11.0" + bluez: + dependency: transitive + description: + name: bluez + sha256: "203a1924e818a9dd74af2b2c7a8f375ab8e5edf0e486bba8f90a0d8a17ed9fce" + url: "https://pub.dev" + source: hosted + version: "0.8.2" boolean_selector: dependency: transitive description: @@ -153,6 +161,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.8" + dbus: + dependency: transitive + description: + name: dbus + sha256: "365c771ac3b0e58845f39ec6deebc76e3276aa9922b0cc60840712094d9047ac" + url: "https://pub.dev" + source: hosted + version: "0.7.10" english_words: dependency: "direct main" description: @@ -185,14 +201,6 @@ packages: url: "https://pub.dev" source: hosted version: "7.0.0" - fixnum: - dependency: transitive - description: - name: fixnum - sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" - url: "https://pub.dev" - source: hosted - version: "1.1.0" flutter: dependency: "direct main" description: flutter @@ -285,32 +293,24 @@ packages: url: "https://pub.dev" source: hosted version: "2.4.1" - flutter_reactive_ble: - dependency: "direct main" - description: - name: flutter_reactive_ble - sha256: "247e2efa76de203d1ba11335c13754b5b9d0504b5423e5b0c93a600f016b24e0" - url: "https://pub.dev" - source: hosted - version: "5.3.1" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + flutter_web_bluetooth: + dependency: transitive + description: + name: flutter_web_bluetooth + sha256: "52ce64f65d7321c4bf6abfe9dac02fb888731339a5e0ad6de59fb916c20c9f02" + url: "https://pub.dev" + source: hosted + version: "0.2.3" flutter_web_plugins: dependency: transitive description: flutter source: sdk version: "0.0.0" - functional_data: - dependency: transitive - description: - name: functional_data - sha256: "76d17dc707c40e552014f5a49c0afcc3f1e3f05e800cd6b7872940bfe41a5039" - url: "https://pub.dev" - source: hosted - version: "1.2.0" html: dependency: transitive description: @@ -375,6 +375,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.1" + logging: + dependency: transitive + description: + name: logging + sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" + url: "https://pub.dev" + source: hosted + version: "1.2.0" matcher: dependency: transitive description: @@ -419,8 +427,8 @@ packages: dependency: "direct main" description: path: "." - ref: HEAD - resolved-ref: e4c390516cfc753c18215d56591c2cfbc5b4296a + ref: web_compatibility + resolved-ref: "3e82d7499c0fac2d8dff90da7f98aa5266698f63" url: "https://github.com/OpenEarable/open_earable_flutter.git" source: git version: "0.0.2" @@ -428,10 +436,66 @@ packages: dependency: "direct main" description: name: open_file - sha256: a5a32d44acb7c899987d0999e1e3cbb0a0f1adebbf41ac813ec6d2d8faa0af20 + sha256: a5ef7162fb9b72955d42abab9f3159b2fd3ee81a27187535c8038dcd5d1fa7f2 + url: "https://pub.dev" + source: hosted + version: "3.5.4" + open_file_android: + dependency: transitive + description: + name: open_file_android + sha256: b5e1a2e9c5ea8e256b015403e94299039627c7205c2a5e6bb426c33235b6ca9a + url: "https://pub.dev" + source: hosted + version: "1.0.2" + open_file_ios: + dependency: transitive + description: + name: open_file_ios + sha256: "8d9c03495cf14ca70bdbf191894b822ba3b2629cc0046ee311cbbe504db66c44" + url: "https://pub.dev" + source: hosted + version: "1.0.2" + open_file_linux: + dependency: transitive + description: + name: open_file_linux + sha256: cd2088722048b9c40f8615c6d83005fe0726e0e447e9cdfb40c2b65477291f7d url: "https://pub.dev" source: hosted - version: "3.3.2" + version: "0.0.4" + open_file_mac: + dependency: transitive + description: + name: open_file_mac + sha256: "9d809f528cccc6dc9390caf50893eae9a6944e0f3b8a2558c7ad19e91c9244a1" + url: "https://pub.dev" + source: hosted + version: "1.0.1" + open_file_platform_interface: + dependency: transitive + description: + name: open_file_platform_interface + sha256: "14c50efb1a9667cb96e4fa68d601e6ad348fe337b02789834029b37ae3631498" + url: "https://pub.dev" + source: hosted + version: "1.0.2" + open_file_web: + dependency: transitive + description: + name: open_file_web + sha256: ba35c6f38c21c2bb4268a80927bb828353dda0edfce92e274e0b9639e4f31360 + url: "https://pub.dev" + source: hosted + version: "0.0.2" + open_file_windows: + dependency: transitive + description: + name: open_file_windows + sha256: "2f4318d2d3958ec8d63b6dd4430c15b1fcb2fe7a2113e83c734584501a5c6d81" + url: "https://pub.dev" + source: hosted + version: "0.0.2" path: dependency: transitive description: @@ -516,18 +580,18 @@ packages: dependency: transitive description: name: permission_handler_html - sha256: d220eb8476b466d58b161e10b3001d93999010a26228a3fb89c4280db1249546 + sha256: af26edbbb1f2674af65a8f4b56e1a6f526156bc273d0e65dd8075fab51c78851 url: "https://pub.dev" source: hosted - version: "0.1.3+1" + version: "0.1.3+2" permission_handler_platform_interface: dependency: transitive description: name: permission_handler_platform_interface - sha256: fe0ffe274d665be8e34f9c59705441a7d248edebbe5d9e3ec2665f88b79358ea + sha256: e9c8eadee926c4532d0305dff94b85bf961f16759c3af791486613152af4b4f9 url: "https://pub.dev" source: hosted - version: "4.2.2" + version: "4.2.3" permission_handler_windows: dependency: transitive description: @@ -560,14 +624,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.8" - protobuf: - dependency: transitive - description: - name: protobuf - sha256: "01dd9bd0fa02548bf2ceee13545d4a0ec6046459d847b6b061d8a27237108a08" - url: "https://pub.dev" - source: hosted - version: "2.1.0" provider: dependency: "direct main" description: @@ -576,22 +632,6 @@ packages: url: "https://pub.dev" source: hosted version: "6.1.2" - reactive_ble_mobile: - dependency: transitive - description: - name: reactive_ble_mobile - sha256: "9ec2b4c9c725e439950838d551579750060258fbccd5536d0543b4d07d225798" - url: "https://pub.dev" - source: hosted - version: "5.3.1" - reactive_ble_platform_interface: - dependency: transitive - description: - name: reactive_ble_platform_interface - sha256: "632c92401a2d69c9b94bd48f8fd47488a7013f3d1f9b291884350291a4a81813" - url: "https://pub.dev" - source: hosted - version: "5.3.1" shared_preferences: dependency: "direct main" description: @@ -604,10 +644,10 @@ packages: dependency: transitive description: name: shared_preferences_android - sha256: a7e8467e9181cef109f601e3f65765685786c1a738a83d7fbbde377589c0d974 + sha256: "480ba4345773f56acda9abf5f50bd966f581dac5d514e5fc4a18c62976bbba7e" url: "https://pub.dev" source: hosted - version: "2.3.1" + version: "2.3.2" shared_preferences_foundation: dependency: transitive description: @@ -717,6 +757,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.2" + universal_ble: + dependency: transitive + description: + name: universal_ble + sha256: "0dfbd6b64bff3ad61ed7a895c232530d9614e9b01ab261a74433a43267edb7f3" + url: "https://pub.dev" + source: hosted + version: "0.12.0" universal_io: dependency: transitive description: @@ -737,10 +785,10 @@ packages: dependency: transitive description: name: url_launcher_android - sha256: f0c73347dfcfa5b3db8bc06e1502668265d39c08f310c29bff4e28eea9699f79 + sha256: e35a698ac302dd68e41f73250bd9517fe3ab5fa4f18fe4647a0872db61bacbab url: "https://pub.dev" source: hosted - version: "6.3.9" + version: "6.3.10" url_launcher_ios: dependency: transitive description: @@ -817,18 +865,18 @@ packages: dependency: transitive description: name: webview_flutter - sha256: "6869c8786d179f929144b4a1f86e09ac0eddfe475984951ea6c634774c16b522" + sha256: ec81f57aa1611f8ebecf1d2259da4ef052281cb5ad624131c93546c79ccc7736 url: "https://pub.dev" source: hosted - version: "4.8.0" + version: "4.9.0" webview_flutter_android: dependency: transitive description: name: webview_flutter_android - sha256: c66651fba15f9d7ddd31daec42da8d6bce46c85610a7127e3ebcb39a4395c3c9 + sha256: "6e64fcb1c19d92024da8f33503aaeeda35825d77142c01d0ea2aa32edc79fdc8" url: "https://pub.dev" source: hosted - version: "3.16.6" + version: "3.16.7" webview_flutter_platform_interface: dependency: transitive description: @@ -841,10 +889,10 @@ packages: dependency: transitive description: name: webview_flutter_wkwebview - sha256: "9c62cc46fa4f2d41e10ab81014c1de470a6c6f26051a2de32111b2ee55287feb" + sha256: "1942a12224ab31e9508cf00c0c6347b931b023b8a4f0811e5dec3b06f94f117d" url: "https://pub.dev" source: hosted - version: "3.14.0" + version: "3.15.0" xdg_directories: dependency: transitive description: @@ -873,10 +921,10 @@ packages: dependency: "direct main" description: name: youtube_player_flutter - sha256: b670314008a9abd051f01f82df754d76fd1366340f03f4f8ff86fc3d6b03080c + sha256: "6de924ac24d7d9d0723fc47d2bbc71d656f089aba9b7f26d4e6855b5ea3bf3fe" url: "https://pub.dev" source: hosted - version: "9.0.3" + version: "9.0.0" sdks: - dart: ">=3.4.0 <4.0.0" - flutter: ">=3.22.0" + dart: ">=3.5.0 <4.0.0" + flutter: ">=3.24.0" diff --git a/open_earable/pubspec.yaml b/open_earable/pubspec.yaml index 6f290dc..aeeb8f1 100644 --- a/open_earable/pubspec.yaml +++ b/open_earable/pubspec.yaml @@ -35,9 +35,9 @@ dependencies: open_earable_flutter: git: url: https://github.com/OpenEarable/open_earable_flutter.git - youtube_player_flutter: ^9.0.3 + ref: web_compatibility + youtube_player_flutter: 9.0.0 permission_handler: ^11.3.1 - flutter_reactive_ble: ^5.3.1 app_settings: ^5.1.1 # The following adds the Cupertino Icons font to your application. @@ -101,7 +101,7 @@ flutter_native_splash: # IMPORTANT NOTE: These parameter do not affect the configuration of Android 12 and later, which # handle splash screens differently that prior versions of Android. Android 12 and later must be # configured specifically in the android_12 section below. - + # color or background_image is the only required parameter. Use color to set the background # of your splash screen to a solid color. Use background_image to set the background of your # splash screen to a png image. This is useful for gradients. The image will be stretch to the From 7fac04e02c34e49ef04ed8111b2e4133dd296af6 Mon Sep 17 00:00:00 2001 From: Jonas Greifenhain Date: Tue, 17 Sep 2024 16:36:30 +0200 Subject: [PATCH 03/10] Remove iOS specific rendering --- open_earable/lib/apps_tab/apps_tab.dart | 20 +- open_earable/lib/ble/ble_connect_view.dart | 50 +-- open_earable/lib/ble/ble_tab_bar_page.dart | 139 +++----- open_earable/lib/ble/v1_ble_connect_view.dart | 67 ++-- .../lib/controls_tab/controls_tab.dart | 4 +- .../lib/controls_tab/views/audio_player.dart | 132 +++---- .../lib/controls_tab/views/connect.dart | 225 ++++-------- .../lib/controls_tab/views/led_color.dart | 77 ++-- .../views/sensor_control/sensor_control.dart | 64 ++-- .../sensor_control/sensor_control_row.dart | 43 +-- .../lib/controls_tab/views/v1_connect.dart | 100 ++---- .../views/v1_sensor_configuration.dart | 80 ++--- open_earable/lib/main.dart | 329 +++++------------- .../lib/shared/dynamic_value_picker.dart | 86 ++--- 14 files changed, 452 insertions(+), 964 deletions(-) diff --git a/open_earable/lib/apps_tab/apps_tab.dart b/open_earable/lib/apps_tab/apps_tab.dart index a392e73..bd944ef 100644 --- a/open_earable/lib/apps_tab/apps_tab.dart +++ b/open_earable/lib/apps_tab/apps_tab.dart @@ -48,8 +48,8 @@ class AppsTab extends StatelessWidget { child: Recorder(_openEarable))))); }), AppInfo( - logoPath: - "lib/apps_tab/posture_tracker/assets/logo.png", //iconData: Icons.face_6, + logoPath: "lib/apps_tab/posture_tracker/assets/logo.png", + //iconData: Icons.face_6, title: "Posture Tracker", description: "Get feedback on bad posture", onTap: () { @@ -79,8 +79,8 @@ class AppsTab extends StatelessWidget { child: JumpHeightTest(_openEarable)))))); }), AppInfo( - logoPath: - "lib/apps_tab/jump_rope_counter/assets/logo.png", //iconData: Icons.keyboard_double_arrow_up, + logoPath: "lib/apps_tab/jump_rope_counter/assets/logo.png", + //iconData: Icons.keyboard_double_arrow_up, title: "Jump Rope Counter", description: "Count your rope skips", onTap: () { @@ -120,8 +120,8 @@ class AppsTab extends StatelessWidget { child: SleepHomeScreen(_openEarable))))); }), AppInfo( - logoPath: - "lib/apps_tab/tightness/assets/logo.png", //iconData: Icons.music_note, + logoPath: "lib/apps_tab/tightness/assets/logo.png", + //iconData: Icons.music_note, title: "Tightness Meter", description: "Practice your sense of rythm", onTap: () { @@ -164,9 +164,7 @@ class AppsTab extends StatelessWidget { return Padding( padding: const EdgeInsets.symmetric(horizontal: 5), child: Card( - color: Platform.isIOS - ? CupertinoTheme.of(context).primaryContrastingColor - : Theme.of(context).colorScheme.primary, + color: Theme.of(context).colorScheme.primary, child: ListTile( iconColor: Colors.white, textColor: Colors.white, @@ -179,8 +177,8 @@ class AppsTab extends StatelessWidget { fit: BoxFit.cover))), title: Text(apps[index].title), subtitle: Text(apps[index].description), - trailing: Icon(Icons.arrow_forward_ios, - size: 16.0), // Arrow icon on the right + trailing: Icon(Icons.arrow_forward_ios, size: 16.0), + // Arrow icon on the right onTap: apps[index].onTap, // Callback when the card is tapped ), diff --git a/open_earable/lib/ble/ble_connect_view.dart b/open_earable/lib/ble/ble_connect_view.dart index 8ea86e5..08f3814 100644 --- a/open_earable/lib/ble/ble_connect_view.dart +++ b/open_earable/lib/ble/ble_connect_view.dart @@ -8,6 +8,7 @@ import 'package:provider/provider.dart'; class BLEPage extends StatefulWidget { final OpenEarable openEarable; final int earableIndex; + BLEPage(this.openEarable, this.earableIndex); @override @@ -16,6 +17,7 @@ class BLEPage extends StatefulWidget { class _BLEPageState extends State { late OpenEarable _openEarable; + @override void initState() { super.initState(); @@ -56,8 +58,8 @@ class _BLEPageState extends State { ), child: ListView.builder( padding: EdgeInsets.zero, - physics: - const NeverScrollableScrollPhysics(), // Disable scrolling, + physics: const NeverScrollableScrollPhysics(), + // Disable scrolling, shrinkWrap: true, itemCount: controller.discoveredDevices.length, itemBuilder: (BuildContext context, int index) { @@ -101,28 +103,18 @@ class _BLEPageState extends State { textAlign: TextAlign.center, ))), Center( - child: Platform.isIOS - ? CupertinoButton( - padding: EdgeInsets.fromLTRB(16, 0, 16, 0), - child: const Text('Restart Scan'), - color: CupertinoTheme.of(context) - .primaryColor, // iOS equivalent for a prominent button color - onPressed: () => - Provider.of(context, listen: false) - .startScanning(_openEarable), - ) - : ElevatedButton( - onPressed: () => - Provider.of(context, listen: false) - .startScanning(_openEarable), - style: ButtonStyle( - foregroundColor: MaterialStateProperty.all( - Theme.of(context).colorScheme.primary), - backgroundColor: MaterialStateProperty.all( - Theme.of(context).colorScheme.secondary), - ), - child: const Text('Restart Scan'), - ), + child: ElevatedButton( + onPressed: () => + Provider.of(context, listen: false) + .startScanning(_openEarable), + style: ButtonStyle( + foregroundColor: MaterialStateProperty.all( + Theme.of(context).colorScheme.primary), + backgroundColor: MaterialStateProperty.all( + Theme.of(context).colorScheme.secondary), + ), + child: const Text('Restart Scan'), + ), ) ], )); @@ -132,17 +124,13 @@ class _BLEPageState extends State { if (_openEarable.bleManager.connectedDevice?.id == id) { return Icon( size: 24, - Platform.isIOS ? CupertinoIcons.check_mark : Icons.check, - color: Platform.isIOS - ? CupertinoTheme.of(context).primaryColor - : Theme.of(context).colorScheme.secondary); + Icons.check, + color: Theme.of(context).colorScheme.secondary); } else if (_openEarable.bleManager.connectingDevice?.id == id) { return SizedBox( height: 24, width: 24, - child: Platform.isIOS - ? CupertinoActivityIndicator() - : CircularProgressIndicator(strokeWidth: 2)); + child: CircularProgressIndicator(strokeWidth: 2)); } return const SizedBox.shrink(); } diff --git a/open_earable/lib/ble/ble_tab_bar_page.dart b/open_earable/lib/ble/ble_tab_bar_page.dart index efb9283..c0c9a77 100644 --- a/open_earable/lib/ble/ble_tab_bar_page.dart +++ b/open_earable/lib/ble/ble_tab_bar_page.dart @@ -7,6 +7,7 @@ import 'package:open_earable/ble/ble_controller.dart'; class BLETabBarPage extends StatefulWidget { final int index; + BLETabBarPage({int this.index = 0}); @override @@ -66,103 +67,55 @@ class _BLETabBarPageState extends State @override Widget build(BuildContext context) { - return Platform.isIOS - ? CupertinoPageScaffold( - backgroundColor: CupertinoTheme.of(context).scaffoldBackgroundColor, - navigationBar: CupertinoNavigationBar( - middle: Text("Bluetooth Devices"), - leading: CupertinoNavigationBarBackButton( - onPressed: () { - Navigator.pop(context); - }, - ), - ), - child: CupertinoTabScaffold( - controller: _cupertinoTabController, - tabBar: CupertinoTabBar( - items: [ - BottomNavigationBarItem( - label: 'Left Earable', - icon: ImageIcon( - AssetImage('assets/OpenEarableIconLeft.png'), - size: 40.0), - ), - BottomNavigationBarItem( - label: 'Right Earable', - icon: ImageIcon( - AssetImage('assets/OpenEarableIconRight.png'), - size: 40.0, - ), - ), - ], - ), - tabBuilder: (BuildContext context, int index) { - return CupertinoTabView( - builder: (context) { - return index == 0 - ? BLEPage( - Provider.of(context) - .openEarableLeft, - 0) - : BLEPage( - Provider.of(context) - .openEarableRight, - 1); - }, - ); - }, - )) - : Scaffold( + return Scaffold( + backgroundColor: Theme.of(context).colorScheme.background, + appBar: AppBar( + title: Text("Bluetooth Devices"), + ), + body: DefaultTabController( + length: 2, + child: Scaffold( backgroundColor: Theme.of(context).colorScheme.background, - appBar: AppBar( - title: Text("Bluetooth Devices"), + body: TabBarView( + controller: _tabController, + physics: + NeverScrollableScrollPhysics(), // Disable swipe to change tabs + children: [ + BLEPage( + Provider.of(context).openEarableLeft, + 0), + BLEPage( + Provider.of(context).openEarableRight, + 1), + ], ), - body: DefaultTabController( - length: 2, - child: Scaffold( - backgroundColor: Theme.of(context).colorScheme.background, - body: TabBarView( - controller: _tabController, - physics: - NeverScrollableScrollPhysics(), // Disable swipe to change tabs - children: [ - BLEPage( - Provider.of(context) - .openEarableLeft, - 0), - BLEPage( - Provider.of(context) - .openEarableRight, - 1), - ], + bottomNavigationBar: BottomNavigationBar( + backgroundColor: Theme.of(context).colorScheme.background, + currentIndex: _tabController.index, + onTap: (index) { + setState(() { + _tabController.index = index; + }); + }, + items: [ + BottomNavigationBarItem( + label: 'Left Earable', + icon: ImageIcon( + AssetImage('assets/OpenEarableIconLeft.png'), + size: 40.0, + ), ), - bottomNavigationBar: BottomNavigationBar( - backgroundColor: Theme.of(context).colorScheme.background, - currentIndex: _tabController.index, - onTap: (index) { - setState(() { - _tabController.index = index; - }); - }, - items: [ - BottomNavigationBarItem( - label: 'Left Earable', - icon: ImageIcon( - AssetImage('assets/OpenEarableIconLeft.png'), - size: 40.0, - ), - ), - BottomNavigationBarItem( - label: 'Right Earable', - icon: ImageIcon( - AssetImage('assets/OpenEarableIconRight.png'), - size: 40.0, - ), - ), - ], + BottomNavigationBarItem( + label: 'Right Earable', + icon: ImageIcon( + AssetImage('assets/OpenEarableIconRight.png'), + size: 40.0, + ), ), - ), - )); + ], + ), + ), + )); } } diff --git a/open_earable/lib/ble/v1_ble_connect_view.dart b/open_earable/lib/ble/v1_ble_connect_view.dart index b2956b7..3869137 100644 --- a/open_earable/lib/ble/v1_ble_connect_view.dart +++ b/open_earable/lib/ble/v1_ble_connect_view.dart @@ -17,6 +17,7 @@ class V1BLEPage extends StatefulWidget { class _V1BLEPageState extends State { final String _pageTitle = "Bluetooth Devices"; late OpenEarable _openEarable; + @override void initState() { super.initState(); @@ -27,18 +28,12 @@ class _V1BLEPageState extends State { @override Widget build(BuildContext context) { - return Platform.isIOS - ? CupertinoPageScaffold( - navigationBar: CupertinoNavigationBar(middle: Text(_pageTitle)), - child: SafeArea( - child: _getBody(), - )) - : Scaffold( - backgroundColor: Theme.of(context).colorScheme.background, - appBar: AppBar( - title: Text(_pageTitle), - ), - body: _getBody()); + return Scaffold( + backgroundColor: Theme.of(context).colorScheme.background, + appBar: AppBar( + title: Text(_pageTitle), + ), + body: _getBody()); } Widget _getBody() { @@ -70,8 +65,8 @@ class _V1BLEPageState extends State { ), child: ListView.builder( padding: EdgeInsets.zero, - physics: - const NeverScrollableScrollPhysics(), // Disable scrolling, + physics: const NeverScrollableScrollPhysics(), + // Disable scrolling, shrinkWrap: true, itemCount: controller.discoveredDevices.length, itemBuilder: (BuildContext context, int index) { @@ -115,28 +110,18 @@ class _V1BLEPageState extends State { textAlign: TextAlign.center, ))), Center( - child: Platform.isIOS - ? CupertinoButton( - padding: EdgeInsets.fromLTRB(16, 0, 16, 0), - child: const Text('Restart Scan'), - color: CupertinoTheme.of(context) - .primaryColor, // iOS equivalent for a prominent button color - onPressed: () => - Provider.of(context, listen: false) - .startScanning(_openEarable), - ) - : ElevatedButton( - onPressed: () => - Provider.of(context, listen: false) - .startScanning(_openEarable), - style: ButtonStyle( - foregroundColor: MaterialStateProperty.all( - Theme.of(context).colorScheme.primary), - backgroundColor: MaterialStateProperty.all( - Theme.of(context).colorScheme.secondary), - ), - child: const Text('Restart Scan'), - ), + child: ElevatedButton( + onPressed: () => + Provider.of(context, listen: false) + .startScanning(_openEarable), + style: ButtonStyle( + foregroundColor: MaterialStateProperty.all( + Theme.of(context).colorScheme.primary), + backgroundColor: MaterialStateProperty.all( + Theme.of(context).colorScheme.secondary), + ), + child: const Text('Restart Scan'), + ), ) ], )); @@ -146,17 +131,13 @@ class _V1BLEPageState extends State { if (_openEarable.bleManager.connectedDevice?.id == id) { return Icon( size: 24, - Platform.isIOS ? CupertinoIcons.check_mark : Icons.check, - color: Platform.isIOS - ? CupertinoTheme.of(context).primaryColor - : Theme.of(context).colorScheme.secondary); + Icons.check, + color: Theme.of(context).colorScheme.secondary); } else if (_openEarable.bleManager.connectingDevice?.id == id) { return SizedBox( height: 24, width: 24, - child: Platform.isIOS - ? CupertinoActivityIndicator() - : CircularProgressIndicator(strokeWidth: 2)); + child: CircularProgressIndicator(strokeWidth: 2)); } return const SizedBox.shrink(); } diff --git a/open_earable/lib/controls_tab/controls_tab.dart b/open_earable/lib/controls_tab/controls_tab.dart index 16be42b..0b200b4 100644 --- a/open_earable/lib/controls_tab/controls_tab.dart +++ b/open_earable/lib/controls_tab/controls_tab.dart @@ -31,9 +31,7 @@ class _ControlTabState extends State { Widget build(BuildContext context) { return SingleChildScrollView( child: GestureDetector( - onTap: () => Platform.isIOS - ? FocusScope.of(context).requestFocus(FocusNode()) - : FocusScope.of(context).unfocus(), + onTap: () => FocusScope.of(context).unfocus(), child: Selector( selector: (context, controller) => controller.isV2, builder: (context, isV2, child) { diff --git a/open_earable/lib/controls_tab/views/audio_player.dart b/open_earable/lib/controls_tab/views/audio_player.dart index 02a31ae..2e03577 100644 --- a/open_earable/lib/controls_tab/views/audio_player.dart +++ b/open_earable/lib/controls_tab/views/audio_player.dart @@ -9,6 +9,7 @@ import '../../shared/dynamic_value_picker.dart'; class AudioPlayerCard extends StatefulWidget { final OpenEarable _openEarable; + AudioPlayerCard(this._openEarable); @override @@ -17,6 +18,7 @@ class AudioPlayerCard extends StatefulWidget { class _AudioPlayerCardState extends State { final OpenEarable _openEarable; + _AudioPlayerCardState(this._openEarable); late TextEditingController _filenameTextController; @@ -187,9 +189,7 @@ class _AudioPlayerCardState extends State { updateText(connected); return Card( //Audio Player Card - color: Platform.isIOS - ? CupertinoTheme.of(context).primaryContrastingColor - : Theme.of(context).colorScheme.primary, + color: Theme.of(context).colorScheme.primary, child: Padding( padding: const EdgeInsets.all(16.0), child: Column( @@ -207,9 +207,7 @@ class _AudioPlayerCardState extends State { _getJingleRow(), _getFrequencyRow(), SizedBox(height: 12), - Platform.isIOS - ? _getCupertinoButtonRow(connected) - : _getMaterialButtonRow(connected), + _getMaterialButtonRow(connected), ], ), ), @@ -224,44 +222,24 @@ class _AudioPlayerCardState extends State { return SizedBox( height: 38, width: 44, - child: Platform.isIOS - ? CupertinoRadio( - value: index, - groupValue: - OpenEarableSettings().selectedAudioPlayerRadio, - onChanged: !connected - ? null - : (int? value) { - setState(() { - OpenEarableSettings().selectedAudioPlayerRadio = - value ?? 0; - }); - }, - activeColor: CupertinoTheme.of(context).primaryColor, - fillColor: - CupertinoTheme.of(context).primaryContrastingColor, - inactiveColor: - CupertinoTheme.of(context).primaryContrastingColor, - ) - : Radio( - value: index, - groupValue: - OpenEarableSettings().selectedAudioPlayerRadio, - onChanged: !connected - ? null - : (int? value) { - setState(() { - OpenEarableSettings().selectedAudioPlayerRadio = - value ?? 0; - }); - }, - fillColor: MaterialStateProperty.resolveWith((states) { - if (states.contains(MaterialState.selected)) { - return Theme.of(context).colorScheme.secondary; - } - return Colors.grey; - }), - )); + child: Radio( + value: index, + groupValue: OpenEarableSettings().selectedAudioPlayerRadio, + onChanged: !connected + ? null + : (int? value) { + setState(() { + OpenEarableSettings().selectedAudioPlayerRadio = + value ?? 0; + }); + }, + fillColor: MaterialStateProperty.resolveWith((states) { + if (states.contains(MaterialState.selected)) { + return Theme.of(context).colorScheme.secondary; + } + return Colors.grey; + }), + )); }); } @@ -294,54 +272,26 @@ class _AudioPlayerCardState extends State { return Selector( selector: (_, controller) => controller.connected, builder: (context, connected, child) { - if (Platform.isIOS) { - return CupertinoTextField( - cursorColor: Colors.blue, - controller: textController, - obscureText: false, - placeholder: placeholder, - style: TextStyle( - color: connected ? Colors.black : Colors.grey[700], - ), - padding: EdgeInsets.fromLTRB(8, 0, 0, 0), - textAlignVertical: TextAlignVertical.center, - textInputAction: TextInputAction.done, - onSubmitted: (_) { - FocusScope.of(context).requestFocus(FocusNode()); - }, - decoration: BoxDecoration( - color: connected ? Colors.white : Colors.grey, - borderRadius: BorderRadius.circular(4.0), - ), - placeholderStyle: TextStyle( - color: connected ? Colors.black : Colors.grey, - ), - keyboardType: keyboardType, - maxLength: maxLength, - maxLines: 1, - ); - } else { - return TextField( - controller: textController, - obscureText: false, - enabled: connected, - style: + return TextField( + controller: textController, + obscureText: false, + enabled: connected, + style: + TextStyle(color: connected ? Colors.black : Colors.grey[700]), + decoration: InputDecoration( + labelText: placeholder, + contentPadding: EdgeInsets.fromLTRB(8, 0, 0, 0), + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.never, + labelStyle: TextStyle(color: connected ? Colors.black : Colors.grey[700]), - decoration: InputDecoration( - labelText: placeholder, - contentPadding: EdgeInsets.fromLTRB(8, 0, 0, 0), - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.never, - labelStyle: TextStyle( - color: connected ? Colors.black : Colors.grey[700]), - filled: true, - fillColor: connected ? Colors.white : Colors.grey, - ), - keyboardType: keyboardType, - maxLength: maxLength, - maxLines: 1, - ); - } + filled: true, + fillColor: connected ? Colors.white : Colors.grey, + ), + keyboardType: keyboardType, + maxLength: maxLength, + maxLines: 1, + ); }); } diff --git a/open_earable/lib/controls_tab/views/connect.dart b/open_earable/lib/controls_tab/views/connect.dart index 4f9e803..781b77c 100644 --- a/open_earable/lib/controls_tab/views/connect.dart +++ b/open_earable/lib/controls_tab/views/connect.dart @@ -69,9 +69,7 @@ class _ConnectCard extends State { return Padding( padding: const EdgeInsets.symmetric(horizontal: 5.0), child: Card( - color: Platform.isIOS - ? CupertinoTheme.of(context).primaryContrastingColor - : Theme.of(context).colorScheme.primary, + color: Theme.of(context).colorScheme.primary, child: Padding( padding: const EdgeInsets.fromLTRB(16, 12, 16, 16), child: Column( @@ -93,38 +91,19 @@ class _ConnectCard extends State { }), Row( children: [ - Platform.isIOS - ? CupertinoCheckbox( - value: _autoConnectEnabled, - onChanged: (value) { - setState(() { - _autoConnectEnabled = value ?? false; - }); - _startAutoConnectScan(); - if (value != null) - prefs.setBool("autoConnectEnabled", value); - }, - activeColor: _autoConnectEnabled - ? CupertinoTheme.of(context).primaryColor - : CupertinoTheme.of(context) - .primaryContrastingColor, - checkColor: CupertinoTheme.of(context) - .primaryContrastingColor, - ) - : Checkbox( - checkColor: - Theme.of(context).colorScheme.primary, - //fillColor: Theme.of(context).colorScheme.primary, - value: _autoConnectEnabled, - onChanged: (value) { - setState(() { - _autoConnectEnabled = value ?? false; - }); - _startAutoConnectScan(); - if (value != null) - prefs.setBool("autoConnectEnabled", value); - }, - ), + Checkbox( + checkColor: Theme.of(context).colorScheme.primary, + //fillColor: Theme.of(context).colorScheme.primary, + value: _autoConnectEnabled, + onChanged: (value) { + setState(() { + _autoConnectEnabled = value ?? false; + }); + _startAutoConnectScan(); + if (value != null) + prefs.setBool("autoConnectEnabled", value); + }, + ), Text( "Connect to OpenEarable automatically", style: TextStyle( @@ -143,8 +122,8 @@ class _ConnectCard extends State { bleController.earableSOCLeft, builder: (context, socLeft, child) { return _getEarableSelectButton( - imagePath: - "assets/OpenEarableV2-L.png", // path to your image asset + imagePath: "assets/OpenEarableV2-L.png", + // path to your image asset isSelected: OpenEarableSettingsV2() .selectedButtonIndex == 0, @@ -191,32 +170,21 @@ class _ConnectCard extends State { Widget _getConnectButton(BuildContext context, String side) { return Container( - height: 37, - width: double.infinity, - child: !Platform.isIOS - ? ElevatedButton( - onPressed: () => _connectButtonAction(context, side), - style: ElevatedButton.styleFrom( - backgroundColor: Color(0xff77F2A1), - foregroundColor: Colors.black, - ), - child: Text("Connect"), - ) - : CupertinoButton( - padding: EdgeInsets.zero, - color: CupertinoTheme.of(context).primaryColor, - child: Text("Connect"), - onPressed: () => _connectButtonAction(context, side)), - ); + height: 37, + width: double.infinity, + child: ElevatedButton( + onPressed: () => _connectButtonAction(context, side), + style: ElevatedButton.styleFrom( + backgroundColor: Color(0xff77F2A1), + foregroundColor: Colors.black, + ), + child: Text("Connect"), + )); } _connectButtonAction(BuildContext context, String side) { - Navigator.of(context).push(Platform.isIOS - ? CupertinoPageRoute( - builder: (context) => BLETabBarPage(index: side == "Left" ? 0 : 1)) - : MaterialPageRoute( - builder: (context) => - BLETabBarPage(index: side == "Left" ? 0 : 1))); + Navigator.of(context).push(MaterialPageRoute( + builder: (context) => BLETabBarPage(index: side == "Left" ? 0 : 1))); } void _tryAutoconnect(List devices) async { @@ -278,110 +246,59 @@ class _ConnectCard extends State { required onPressed, required int? percentage, }) { - if (Platform.isIOS) { - return CupertinoButton( - color: Color.fromARGB(255, 83, 81, 91), - onPressed: onPressed, - padding: - EdgeInsets.zero, // Remove padding to use the entire container space - child: Container( - padding: EdgeInsets.all(8.0), // Internal padding within the button - decoration: BoxDecoration( - borderRadius: BorderRadius.circular( - 7.0), // Slightly smaller radius for the inner border - border: Border.all( + return ElevatedButton( + onPressed: onPressed, + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all( + Color.fromARGB(255, 83, 81, 91)), // Adjust the color as needed + shape: MaterialStateProperty.all( + RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10.0), + side: BorderSide( color: isSelected - ? CupertinoTheme.of(context).primaryColor + ? Theme.of(context).colorScheme.secondary : Colors.transparent, width: 3, ), ), - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "${openEarable.bleManager.connectedDevice?.name ?? "OpenEarable-XXXX"}${_batteryPercentageString(percentage)}", - style: TextStyle( - color: Colors.white, - fontSize: 15.0, - ), - ), - SizedBox(height: 8), - Image.asset(imagePath, fit: BoxFit.fill), - SizedBox(height: 8), - Text( - "Firmware: ${openEarable.deviceFirmwareVersion ?? "X.X.X"}", - style: TextStyle( - color: Colors.white, - fontSize: 15.0, - ), - ), - Text( - "Hardware: ${openEarable.deviceHardwareVersion ?? "X.X.X"}", - style: TextStyle( - color: Colors.white, - fontSize: 15.0, - ), - ), - ], - ), ), - ); - } else { - return ElevatedButton( - onPressed: onPressed, - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( - Color.fromARGB(255, 83, 81, 91)), // Adjust the color as needed - shape: MaterialStateProperty.all( - RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10.0), - side: BorderSide( - color: isSelected - ? Theme.of(context).colorScheme.secondary - : Colors.transparent, - width: 3, + padding: MaterialStateProperty.all( + EdgeInsets.zero), // Adjust padding if necessary + ), + child: Container( + padding: EdgeInsets.all(8.0), // Padding inside the button for content + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "${openEarable.bleManager.connectedDevice?.name ?? "OpenEarable-XXXX"}${_batteryPercentageString(percentage)}", + // Assuming _openEarable and bleController are accessible + style: TextStyle( + color: Colors.white, + fontSize: 15.0, ), ), - ), - padding: MaterialStateProperty.all( - EdgeInsets.zero), // Adjust padding if necessary - ), - child: Container( - padding: EdgeInsets.all(8.0), // Padding inside the button for content - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "${openEarable.bleManager.connectedDevice?.name ?? "OpenEarable-XXXX"}${_batteryPercentageString(percentage)}", // Assuming _openEarable and bleController are accessible - style: TextStyle( - color: Colors.white, - fontSize: 15.0, - ), + SizedBox(height: 8), + Image.asset(imagePath, fit: BoxFit.fill), + SizedBox(height: 8), + Text( + "Firmware: ${openEarable.deviceFirmwareVersion ?? "X.X.X"}", + style: TextStyle( + color: Colors.white, + fontSize: 15.0, ), - SizedBox(height: 8), - Image.asset(imagePath, fit: BoxFit.fill), - SizedBox(height: 8), - Text( - "Firmware: ${openEarable.deviceFirmwareVersion ?? "X.X.X"}", - style: TextStyle( - color: Colors.white, - fontSize: 15.0, - ), - ), - Text( - "Hardware: ${openEarable.deviceHardwareVersion ?? "X.X.X"}", - style: TextStyle( - color: Colors.white, - fontSize: 15.0, - ), + ), + Text( + "Hardware: ${openEarable.deviceHardwareVersion ?? "X.X.X"}", + style: TextStyle( + color: Colors.white, + fontSize: 15.0, ), - ], - ), + ), + ], ), - ); - } + ), + ); } } diff --git a/open_earable/lib/controls_tab/views/led_color.dart b/open_earable/lib/controls_tab/views/led_color.dart index e413fd0..b8d48e5 100644 --- a/open_earable/lib/controls_tab/views/led_color.dart +++ b/open_earable/lib/controls_tab/views/led_color.dart @@ -217,9 +217,7 @@ class _LEDColorCardState extends State { padding: const EdgeInsets.symmetric(horizontal: 5.0), child: Card( //LED Color Picker Card - color: Platform.isIOS - ? CupertinoTheme.of(context).primaryContrastingColor - : Theme.of(context).colorScheme.primary, + color: Theme.of(context).colorScheme.primary, child: Padding( padding: const EdgeInsets.all(16.0), child: Column( @@ -254,64 +252,39 @@ class _LEDColorCardState extends State { SizedBox( width: 66, height: 36, - child: Platform.isIOS - ? CupertinoButton( - padding: EdgeInsets.zero, - child: Text('Set', - style: TextStyle( - color: connected - ? Colors.white - : null)), - onPressed: connected ? _setLEDColor : null, - color: Color(0xff53515b), - ) - : ElevatedButton( - onPressed: connected ? _setLEDColor : null, - style: ElevatedButton.styleFrom( - backgroundColor: Color( - 0xff53515b), // Set the background color to grey - foregroundColor: Colors.white), - child: Text('Set'), - ), + child: ElevatedButton( + onPressed: connected ? _setLEDColor : null, + style: ElevatedButton.styleFrom( + backgroundColor: Color(0xff53515b), + // Set the background color to grey + foregroundColor: Colors.white), + child: Text('Set'), + ), ), SizedBox(width: 5), SizedBox( width: 66, height: 36, - child: Platform.isIOS - ? CupertinoButton( - onPressed: - connected ? _startRainbowMode : null, - color: Color(0xff53515b), - padding: EdgeInsets.zero, - child: Text("🦄")) - : ElevatedButton( - onPressed: - connected ? _startRainbowMode : null, - style: ElevatedButton.styleFrom( - backgroundColor: Color( - 0xff53515b), // Set the background color to grey - foregroundColor: Colors.white), - child: Text("🦄"), - )), + child: ElevatedButton( + onPressed: connected ? _startRainbowMode : null, + style: ElevatedButton.styleFrom( + backgroundColor: Color(0xff53515b), + // Set the background color to grey + foregroundColor: Colors.white), + child: Text("🦄"), + )), Spacer(), SizedBox( width: 66, height: 36, - child: Platform.isIOS - ? CupertinoButton( - onPressed: connected ? _turnLEDoff : null, - padding: EdgeInsets.zero, - color: Color(0xfff27777), - child: Text('Off')) - : ElevatedButton( - onPressed: connected ? _turnLEDoff : null, - style: ElevatedButton.styleFrom( - backgroundColor: Color(0xfff27777), - foregroundColor: Colors.black, - ), - child: Text('Off'), - ), + child: ElevatedButton( + onPressed: connected ? _turnLEDoff : null, + style: ElevatedButton.styleFrom( + backgroundColor: Color(0xfff27777), + foregroundColor: Colors.black, + ), + child: Text('Off'), + ), ) ], ), diff --git a/open_earable/lib/controls_tab/views/sensor_control/sensor_control.dart b/open_earable/lib/controls_tab/views/sensor_control/sensor_control.dart index 45e7298..1ec8c3e 100644 --- a/open_earable/lib/controls_tab/views/sensor_control/sensor_control.dart +++ b/open_earable/lib/controls_tab/views/sensor_control/sensor_control.dart @@ -95,9 +95,7 @@ class _SensorControlCardState extends State { padding: const EdgeInsets.symmetric(horizontal: 5.0), child: Card( //Audio Player Card - color: Platform.isIOS - ? CupertinoTheme.of(context).primaryContrastingColor - : Theme.of(context).colorScheme.primary, + color: Theme.of(context).colorScheme.primary, child: Padding( padding: const EdgeInsets.fromLTRB(16, 12, 16, 16), child: Column( @@ -113,7 +111,8 @@ class _SensorControlCardState extends State { fontWeight: FontWeight.bold, ), ), - Spacer(), // This matches the Spacer in your DynamicValuePicker row + Spacer(), + // This matches the Spacer in your DynamicValuePicker row SizedBox( width: 70, height: 37, @@ -125,9 +124,8 @@ class _SensorControlCardState extends State { color: Color.fromRGBO(168, 168, 172, 1.0))), ), ), - SizedBox( - width: - 8), // Space between the first title and the second title + SizedBox(width: 8), + // Space between the first title and the second title SizedBox( width: 70, height: 37, @@ -139,7 +137,8 @@ class _SensorControlCardState extends State { color: Color.fromRGBO(168, 168, 172, 1.0))), ), ), - SizedBox(width: 8), // Space before the "Hz" label + SizedBox(width: 8), + // Space before the "Hz" label Text("Hz", textAlign: TextAlign.left, style: @@ -181,41 +180,24 @@ class _SensorControlCardState extends State { Expanded( child: SizedBox( height: 37, - child: Platform.isIOS - ? CupertinoButton( - padding: EdgeInsets.zero, - onPressed: - Provider.of(context) - .connected - ? () => _writeSensorConfigs() - : null, - color: Provider.of(context) + child: ElevatedButton( + onPressed: + Provider.of(context).connected + ? _writeSensorConfigs + : null, + style: ElevatedButton.styleFrom( + backgroundColor: + Provider.of(context) .connected - ? CupertinoTheme.of(context).primaryColor + ? Theme.of(context).colorScheme.secondary : Colors.grey, - child: Text("Set Configuration"), - ) - : ElevatedButton( - onPressed: - Provider.of(context) - .connected - ? _writeSensorConfigs - : null, - style: ElevatedButton.styleFrom( - backgroundColor: - Provider.of(context) - .connected - ? Theme.of(context) - .colorScheme - .secondary - : Colors.grey, - foregroundColor: Colors.black, - enableFeedback: - Provider.of(context) - .connected, - ), - child: Text("Set Configuration"), - ), + foregroundColor: Colors.black, + enableFeedback: + Provider.of(context) + .connected, + ), + child: Text("Set Configuration"), + ), ), ), ], diff --git a/open_earable/lib/controls_tab/views/sensor_control/sensor_control_row.dart b/open_earable/lib/controls_tab/views/sensor_control/sensor_control_row.dart index 1be4ece..d98bc5c 100644 --- a/open_earable/lib/controls_tab/views/sensor_control/sensor_control_row.dart +++ b/open_earable/lib/controls_tab/views/sensor_control/sensor_control_row.dart @@ -8,47 +8,36 @@ import 'package:open_earable/ble/ble_controller.dart'; class SensorControlRow extends StatefulWidget { final String _sensorName; + SensorControlRow(this._sensorName); + @override _SensorControlRow createState() => _SensorControlRow(_sensorName); } class _SensorControlRow extends State { String _sensorName; + _SensorControlRow(this._sensorName); + @override Widget build(BuildContext context) { SensorSettings sensorSettings = Provider.of(context, listen: true); return Row( children: [ - Platform.isIOS - ? CupertinoCheckbox( - value: sensorSettings.sensorSelected, - onChanged: Provider.of(context).connected - ? (value) { - setState(() { - sensorSettings.sensorSelected = value ?? false; - }); - } - : null, - activeColor: sensorSettings.sensorSelected - ? CupertinoTheme.of(context).primaryColor - : CupertinoTheme.of(context).primaryContrastingColor, - checkColor: CupertinoTheme.of(context).primaryContrastingColor, - ) - : Checkbox( - checkColor: Theme.of(context).colorScheme.primary, - fillColor: MaterialStateProperty.resolveWith(_getCheckboxColor), - value: sensorSettings.sensorSelected, - onChanged: Provider.of(context).connected - ? (value) { - setState(() { - sensorSettings.sensorSelected = value ?? false; - }); - } - : null, - ), + Checkbox( + checkColor: Theme.of(context).colorScheme.primary, + fillColor: MaterialStateProperty.resolveWith(_getCheckboxColor), + value: sensorSettings.sensorSelected, + onChanged: Provider.of(context).connected + ? (value) { + setState(() { + sensorSettings.sensorSelected = value ?? false; + }); + } + : null, + ), Text( _sensorName, style: TextStyle( diff --git a/open_earable/lib/controls_tab/views/v1_connect.dart b/open_earable/lib/controls_tab/views/v1_connect.dart index 3891470..478ec02 100644 --- a/open_earable/lib/controls_tab/views/v1_connect.dart +++ b/open_earable/lib/controls_tab/views/v1_connect.dart @@ -54,9 +54,7 @@ class _ConnectCard extends State { return Padding( padding: const EdgeInsets.symmetric(horizontal: 5.0), child: Card( - color: Platform.isIOS - ? CupertinoTheme.of(context).primaryContrastingColor - : Theme.of(context).colorScheme.primary, + color: Theme.of(context).colorScheme.primary, child: Padding( padding: const EdgeInsets.all(16.0), child: Consumer( @@ -76,37 +74,19 @@ class _ConnectCard extends State { ), Row( children: [ - Platform.isIOS - ? CupertinoCheckbox( - value: _autoConnectEnabled, - onChanged: (value) => { - setState(() { - _autoConnectEnabled = value ?? false; - _startAutoConnectScan(); - if (value != null) - prefs.setBool("autoConnectEnabled", value); - }) - }, - activeColor: _autoConnectEnabled - ? CupertinoTheme.of(context).primaryColor - : CupertinoTheme.of(context) - .primaryContrastingColor, - checkColor: CupertinoTheme.of(context) - .primaryContrastingColor, - ) - : Checkbox( - checkColor: Theme.of(context).colorScheme.primary, - //fillColor: Theme.of(context).colorScheme.primary, - value: _autoConnectEnabled, - onChanged: (value) => { - setState(() { - _autoConnectEnabled = value ?? false; - _startAutoConnectScan(); - if (value != null) - prefs.setBool("autoConnectEnabled", value); - }) - }, - ), + Checkbox( + checkColor: Theme.of(context).colorScheme.primary, + //fillColor: Theme.of(context).colorScheme.primary, + value: _autoConnectEnabled, + onChanged: (value) => { + setState(() { + _autoConnectEnabled = value ?? false; + _startAutoConnectScan(); + if (value != null) + prefs.setBool("autoConnectEnabled", value); + }) + }, + ), Text( "Connect to OpenEarable automatically", style: TextStyle( @@ -184,45 +164,27 @@ class _ConnectCard extends State { child: Container( height: 37, width: double.infinity, - child: !Platform.isIOS - ? ElevatedButton( - onPressed: () => _connectButtonAction(context), - style: ElevatedButton.styleFrom( - backgroundColor: !_openEarable.bleManager.connected - ? Color(0xff77F2A1) - : Color(0xfff27777), - foregroundColor: Colors.black, - ), - child: Text("Connect"), - ) - : CupertinoButton( - padding: EdgeInsets.zero, - color: CupertinoTheme.of(context).primaryColor, - child: Text("Connect"), - onPressed: () => _connectButtonAction(context))), + child: ElevatedButton( + onPressed: () => _connectButtonAction(context), + style: ElevatedButton.styleFrom( + backgroundColor: !_openEarable.bleManager.connected + ? Color(0xff77F2A1) + : Color(0xfff27777), + foregroundColor: Colors.black, + ), + child: Text("Connect"), + )), ); } _connectButtonAction(BuildContext context) { - 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(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)))); + Navigator.of(context).push(MaterialPageRoute( + builder: (context) => Scaffold( + backgroundColor: Theme.of(context).colorScheme.background, + appBar: AppBar( + title: Text("Bluetooth Devices"), + ), + body: BLEPage(_openEarable, 0)))); } void _tryAutoconnect( diff --git a/open_earable/lib/controls_tab/views/v1_sensor_configuration.dart b/open_earable/lib/controls_tab/views/v1_sensor_configuration.dart index 3bcbece..7187976 100644 --- a/open_earable/lib/controls_tab/views/v1_sensor_configuration.dart +++ b/open_earable/lib/controls_tab/views/v1_sensor_configuration.dart @@ -96,9 +96,7 @@ class _V1SensorConfigurationCardState extends State { padding: const EdgeInsets.symmetric(horizontal: 5.0), child: Card( //Audio Player Card - color: Platform.isIOS - ? CupertinoTheme.of(context).primaryContrastingColor - : Theme.of(context).colorScheme.primary, + color: Theme.of(context).colorScheme.primary, child: Padding( padding: const EdgeInsets.all(16.0), child: Column( @@ -157,41 +155,24 @@ class _V1SensorConfigurationCardState extends State { Expanded( child: SizedBox( height: 37, - child: Platform.isIOS - ? CupertinoButton( - padding: EdgeInsets.zero, - onPressed: - Provider.of(context) - .connected - ? () => _writeSensorConfigs() - : null, - color: Provider.of(context) + child: ElevatedButton( + onPressed: + Provider.of(context).connected + ? _writeSensorConfigs + : null, + style: ElevatedButton.styleFrom( + backgroundColor: + Provider.of(context) .connected - ? CupertinoTheme.of(context).primaryColor + ? Theme.of(context).colorScheme.secondary : Colors.grey, - child: Text("Set Configuration"), - ) - : ElevatedButton( - onPressed: - Provider.of(context) - .connected - ? _writeSensorConfigs - : null, - style: ElevatedButton.styleFrom( - backgroundColor: - Provider.of(context) - .connected - ? Theme.of(context) - .colorScheme - .secondary - : Colors.grey, - foregroundColor: Colors.black, - enableFeedback: - Provider.of(context) - .connected, - ), - child: Text("Set Configuration"), - ), + foregroundColor: Colors.black, + enableFeedback: + Provider.of(context) + .connected, + ), + child: Text("Set Configuration"), + ), ), ), ], @@ -212,25 +193,14 @@ class _V1SensorConfigurationCardState extends State { Function(String) changeSelection) { return Row( children: [ - Platform.isIOS - ? CupertinoCheckbox( - value: settingSelected, - onChanged: Provider.of(context).connected - ? changeBool - : null, - activeColor: settingSelected - ? CupertinoTheme.of(context).primaryColor - : CupertinoTheme.of(context).primaryContrastingColor, - checkColor: CupertinoTheme.of(context).primaryContrastingColor, - ) - : Checkbox( - checkColor: Theme.of(context).colorScheme.primary, - fillColor: MaterialStateProperty.resolveWith(_getCheckboxColor), - value: settingSelected, - onChanged: Provider.of(context).connected - ? changeBool - : null, - ), + Checkbox( + checkColor: Theme.of(context).colorScheme.primary, + fillColor: MaterialStateProperty.resolveWith(_getCheckboxColor), + value: settingSelected, + onChanged: Provider.of(context).connected + ? changeBool + : null, + ), Text( sensorName, style: TextStyle( diff --git a/open_earable/lib/main.dart b/open_earable/lib/main.dart index 32bf2a6..0032a19 100644 --- a/open_earable/lib/main.dart +++ b/open_earable/lib/main.dart @@ -24,28 +24,11 @@ void main() => runApp(ChangeNotifierProvider( class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - if (Platform.isIOS) { - return CupertinoApp( - locale: const Locale('en', 'US'), - localizationsDelegates: [ - GlobalMaterialLocalizations.delegate, - GlobalWidgetsLocalizations.delegate, - GlobalCupertinoLocalizations.delegate, - ], - supportedLocales: [ - const Locale('en', 'US'), - ], - title: '🦻 OpenEarable', - theme: cupertinoTheme, - home: MyHomePage(), - ); - } else { - return MaterialApp( - title: '🦻 OpenEarable', - theme: materialTheme, - home: MyHomePage(), - ); - } + return MaterialApp( + title: '🦻 OpenEarable', + theme: materialTheme, + home: MyHomePage(), + ); } } @@ -60,6 +43,7 @@ class _MyHomePageState extends State { late bool alertOpen; late List _widgetOptions; StreamSubscription? blePermissionSubscription; + @override void initState() { super.initState(); @@ -106,77 +90,40 @@ class _MyHomePageState extends State { } void _showBluetoothAlert(BuildContext context) { - if (Platform.isIOS) { - showCupertinoModalPopup( - context: context, - barrierDismissible: false, - builder: (BuildContext context) => CupertinoTheme( - data: CupertinoThemeData(), - child: CupertinoAlertDialog( - title: const Text('Bluetooth disabled'), - content: const Text( - "Please make sure your device's bluetooth and location services are turned on and this app has been granted permission to use them in the app's settings.\nThis alert can only be closed if these requirements are fulfilled."), - actions: [ - CupertinoDialogAction( - isDefaultAction: false, - onPressed: () { - AppSettings.openAppSettings(); - }, - child: Text( - 'Open App Settings', - ), - ), - CupertinoDialogAction( - isDefaultAction: true, - onPressed: () { - if (flutterReactiveBle.status == BleStatus.ready) { - alertOpen = false; - Navigator.of(context).pop(); - } - }, - child: Text( - 'OK', - ), - ), - ], - ), - )); - } else { - showDialog( - context: context, - barrierDismissible: false, - builder: (BuildContext context) { - return AlertDialog( - title: Text("Bluetooth disabled"), - content: Text( - "Please make sure your device's bluetooth and location services are turned on and this app has been granted permission to use them in the app's settings.\nThis alert can only be closed if these requirements are fulfilled."), - actions: [ - TextButton( - child: Text( - 'Open App Settings', - style: TextStyle( - color: Theme.of(context).colorScheme.onBackground), - ), - onPressed: () { - AppSettings.openAppSettings(); - }, - ), - TextButton( - child: Text('OK', - style: TextStyle( - color: Theme.of(context).colorScheme.onBackground)), - onPressed: () { - if (flutterReactiveBle.status == BleStatus.ready) { - alertOpen = false; - Navigator.of(context).pop(); - } - }, + showDialog( + context: context, + barrierDismissible: false, + builder: (BuildContext context) { + return AlertDialog( + title: Text("Bluetooth disabled"), + content: Text( + "Please make sure your device's bluetooth and location services are turned on and this app has been granted permission to use them in the app's settings.\nThis alert can only be closed if these requirements are fulfilled."), + actions: [ + TextButton( + child: Text( + 'Open App Settings', + style: TextStyle( + color: Theme.of(context).colorScheme.onBackground), ), - ], - ); - }, - ); - } + onPressed: () { + AppSettings.openAppSettings(); + }, + ), + TextButton( + child: Text('OK', + style: TextStyle( + color: Theme.of(context).colorScheme.onBackground)), + onPressed: () { + if (flutterReactiveBle.status == BleStatus.ready) { + alertOpen = false; + Navigator.of(context).pop(); + } + }, + ), + ], + ); + }, + ); } void _onItemTapped(int index) { @@ -187,157 +134,61 @@ class _MyHomePageState extends State { @override Widget build(BuildContext context) { - if (Platform.isIOS) { - return CupertinoTabScaffold( - tabBar: CupertinoTabBar( - backgroundColor: CupertinoTheme.of(context).scaffoldBackgroundColor, - items: [ - BottomNavigationBarItem( - icon: Icon(CupertinoIcons.gear), - label: 'Controls', - ), - BottomNavigationBarItem( - icon: Icon(CupertinoIcons.heart), - label: 'Sensor Data', - ), - BottomNavigationBarItem( - icon: Icon(CupertinoIcons.square_grid_2x2), - label: 'Apps', + return Scaffold( + backgroundColor: Theme.of(context).colorScheme.background, + appBar: AppBar( + title: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SizedBox(width: 50), + Image.asset( + 'assets/earable_logo.png', + width: 24, + height: 24, ), + SizedBox(width: 8), + Text('OpenEarable'), ], - currentIndex: _selectedIndex, - onTap: _onItemTapped, - ), - tabBuilder: (BuildContext context, int index) { - return CupertinoPageScaffold( - navigationBar: CupertinoNavigationBar( - middle: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Image.asset( - 'assets/earable_logo.png', - width: 24, - height: 24, - ), - SizedBox(width: 8), - Text('OpenEarable'), - ], - ), - trailing: CupertinoButton( - padding: EdgeInsets.zero, - child: Icon( - CupertinoIcons.bluetooth, - color: CupertinoTheme.of(context).primaryColor, - ), - onPressed: () { - if (Provider.of(context, listen: false) - .isV2) { - Navigator.of(context).push(Platform.isIOS - ? CupertinoPageRoute( - builder: (context) => BLETabBarPage( - index: OpenEarableSettingsV2() - .selectedButtonIndex)) - : MaterialPageRoute( - builder: (context) => BLETabBarPage( - index: OpenEarableSettingsV2() - .selectedButtonIndex))); - } else { - 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(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(context, - listen: false) - .openEarableLeft, - 0)))); - } - }, - ), - ), - backgroundColor: CupertinoTheme.of(context).scaffoldBackgroundColor, - child: _widgetOptions.elementAt(index), - ); - }, - ); - } else { - return Scaffold( + )), + actions: [ + IconButton( + icon: Icon(Icons.bluetooth, + color: Theme.of(context).colorScheme.secondary), + onPressed: () { + Navigator.of(context).push(MaterialPageRoute( + builder: (context) => BLETabBarPage( + index: OpenEarableSettingsV2().selectedButtonIndex))); + }, + ), + ], + ), + body: _widgetOptions.elementAt(_selectedIndex), + bottomNavigationBar: BottomNavigationBar( backgroundColor: Theme.of(context).colorScheme.background, - appBar: AppBar( - title: Center( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SizedBox(width: 50), - Image.asset( - 'assets/earable_logo.png', - width: 24, - height: 24, - ), - SizedBox(width: 8), - Text('OpenEarable'), - ], - )), - actions: [ - IconButton( - icon: Icon(Icons.bluetooth, - color: Theme.of(context).colorScheme.secondary), - onPressed: () { - Navigator.of(context).push(Platform.isIOS - ? CupertinoPageRoute( - builder: (context) => BLETabBarPage( - index: OpenEarableSettingsV2().selectedButtonIndex)) - : MaterialPageRoute( - builder: (context) => BLETabBarPage( - index: - OpenEarableSettingsV2().selectedButtonIndex))); - }, - ), - ], - ), - body: _widgetOptions.elementAt(_selectedIndex), - bottomNavigationBar: BottomNavigationBar( - backgroundColor: Theme.of(context).colorScheme.background, - items: const [ - BottomNavigationBarItem( - icon: Padding( - padding: EdgeInsets.only(bottom: 3.0), - child: Icon( - OpenEarableIcon.icon, - size: 20.0, - ), + items: const [ + BottomNavigationBarItem( + icon: Padding( + padding: EdgeInsets.only(bottom: 3.0), + child: Icon( + OpenEarableIcon.icon, + size: 20.0, ), - label: 'Controls', - ), - BottomNavigationBarItem( - icon: Icon(Icons.monitor_heart_outlined), - label: 'Sensor Data', ), - BottomNavigationBarItem( - icon: Icon(Icons.apps), - label: 'Apps', - ), - ], - currentIndex: _selectedIndex, - onTap: _onItemTapped, - ), - ); - } + label: 'Controls', + ), + BottomNavigationBarItem( + icon: Icon(Icons.monitor_heart_outlined), + label: 'Sensor Data', + ), + BottomNavigationBarItem( + icon: Icon(Icons.apps), + label: 'Apps', + ), + ], + currentIndex: _selectedIndex, + onTap: _onItemTapped, + ), + ); } } diff --git a/open_earable/lib/shared/dynamic_value_picker.dart b/open_earable/lib/shared/dynamic_value_picker.dart index 67b191f..c1f7d8b 100644 --- a/open_earable/lib/shared/dynamic_value_picker.dart +++ b/open_earable/lib/shared/dynamic_value_picker.dart @@ -21,61 +21,36 @@ class DynamicValuePicker extends StatelessWidget { @override Widget build(BuildContext context) { - if (Platform.isIOS) { - return CupertinoButton( - borderRadius: BorderRadius.all(Radius.circular(4.0)), - disabledColor: Colors.grey[200]!, - color: this.isFakeDisabled || !isConnected - ? CupertinoColors.systemGrey - : CupertinoColors.white, - padding: EdgeInsets.fromLTRB(8, 0, 0, 0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - currentValue, - style: TextStyle( - color: this.isFakeDisabled || !isConnected - ? Colors.grey[700] - : Colors.black, - ), + return DropdownButton( + dropdownColor: Colors.white, + alignment: Alignment.centerRight, + value: currentValue, + onChanged: isConnected + ? (String? newValue) { + onValueChange(newValue!); + } + : null, + items: options.map((String value) { + return DropdownMenuItem( + alignment: Alignment.centerRight, + value: value, + child: Text( + value, + style: TextStyle( + color: this.isFakeDisabled || !isConnected + ? Colors.grey[700] + : Colors.black, ), - ], - ), - onPressed: () => isConnected ? _showCupertinoPicker() : null, - ); - } else { - return DropdownButton( - dropdownColor: Colors.white, - alignment: Alignment.centerRight, - value: currentValue, - onChanged: isConnected - ? (String? newValue) { - onValueChange(newValue!); - } - : null, - items: options.map((String value) { - return DropdownMenuItem( - alignment: Alignment.centerRight, - value: value, - child: Text( - value, - style: TextStyle( - color: this.isFakeDisabled || !isConnected - ? Colors.grey[700] - : Colors.black, - ), - textAlign: TextAlign.end, - ), - ); - }).toList(), - underline: Container(), - icon: Icon( - Icons.arrow_drop_down, - color: isConnected ? Colors.black : Colors.grey[700], - ), - ); - } + textAlign: TextAlign.end, + ), + ); + }).toList(), + underline: Container(), + icon: Icon( + Icons.arrow_drop_down, + color: isConnected ? Colors.black : Colors.grey[700], + ), + ); } void _showCupertinoPicker() { @@ -90,7 +65,8 @@ class DynamicValuePicker extends StatelessWidget { child: CupertinoPicker( scrollController: scrollController, backgroundColor: isConnected ? Colors.white : Colors.grey[200], - itemExtent: 32, // Height of each item + itemExtent: 32, + // Height of each item onSelectedItemChanged: (int index) { String newValue = options[index]; onValueChange(newValue); From 74c1df0ff9fd820da12eb3c9b13b848679f9d84f Mon Sep 17 00:00:00 2001 From: Jonas Greifenhain Date: Sun, 22 Sep 2024 12:28:05 +0200 Subject: [PATCH 04/10] Set Android permissions --- .../android/app/src/main/AndroidManifest.xml | 10 ++++++++++ .../android/app/src/profile/AndroidManifest.xml | 12 ------------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/open_earable/android/app/src/main/AndroidManifest.xml b/open_earable/android/app/src/main/AndroidManifest.xml index 0fd75de..727800b 100644 --- a/open_earable/android/app/src/main/AndroidManifest.xml +++ b/open_earable/android/app/src/main/AndroidManifest.xml @@ -31,4 +31,14 @@ android:name="flutterEmbedding" android:value="2" /> + + + + + + + + + + diff --git a/open_earable/android/app/src/profile/AndroidManifest.xml b/open_earable/android/app/src/profile/AndroidManifest.xml index 869e598..399f698 100644 --- a/open_earable/android/app/src/profile/AndroidManifest.xml +++ b/open_earable/android/app/src/profile/AndroidManifest.xml @@ -4,16 +4,4 @@ to allow setting breakpoints, to provide hot reload, etc. --> - - - - - - - - - - - - From e1ab3daec4fb0402323a97b546538a35493d60c5 Mon Sep 17 00:00:00 2001 From: Jonas Greifenhain Date: Sun, 22 Sep 2024 12:30:04 +0200 Subject: [PATCH 05/10] Fix OpenEarable lib imports --- open_earable/lib/apps_tab/apps_tab.dart | 2 +- .../lib/apps_tab/jump_height_test/jump_height_chart.dart | 2 +- .../lib/apps_tab/jump_height_test/jump_height_test.dart | 2 +- .../lib/apps_tab/jump_rope_counter/jump_rope_counter.dart | 2 +- .../lib/apps_tab/neck_stretch/model/stretch_state.dart | 2 +- .../lib/apps_tab/neck_stretch/view/stretch_app_view.dart | 2 +- .../apps_tab/neck_stretch/view_model/stretch_view_model.dart | 2 +- .../apps_tab/posture_tracker/model/bad_posture_reminder.dart | 2 +- .../posture_tracker/model/earable_attitude_tracker.dart | 2 +- .../apps_tab/posture_tracker/view/posture_tracker_view.dart | 2 +- open_earable/lib/apps_tab/powernapper/home_screen.dart | 2 +- open_earable/lib/apps_tab/powernapper/interact.dart | 2 +- open_earable/lib/apps_tab/powernapper/movementTracker.dart | 2 +- open_earable/lib/apps_tab/recorder/lib/recorder.dart | 2 +- open_earable/lib/apps_tab/step_counter/step_counter.dart | 2 +- open_earable/lib/apps_tab/tightness/tightness.dart | 2 +- open_earable/lib/ble/ble_connect_view.dart | 2 +- open_earable/lib/ble/ble_controller.dart | 3 +-- open_earable/lib/ble/v1_ble_connect_view.dart | 2 +- .../lib/controls_tab/models/open_earable_settings_v2.dart | 2 +- open_earable/lib/controls_tab/views/audio_player.dart | 2 +- open_earable/lib/controls_tab/views/connect.dart | 4 +--- open_earable/lib/controls_tab/views/led_color.dart | 2 +- .../lib/controls_tab/views/sensor_control/sensor_control.dart | 2 +- open_earable/lib/controls_tab/views/v1_connect.dart | 4 +--- .../lib/controls_tab/views/v1_sensor_configuration.dart | 2 +- open_earable/lib/sensor_data_tab/earable_3d_model.dart | 2 +- open_earable/lib/sensor_data_tab/sensor_chart.dart | 2 +- open_earable/lib/sensor_data_tab/sensor_data_tab.dart | 2 +- 29 files changed, 29 insertions(+), 34 deletions(-) diff --git a/open_earable/lib/apps_tab/apps_tab.dart b/open_earable/lib/apps_tab/apps_tab.dart index bd944ef..b44b432 100644 --- a/open_earable/lib/apps_tab/apps_tab.dart +++ b/open_earable/lib/apps_tab/apps_tab.dart @@ -9,7 +9,7 @@ import 'package:open_earable/apps_tab/step_counter/step_counter.dart'; import 'package:open_earable/apps_tab/tightness/tightness.dart'; import 'package:open_earable/apps_tab/recorder/lib/recorder.dart'; import 'package:open_earable/apps_tab/jump_height_test/jump_height_test.dart'; -import 'package:open_earable_flutter/src/open_earable_flutter.dart'; +import 'package:open_earable_flutter/open_earable_flutter.dart'; import '../shared/global_theme.dart'; import 'package:open_earable/apps_tab/jump_rope_counter/jump_rope_counter.dart'; import 'powernapper/home_screen.dart'; diff --git a/open_earable/lib/apps_tab/jump_height_test/jump_height_chart.dart b/open_earable/lib/apps_tab/jump_height_test/jump_height_chart.dart index 09a18b8..ddf02db 100644 --- a/open_earable/lib/apps_tab/jump_height_test/jump_height_chart.dart +++ b/open_earable/lib/apps_tab/jump_height_test/jump_height_chart.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:open_earable_flutter/src/open_earable_flutter.dart'; +import 'package:open_earable_flutter/open_earable_flutter.dart'; import 'package:flutter/material.dart'; import 'package:community_charts_flutter/community_charts_flutter.dart' as charts; import 'package:simple_kalman/simple_kalman.dart'; diff --git a/open_earable/lib/apps_tab/jump_height_test/jump_height_test.dart b/open_earable/lib/apps_tab/jump_height_test/jump_height_test.dart index 4ae9a02..a3f8ad4 100644 --- a/open_earable/lib/apps_tab/jump_height_test/jump_height_test.dart +++ b/open_earable/lib/apps_tab/jump_height_test/jump_height_test.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:open_earable/apps_tab/jump_height_test/jump_height_chart.dart'; import 'dart:async'; -import 'package:open_earable_flutter/src/open_earable_flutter.dart'; +import 'package:open_earable_flutter/open_earable_flutter.dart'; import 'package:simple_kalman/simple_kalman.dart'; import 'dart:math'; import 'package:open_earable/shared/earable_not_connected_warning.dart'; diff --git a/open_earable/lib/apps_tab/jump_rope_counter/jump_rope_counter.dart b/open_earable/lib/apps_tab/jump_rope_counter/jump_rope_counter.dart index e3844d4..70ed469 100644 --- a/open_earable/lib/apps_tab/jump_rope_counter/jump_rope_counter.dart +++ b/open_earable/lib/apps_tab/jump_rope_counter/jump_rope_counter.dart @@ -2,7 +2,7 @@ import 'dart:math'; import 'package:flutter/material.dart'; import 'package:open_earable/shared/earable_not_connected_warning.dart'; -import 'package:open_earable_flutter/src/open_earable_flutter.dart'; +import 'package:open_earable_flutter/open_earable_flutter.dart'; import 'dart:async'; import 'package:intl/intl.dart'; import 'package:shared_preferences/shared_preferences.dart'; diff --git a/open_earable/lib/apps_tab/neck_stretch/model/stretch_state.dart b/open_earable/lib/apps_tab/neck_stretch/model/stretch_state.dart index 7d37f27..84be6ba 100644 --- a/open_earable/lib/apps_tab/neck_stretch/model/stretch_state.dart +++ b/open_earable/lib/apps_tab/neck_stretch/model/stretch_state.dart @@ -1,7 +1,7 @@ import 'dart:async'; import 'package:open_earable/apps_tab/neck_stretch/view_model/stretch_view_model.dart'; -import 'package:open_earable_flutter/src/open_earable_flutter.dart'; +import 'package:open_earable_flutter/open_earable_flutter.dart'; /// Enum for the neck stretch states enum NeckStretchState { diff --git a/open_earable/lib/apps_tab/neck_stretch/view/stretch_app_view.dart b/open_earable/lib/apps_tab/neck_stretch/view/stretch_app_view.dart index 0dfc38b..d3421d8 100644 --- a/open_earable/lib/apps_tab/neck_stretch/view/stretch_app_view.dart +++ b/open_earable/lib/apps_tab/neck_stretch/view/stretch_app_view.dart @@ -9,7 +9,7 @@ import 'package:open_earable/apps_tab/neck_stretch/view/stretch_settings_view.da import 'package:open_earable/apps_tab/neck_stretch/view/stretch_stats_view.dart'; import 'package:open_earable/shared/global_theme.dart'; -import 'package:open_earable_flutter/src/open_earable_flutter.dart'; +import 'package:open_earable_flutter/open_earable_flutter.dart'; class MenuItem { final IconData iconData; diff --git a/open_earable/lib/apps_tab/neck_stretch/view_model/stretch_view_model.dart b/open_earable/lib/apps_tab/neck_stretch/view_model/stretch_view_model.dart index 7b49e9e..a991347 100644 --- a/open_earable/lib/apps_tab/neck_stretch/view_model/stretch_view_model.dart +++ b/open_earable/lib/apps_tab/neck_stretch/view_model/stretch_view_model.dart @@ -4,7 +4,7 @@ import "package:flutter/material.dart"; import 'package:open_earable/apps_tab/posture_tracker/model/attitude.dart'; import 'package:open_earable/apps_tab/posture_tracker/model/attitude_tracker.dart'; import 'package:open_earable/apps_tab/neck_stretch/model/stretch_state.dart'; -import 'package:open_earable_flutter/src/open_earable_flutter.dart'; +import 'package:open_earable_flutter/open_earable_flutter.dart'; class StretchViewModel extends ChangeNotifier { Attitude _attitude = Attitude(); diff --git a/open_earable/lib/apps_tab/posture_tracker/model/bad_posture_reminder.dart b/open_earable/lib/apps_tab/posture_tracker/model/bad_posture_reminder.dart index 6ef0d5b..ee0d1b9 100644 --- a/open_earable/lib/apps_tab/posture_tracker/model/bad_posture_reminder.dart +++ b/open_earable/lib/apps_tab/posture_tracker/model/bad_posture_reminder.dart @@ -2,7 +2,7 @@ import 'dart:math'; import 'package:open_earable/apps_tab/posture_tracker/model/attitude.dart'; import 'package:open_earable/apps_tab/posture_tracker/model/attitude_tracker.dart'; -import 'package:open_earable_flutter/src/open_earable_flutter.dart'; +import 'package:open_earable_flutter/open_earable_flutter.dart'; class BadPostureSettings { bool isActive; diff --git a/open_earable/lib/apps_tab/posture_tracker/model/earable_attitude_tracker.dart b/open_earable/lib/apps_tab/posture_tracker/model/earable_attitude_tracker.dart index 8fd8627..b2ecb57 100644 --- a/open_earable/lib/apps_tab/posture_tracker/model/earable_attitude_tracker.dart +++ b/open_earable/lib/apps_tab/posture_tracker/model/earable_attitude_tracker.dart @@ -2,7 +2,7 @@ import 'dart:async'; import 'package:open_earable/apps_tab/posture_tracker/model/attitude_tracker.dart'; import 'package:open_earable/apps_tab/posture_tracker/model/ewma.dart'; -import 'package:open_earable_flutter/src/open_earable_flutter.dart'; +import 'package:open_earable_flutter/open_earable_flutter.dart'; class EarableAttitudeTracker extends AttitudeTracker { final OpenEarable _openEarable; diff --git a/open_earable/lib/apps_tab/posture_tracker/view/posture_tracker_view.dart b/open_earable/lib/apps_tab/posture_tracker/view/posture_tracker_view.dart index 18e5e0b..fd83688 100644 --- a/open_earable/lib/apps_tab/posture_tracker/view/posture_tracker_view.dart +++ b/open_earable/lib/apps_tab/posture_tracker/view/posture_tracker_view.dart @@ -8,7 +8,7 @@ import 'package:open_earable/apps_tab/posture_tracker/view/settings_view.dart'; import 'package:open_earable/apps_tab/posture_tracker/view_model/posture_tracker_view_model.dart'; import 'package:provider/provider.dart'; -import 'package:open_earable_flutter/src/open_earable_flutter.dart'; +import 'package:open_earable_flutter/open_earable_flutter.dart'; class PostureTrackerView extends StatefulWidget { final AttitudeTracker _tracker; diff --git a/open_earable/lib/apps_tab/powernapper/home_screen.dart b/open_earable/lib/apps_tab/powernapper/home_screen.dart index 8760d41..0bf38ce 100644 --- a/open_earable/lib/apps_tab/powernapper/home_screen.dart +++ b/open_earable/lib/apps_tab/powernapper/home_screen.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:open_earable/apps_tab/powernapper/timerscreen.dart'; -import 'package:open_earable_flutter/src/open_earable_flutter.dart'; +import 'package:open_earable_flutter/open_earable_flutter.dart'; import 'interact.dart'; diff --git a/open_earable/lib/apps_tab/powernapper/interact.dart b/open_earable/lib/apps_tab/powernapper/interact.dart index cb3c528..dc90d3f 100644 --- a/open_earable/lib/apps_tab/powernapper/interact.dart +++ b/open_earable/lib/apps_tab/powernapper/interact.dart @@ -1,4 +1,4 @@ -import 'package:open_earable_flutter/src/open_earable_flutter.dart'; +import 'package:open_earable_flutter/open_earable_flutter.dart'; ///Interaction class for the earable. All actions executed on the earable are accessible through this class. ///For example rings or led colors. diff --git a/open_earable/lib/apps_tab/powernapper/movementTracker.dart b/open_earable/lib/apps_tab/powernapper/movementTracker.dart index 023d2c4..59cffb2 100644 --- a/open_earable/lib/apps_tab/powernapper/movementTracker.dart +++ b/open_earable/lib/apps_tab/powernapper/movementTracker.dart @@ -2,7 +2,7 @@ import 'dart:async'; import 'package:open_earable/apps_tab/powernapper/interact.dart'; import 'package:open_earable/apps_tab/powernapper/sensor_datatypes.dart'; -import 'package:open_earable_flutter/src/open_earable_flutter.dart'; +import 'package:open_earable_flutter/open_earable_flutter.dart'; /// Movement Tracker has lgoic for timer & movement validation. class MovementTracker { diff --git a/open_earable/lib/apps_tab/recorder/lib/recorder.dart b/open_earable/lib/apps_tab/recorder/lib/recorder.dart index eef4b66..09cf3d8 100644 --- a/open_earable/lib/apps_tab/recorder/lib/recorder.dart +++ b/open_earable/lib/apps_tab/recorder/lib/recorder.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:open_earable/shared/earable_not_connected_warning.dart'; import 'dart:async'; import 'dart:io'; -import 'package:open_earable_flutter/src/open_earable_flutter.dart'; +import 'package:open_earable_flutter/open_earable_flutter.dart'; import 'package:path_provider/path_provider.dart'; import 'package:open_file/open_file.dart'; diff --git a/open_earable/lib/apps_tab/step_counter/step_counter.dart b/open_earable/lib/apps_tab/step_counter/step_counter.dart index 2beb8cd..0a73a19 100644 --- a/open_earable/lib/apps_tab/step_counter/step_counter.dart +++ b/open_earable/lib/apps_tab/step_counter/step_counter.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:open_earable/ble/ble_controller.dart'; import 'package:open_earable/shared/earable_not_connected_warning.dart'; import 'dart:async'; -import 'package:open_earable_flutter/src/open_earable_flutter.dart'; +import 'package:open_earable_flutter/open_earable_flutter.dart'; import 'package:provider/provider.dart'; /** diff --git a/open_earable/lib/apps_tab/tightness/tightness.dart b/open_earable/lib/apps_tab/tightness/tightness.dart index 279d05a..1509f84 100644 --- a/open_earable/lib/apps_tab/tightness/tightness.dart +++ b/open_earable/lib/apps_tab/tightness/tightness.dart @@ -3,7 +3,7 @@ import 'package:open_earable/ble/ble_controller.dart'; import 'package:open_earable/shared/earable_not_connected_warning.dart'; import 'dart:async'; import 'dart:math' as math; -import 'package:open_earable_flutter/src/open_earable_flutter.dart'; +import 'package:open_earable_flutter/open_earable_flutter.dart'; import 'package:provider/provider.dart'; class TightnessMeter extends StatefulWidget { diff --git a/open_earable/lib/ble/ble_connect_view.dart b/open_earable/lib/ble/ble_connect_view.dart index 08f3814..80ab531 100644 --- a/open_earable/lib/ble/ble_connect_view.dart +++ b/open_earable/lib/ble/ble_connect_view.dart @@ -2,7 +2,7 @@ import 'dart:io'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:open_earable/ble/ble_controller.dart'; -import 'package:open_earable_flutter/src/open_earable_flutter.dart'; +import 'package:open_earable_flutter/open_earable_flutter.dart'; import 'package:provider/provider.dart'; class BLEPage extends StatefulWidget { diff --git a/open_earable/lib/ble/ble_controller.dart b/open_earable/lib/ble/ble_controller.dart index 91e29ea..602a537 100644 --- a/open_earable/lib/ble/ble_controller.dart +++ b/open_earable/lib/ble/ble_controller.dart @@ -2,9 +2,8 @@ import 'dart:async'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; import 'package:open_earable/controls_tab/models/open_earable_settings_v2.dart'; -import 'package:open_earable_flutter/src/open_earable_flutter.dart'; +import 'package:open_earable_flutter/open_earable_flutter.dart'; import 'package:shared_preferences/shared_preferences.dart'; class BluetoothController extends ChangeNotifier { diff --git a/open_earable/lib/ble/v1_ble_connect_view.dart b/open_earable/lib/ble/v1_ble_connect_view.dart index 3869137..f7751f8 100644 --- a/open_earable/lib/ble/v1_ble_connect_view.dart +++ b/open_earable/lib/ble/v1_ble_connect_view.dart @@ -2,7 +2,7 @@ import 'dart:io'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:open_earable/ble/ble_controller.dart'; -import 'package:open_earable_flutter/src/open_earable_flutter.dart'; +import 'package:open_earable_flutter/open_earable_flutter.dart'; import 'package:provider/provider.dart'; class V1BLEPage extends StatefulWidget { diff --git a/open_earable/lib/controls_tab/models/open_earable_settings_v2.dart b/open_earable/lib/controls_tab/models/open_earable_settings_v2.dart index 50b5390..0e45a53 100644 --- a/open_earable/lib/controls_tab/models/open_earable_settings_v2.dart +++ b/open_earable/lib/controls_tab/models/open_earable_settings_v2.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:open_earable_flutter/src/open_earable_flutter.dart'; +import 'package:open_earable_flutter/open_earable_flutter.dart'; class OpenEarableSettingsV2 { static final OpenEarableSettingsV2 _instance = diff --git a/open_earable/lib/controls_tab/views/audio_player.dart b/open_earable/lib/controls_tab/views/audio_player.dart index 2e03577..b1274c1 100644 --- a/open_earable/lib/controls_tab/views/audio_player.dart +++ b/open_earable/lib/controls_tab/views/audio_player.dart @@ -2,7 +2,7 @@ import 'dart:io'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:open_earable/ble/ble_controller.dart'; -import 'package:open_earable_flutter/src/open_earable_flutter.dart'; +import 'package:open_earable_flutter/open_earable_flutter.dart'; import 'package:provider/provider.dart'; import '../models/open_earable_settings.dart'; import '../../shared/dynamic_value_picker.dart'; diff --git a/open_earable/lib/controls_tab/views/connect.dart b/open_earable/lib/controls_tab/views/connect.dart index 781b77c..d6c3ff4 100644 --- a/open_earable/lib/controls_tab/views/connect.dart +++ b/open_earable/lib/controls_tab/views/connect.dart @@ -1,11 +1,9 @@ -import 'dart:io'; import 'dart:async'; import 'package:flutter/material.dart'; -import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; import 'package:open_earable/ble/ble_controller.dart'; import 'package:open_earable/ble/ble_tab_bar_page.dart'; import 'package:open_earable/controls_tab/models/open_earable_settings_v2.dart'; -import 'package:open_earable_flutter/src/open_earable_flutter.dart'; +import 'package:open_earable_flutter/open_earable_flutter.dart'; import 'package:flutter/cupertino.dart'; import 'package:provider/provider.dart'; import 'package:shared_preferences/shared_preferences.dart'; diff --git a/open_earable/lib/controls_tab/views/led_color.dart b/open_earable/lib/controls_tab/views/led_color.dart index b8d48e5..063040a 100644 --- a/open_earable/lib/controls_tab/views/led_color.dart +++ b/open_earable/lib/controls_tab/views/led_color.dart @@ -1,7 +1,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:open_earable/controls_tab/models/open_earable_settings.dart'; -import 'package:open_earable_flutter/src/open_earable_flutter.dart'; +import 'package:open_earable_flutter/open_earable_flutter.dart'; import 'dart:async'; import 'package:flutter_colorpicker/flutter_colorpicker.dart'; import 'dart:io'; diff --git a/open_earable/lib/controls_tab/views/sensor_control/sensor_control.dart b/open_earable/lib/controls_tab/views/sensor_control/sensor_control.dart index 1ec8c3e..28b61f7 100644 --- a/open_earable/lib/controls_tab/views/sensor_control/sensor_control.dart +++ b/open_earable/lib/controls_tab/views/sensor_control/sensor_control.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; import 'dart:io'; import 'package:open_earable/ble/ble_controller.dart'; import 'sensor_control_row.dart'; -import 'package:open_earable_flutter/src/open_earable_flutter.dart'; +import 'package:open_earable_flutter/open_earable_flutter.dart'; import 'package:provider/provider.dart'; import '../../models/open_earable_settings_v2.dart'; diff --git a/open_earable/lib/controls_tab/views/v1_connect.dart b/open_earable/lib/controls_tab/views/v1_connect.dart index 478ec02..9d81b06 100644 --- a/open_earable/lib/controls_tab/views/v1_connect.dart +++ b/open_earable/lib/controls_tab/views/v1_connect.dart @@ -1,9 +1,7 @@ -import 'dart:io'; import 'dart:async'; import 'package:flutter/material.dart'; -import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; import 'package:open_earable/ble/ble_controller.dart'; -import 'package:open_earable_flutter/src/open_earable_flutter.dart'; +import 'package:open_earable_flutter/open_earable_flutter.dart'; import 'package:flutter/cupertino.dart'; import 'package:provider/provider.dart'; import 'package:open_earable/ble/ble_connect_view.dart'; diff --git a/open_earable/lib/controls_tab/views/v1_sensor_configuration.dart b/open_earable/lib/controls_tab/views/v1_sensor_configuration.dart index 7187976..9c68f27 100644 --- a/open_earable/lib/controls_tab/views/v1_sensor_configuration.dart +++ b/open_earable/lib/controls_tab/views/v1_sensor_configuration.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; import 'package:open_earable/shared/dynamic_value_picker.dart'; import 'dart:io'; import 'package:open_earable/ble/ble_controller.dart'; -import 'package:open_earable_flutter/src/open_earable_flutter.dart'; +import 'package:open_earable_flutter/open_earable_flutter.dart'; import 'package:provider/provider.dart'; import '../models/open_earable_settings.dart'; diff --git a/open_earable/lib/sensor_data_tab/earable_3d_model.dart b/open_earable/lib/sensor_data_tab/earable_3d_model.dart index b20986d..1903f77 100644 --- a/open_earable/lib/sensor_data_tab/earable_3d_model.dart +++ b/open_earable/lib/sensor_data_tab/earable_3d_model.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'dart:async'; import 'dart:math'; -import 'package:open_earable_flutter/src/open_earable_flutter.dart'; +import 'package:open_earable_flutter/open_earable_flutter.dart'; import 'package:model_viewer_plus/model_viewer_plus.dart'; import 'package:webview_flutter/webview_flutter.dart'; diff --git a/open_earable/lib/sensor_data_tab/sensor_chart.dart b/open_earable/lib/sensor_data_tab/sensor_chart.dart index d7f6751..8e79c07 100644 --- a/open_earable/lib/sensor_data_tab/sensor_chart.dart +++ b/open_earable/lib/sensor_data_tab/sensor_chart.dart @@ -1,7 +1,7 @@ import 'dart:async'; import 'package:open_earable/shared/earable_not_connected_warning.dart'; -import 'package:open_earable_flutter/src/open_earable_flutter.dart'; +import 'package:open_earable_flutter/open_earable_flutter.dart'; import 'package:flutter/material.dart'; import 'package:community_charts_flutter/community_charts_flutter.dart' as charts; import 'package:simple_kalman/simple_kalman.dart'; diff --git a/open_earable/lib/sensor_data_tab/sensor_data_tab.dart b/open_earable/lib/sensor_data_tab/sensor_data_tab.dart index ea18419..1a423ab 100644 --- a/open_earable/lib/sensor_data_tab/sensor_data_tab.dart +++ b/open_earable/lib/sensor_data_tab/sensor_data_tab.dart @@ -3,7 +3,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:open_earable/ble/ble_controller.dart'; import 'package:open_earable/sensor_data_tab/earable_3d_model.dart'; -import 'package:open_earable_flutter/src/open_earable_flutter.dart'; +import 'package:open_earable_flutter/open_earable_flutter.dart'; import 'package:open_earable/sensor_data_tab/sensor_chart.dart'; import 'package:provider/provider.dart'; From 5f8c2ef46e5b428f70eeb007349832a0dd5aefeb Mon Sep 17 00:00:00 2001 From: Jonas Greifenhain Date: Sun, 22 Sep 2024 12:30:31 +0200 Subject: [PATCH 06/10] Remove Bluetooth permission checks Is part of the library now --- open_earable/lib/main.dart | 65 -------------------------------------- 1 file changed, 65 deletions(-) diff --git a/open_earable/lib/main.dart b/open_earable/lib/main.dart index 0032a19..5415d9b 100644 --- a/open_earable/lib/main.dart +++ b/open_earable/lib/main.dart @@ -1,21 +1,13 @@ -import 'dart:io'; import 'dart:async'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:open_earable/ble/ble_tab_bar_page.dart'; import 'package:open_earable/controls_tab/models/open_earable_settings_v2.dart'; import 'package:open_earable/shared/open_earable_icon_icons.dart'; import 'package:provider/provider.dart'; import 'controls_tab/controls_tab.dart'; import 'sensor_data_tab/sensor_data_tab.dart'; -import 'package:open_earable/ble/ble_connect_view.dart'; import 'package:open_earable/ble/ble_controller.dart'; import 'apps_tab/apps_tab.dart'; -import 'package:open_earable_flutter/src/open_earable_flutter.dart'; -import 'package:permission_handler/permission_handler.dart'; -import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; -import 'package:app_settings/app_settings.dart'; import 'shared/global_theme.dart'; void main() => runApp(ChangeNotifierProvider( @@ -39,7 +31,6 @@ class MyHomePage extends StatefulWidget { class _MyHomePageState extends State { int _selectedIndex = 0; - final flutterReactiveBle = FlutterReactiveBle(); late bool alertOpen; late List _widgetOptions; StreamSubscription? blePermissionSubscription; @@ -48,7 +39,6 @@ class _MyHomePageState extends State { void initState() { super.initState(); alertOpen = false; - _checkBLEPermission(); } @override @@ -71,61 +61,6 @@ class _MyHomePageState extends State { blePermissionSubscription?.cancel(); } - Future _checkBLEPermission() async { - PermissionStatus status = await Permission.bluetoothConnect.request(); - await Permission.location.request(); - await Permission.bluetoothScan.request(); - if (status.isGranted) { - print("BLE is working"); - } - blePermissionSubscription = - flutterReactiveBle.statusStream.listen((status) { - if (status != BleStatus.ready && - status != BleStatus.unknown && - alertOpen == false) { - alertOpen = true; - _showBluetoothAlert(context); - } - }); - } - - void _showBluetoothAlert(BuildContext context) { - showDialog( - context: context, - barrierDismissible: false, - builder: (BuildContext context) { - return AlertDialog( - title: Text("Bluetooth disabled"), - content: Text( - "Please make sure your device's bluetooth and location services are turned on and this app has been granted permission to use them in the app's settings.\nThis alert can only be closed if these requirements are fulfilled."), - actions: [ - TextButton( - child: Text( - 'Open App Settings', - style: TextStyle( - color: Theme.of(context).colorScheme.onBackground), - ), - onPressed: () { - AppSettings.openAppSettings(); - }, - ), - TextButton( - child: Text('OK', - style: TextStyle( - color: Theme.of(context).colorScheme.onBackground)), - onPressed: () { - if (flutterReactiveBle.status == BleStatus.ready) { - alertOpen = false; - Navigator.of(context).pop(); - } - }, - ), - ], - ); - }, - ); - } - void _onItemTapped(int index) { setState(() { _selectedIndex = index; From 20c298a30fba8426d2228760a283c7cb2dfaf0cc Mon Sep 17 00:00:00 2001 From: Jonas Greifenhain Date: Mon, 23 Sep 2024 21:53:44 +0200 Subject: [PATCH 07/10] Add MacOS Bluetooth capabilities and permissions --- open_earable/macos/Runner/DebugProfile.entitlements | 2 ++ open_earable/macos/Runner/Info.plist | 4 ++++ open_earable/macos/Runner/Release.entitlements | 2 ++ 3 files changed, 8 insertions(+) diff --git a/open_earable/macos/Runner/DebugProfile.entitlements b/open_earable/macos/Runner/DebugProfile.entitlements index dddb8a3..14a39b7 100644 --- a/open_earable/macos/Runner/DebugProfile.entitlements +++ b/open_earable/macos/Runner/DebugProfile.entitlements @@ -6,6 +6,8 @@ com.apple.security.cs.allow-jit + com.apple.security.device.bluetooth + com.apple.security.network.server diff --git a/open_earable/macos/Runner/Info.plist b/open_earable/macos/Runner/Info.plist index 4789daa..1349ea7 100644 --- a/open_earable/macos/Runner/Info.plist +++ b/open_earable/macos/Runner/Info.plist @@ -28,5 +28,9 @@ MainMenu NSPrincipalClass NSApplication + NSBluetoothAlwaysUsageDescription + Needs access to Bluetooth to connect to devices. + NSBluetoothPeripheralUsageDescription + Needs access to Bluetooth to communicate with peripherals. diff --git a/open_earable/macos/Runner/Release.entitlements b/open_earable/macos/Runner/Release.entitlements index 852fa1a..c269f52 100644 --- a/open_earable/macos/Runner/Release.entitlements +++ b/open_earable/macos/Runner/Release.entitlements @@ -4,5 +4,7 @@ com.apple.security.app-sandbox + com.apple.security.device.bluetooth + From 4f92561d2b1cb43efe212861a72e5f158818ef33 Mon Sep 17 00:00:00 2001 From: Jonas Greifenhain Date: Mon, 7 Oct 2024 00:59:15 +0200 Subject: [PATCH 08/10] Init web deployment --- .../firebase-hosting-pull-request.yml | 23 +++++++++++++++++++ open_earable/.firebaserc | 5 ++++ open_earable/firebase.json | 10 ++++++++ 3 files changed, 38 insertions(+) create mode 100644 .github/workflows/firebase-hosting-pull-request.yml create mode 100644 open_earable/.firebaserc create mode 100644 open_earable/firebase.json diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml new file mode 100644 index 0000000..70f844a --- /dev/null +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -0,0 +1,23 @@ +# This file was auto-generated by the Firebase CLI +# https://github.com/firebase/firebase-tools + +name: Deploy to Firebase Hosting on PR +on: pull_request +permissions: + checks: write + contents: read + pull-requests: write +jobs: + build_and_preview: + if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: (cd open_earable && flutter build web --dart-define=BUILD_COMMIT=$(git + rev-parse --short HEAD) --dart-define=BUILD_BRANCH=$(git rev-parse + --abbrev-ref HEAD)) + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: ${{ secrets.GITHUB_TOKEN }} + firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_OPEN_EARABLE_WEB }} + projectId: open-earable-web diff --git a/open_earable/.firebaserc b/open_earable/.firebaserc new file mode 100644 index 0000000..f3e4c75 --- /dev/null +++ b/open_earable/.firebaserc @@ -0,0 +1,5 @@ +{ + "projects": { + "default": "open-earable-web" + } +} diff --git a/open_earable/firebase.json b/open_earable/firebase.json new file mode 100644 index 0000000..ddab6ab --- /dev/null +++ b/open_earable/firebase.json @@ -0,0 +1,10 @@ +{ + "hosting": { + "public": "build/web/", + "ignore": [ + "firebase.json", + "**/.*", + "**/node_modules/**" + ] + } +} From 44878b48172e2cc39329d9c7bfd90ebb042c9338 Mon Sep 17 00:00:00 2001 From: Jonas Greifenhain Date: Mon, 7 Oct 2024 01:05:36 +0200 Subject: [PATCH 09/10] Configure flutter web deployments --- .github/workflows/firebase-hosting-pull-request.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml index 70f844a..394bd64 100644 --- a/.github/workflows/firebase-hosting-pull-request.yml +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -13,11 +13,18 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: subosito/flutter-action@v2 + with: + channel: stable - run: (cd open_earable && flutter build web --dart-define=BUILD_COMMIT=$(git rev-parse --short HEAD) --dart-define=BUILD_BRANCH=$(git rev-parse --abbrev-ref HEAD)) - uses: FirebaseExtended/action-hosting-deploy@v0 + if: ${{ github.event_name == 'pull_request' }} + name: Deploy preview with: repoToken: ${{ secrets.GITHUB_TOKEN }} firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_OPEN_EARABLE_WEB }} projectId: open-earable-web + expires: 28d + entryPoint: open_earable/ From 5706ec6830a05434276101dff2e4b5389d05dbf1 Mon Sep 17 00:00:00 2001 From: Jonas Greifenhain Date: Mon, 7 Oct 2024 01:22:04 +0200 Subject: [PATCH 10/10] Recreate pubspec.lock --- open_earable/pubspec.lock | 50 +++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/open_earable/pubspec.lock b/open_earable/pubspec.lock index a9ddc2b..3d2d4e9 100644 --- a/open_earable/pubspec.lock +++ b/open_earable/pubspec.lock @@ -226,10 +226,10 @@ packages: dependency: transitive description: name: flutter_inappwebview_android - sha256: d247f6ed417f1f8c364612fa05a2ecba7f775c8d0c044c1d3b9ee33a6515c421 + sha256: "62557c15a5c2db5d195cb3892aab74fcaec266d7b86d59a6f0027abd672cddba" url: "https://pub.dev" source: hosted - version: "1.0.13" + version: "1.1.3" flutter_inappwebview_internal_annotations: dependency: transitive description: @@ -243,27 +243,27 @@ packages: description: path: flutter_inappwebview_ios ref: master - resolved-ref: c3553312a65780c402b95960d70c190367385652 + resolved-ref: "683d1cace2fe0ca4284b1e940a13f56008e75c3d" url: "https://github.com/pichillilorenzo/flutter_inappwebview" source: git - version: "1.0.14" + version: "1.1.2" flutter_inappwebview_macos: dependency: "direct overridden" description: path: flutter_inappwebview_macos ref: master - resolved-ref: c3553312a65780c402b95960d70c190367385652 + resolved-ref: "683d1cace2fe0ca4284b1e940a13f56008e75c3d" url: "https://github.com/pichillilorenzo/flutter_inappwebview" source: git - version: "1.0.12" + version: "1.1.2" flutter_inappwebview_platform_interface: dependency: transitive description: name: flutter_inappwebview_platform_interface - sha256: "545fd4c25a07d2775f7d5af05a979b2cac4fbf79393b0a7f5d33ba39ba4f6187" + sha256: cf5323e194096b6ede7a1ca808c3e0a078e4b33cc3f6338977d75b4024ba2500 url: "https://pub.dev" source: hosted - version: "1.0.10" + version: "1.3.0+1" flutter_inappwebview_web: dependency: transitive description: @@ -428,7 +428,7 @@ packages: description: path: "." ref: web_compatibility - resolved-ref: "3e82d7499c0fac2d8dff90da7f98aa5266698f63" + resolved-ref: "3a11438c399d98837c677d830356ca02724b68f8" url: "https://github.com/OpenEarable/open_earable_flutter.git" source: git version: "0.0.2" @@ -444,10 +444,10 @@ packages: dependency: transitive description: name: open_file_android - sha256: b5e1a2e9c5ea8e256b015403e94299039627c7205c2a5e6bb426c33235b6ca9a + sha256: c29d96112e5092e4871e292b73f71ecf35f262364b11553852a16f36475fe5e0 url: "https://pub.dev" source: hosted - version: "1.0.2" + version: "1.0.5" open_file_ios: dependency: transitive description: @@ -516,10 +516,10 @@ packages: dependency: transitive description: name: path_provider_android - sha256: "6f01f8e37ec30b07bc424b4deabac37cacb1bc7e2e515ad74486039918a37eb7" + sha256: f7544c346a0742aee1450f9e5c0f5269d7c602b9c95fdbcd9fb8f5b1df13b1cc url: "https://pub.dev" source: hosted - version: "2.2.10" + version: "2.2.11" path_provider_foundation: dependency: transitive description: @@ -644,18 +644,18 @@ packages: dependency: transitive description: name: shared_preferences_android - sha256: "480ba4345773f56acda9abf5f50bd966f581dac5d514e5fc4a18c62976bbba7e" + sha256: "3b9febd815c9ca29c9e3520d50ec32f49157711e143b7a4ca039eb87e8ade5ab" url: "https://pub.dev" source: hosted - version: "2.3.2" + version: "2.3.3" shared_preferences_foundation: dependency: transitive description: name: shared_preferences_foundation - sha256: c4b35f6cb8f63c147312c054ce7c2254c8066745125264f0c88739c417fc9d9f + sha256: "07e050c7cd39bad516f8d64c455f04508d09df104be326d8c02551590a0d513d" url: "https://pub.dev" source: hosted - version: "2.5.2" + version: "2.5.3" shared_preferences_linux: dependency: transitive description: @@ -785,10 +785,10 @@ packages: dependency: transitive description: name: url_launcher_android - sha256: e35a698ac302dd68e41f73250bd9517fe3ab5fa4f18fe4647a0872db61bacbab + sha256: "8fc3bae0b68c02c47c5c86fa8bfa74471d42687b0eded01b78de87872db745e2" url: "https://pub.dev" source: hosted - version: "6.3.10" + version: "6.3.12" url_launcher_ios: dependency: transitive description: @@ -809,10 +809,10 @@ packages: dependency: transitive description: name: url_launcher_macos - sha256: "9a1a42d5d2d95400c795b2914c36fdcb525870c752569438e4ebb09a2b5d90de" + sha256: "769549c999acdb42b8bcfa7c43d72bf79a382ca7441ab18a808e101149daf672" url: "https://pub.dev" source: hosted - version: "3.2.0" + version: "3.2.1" url_launcher_platform_interface: dependency: transitive description: @@ -873,10 +873,10 @@ packages: dependency: transitive description: name: webview_flutter_android - sha256: "6e64fcb1c19d92024da8f33503aaeeda35825d77142c01d0ea2aa32edc79fdc8" + sha256: "47a8da40d02befda5b151a26dba71f47df471cddd91dfdb7802d0a87c5442558" url: "https://pub.dev" source: hosted - version: "3.16.7" + version: "3.16.9" webview_flutter_platform_interface: dependency: transitive description: @@ -897,10 +897,10 @@ packages: dependency: transitive description: name: xdg_directories - sha256: faea9dee56b520b55a566385b84f2e8de55e7496104adada9962e0bd11bcff1d + sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15" url: "https://pub.dev" source: hosted - version: "1.0.4" + version: "1.1.0" xml: dependency: transitive description: