Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Web compatibility #68

Merged
merged 10 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/firebase-hosting-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# 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
- 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/
5 changes: 5 additions & 0 deletions open_earable/.firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "open-earable-web"
}
}
10 changes: 10 additions & 0 deletions open_earable/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,14 @@
android:name="flutterEmbedding"
android:value="2" />
</application>

<!-- flutter_reactive_ble permissions -->
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

<!-- location permissions -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
</manifest>
12 changes: 0 additions & 12 deletions open_earable/android/app/src/profile/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,4 @@
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>

<!-- flutter_reactive_ble permissions -->
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />


<!-- location permissions -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
</manifest>
10 changes: 10 additions & 0 deletions open_earable/firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"hosting": {
"public": "build/web/",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
}
}
22 changes: 10 additions & 12 deletions open_earable/lib/apps_tab/apps_tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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: () {
Expand Down Expand Up @@ -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: () {
Expand Down Expand Up @@ -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: () {
Expand Down Expand Up @@ -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,
Expand All @@ -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
),
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion open_earable/lib/apps_tab/powernapper/home_screen.dart
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion open_earable/lib/apps_tab/powernapper/interact.dart
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion open_earable/lib/apps_tab/powernapper/movementTracker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion open_earable/lib/apps_tab/recorder/lib/recorder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion open_earable/lib/apps_tab/step_counter/step_counter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down
2 changes: 1 addition & 1 deletion open_earable/lib/apps_tab/tightness/tightness.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
52 changes: 20 additions & 32 deletions open_earable/lib/ble/ble_connect_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ 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 {
final OpenEarable openEarable;
final int earableIndex;

BLEPage(this.openEarable, this.earableIndex);

@override
Expand All @@ -16,6 +17,7 @@ class BLEPage extends StatefulWidget {

class _BLEPageState extends State<BLEPage> {
late OpenEarable _openEarable;

@override
void initState() {
super.initState();
Expand Down Expand Up @@ -56,8 +58,8 @@ class _BLEPageState extends State<BLEPage> {
),
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) {
Expand Down Expand Up @@ -101,28 +103,18 @@ class _BLEPageState extends State<BLEPage> {
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<BluetoothController>(context, listen: false)
.startScanning(_openEarable),
)
: ElevatedButton(
onPressed: () =>
Provider.of<BluetoothController>(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<BluetoothController>(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'),
),
)
],
));
Expand All @@ -132,17 +124,13 @@ class _BLEPageState extends State<BLEPage> {
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();
}
Expand Down
3 changes: 1 addition & 2 deletions open_earable/lib/ble/ble_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading