Skip to content

Commit

Permalink
M3-107 Feat : 안드로이드 신체활동 권한, 안드로이드 걷기 인터페이스 일부 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
tkdals802 committed Jun 21, 2024
1 parent d85e006 commit 96b3c1a
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 2 deletions.
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />
<application
android:label="ground_flip"
android:name="${applicationName}"
Expand Down
37 changes: 37 additions & 0 deletions lib/service/android_walk_interface.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import 'dart:async';

import 'package:get/get.dart';
import 'package:pedometer/pedometer.dart';

import '../utils/walking_service.dart';

class AndroidWalkInterface extends GetxController implements WalkingService{
late Stream<StepCount> _stepCountStream;

@override
RxInt step = 0.obs;

RxInt get steps => step;

@override
void getCurrentStep(StepCount event){
step.value = event.steps;
}

void onStepCountError(error) {
//print('onStepCountError: $error');
step.value = 0;
}

void initPlatformState() {
_stepCountStream = Pedometer.stepCountStream;
_stepCountStream.listen(getCurrentStep).onError(onStepCountError);
}

@override
List<int> getWeeklySteps(startDate, endDate){
List<int> a = [];
return a;
}

}
7 changes: 5 additions & 2 deletions lib/utils/walking_service.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import 'package:get/get.dart';
import 'package:pedometer/pedometer.dart';

abstract class WalkingService {
late int step;
late RxInt step;

int getCurrentStep();
void getCurrentStep(StepCount event);

List<int> getWeeklySteps(startDate, endDate);
}
8 changes: 8 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.9.0"
pedometer:
dependency: "direct main"
description:
name: pedometer
sha256: e8c574dae778276fa848873c6ea2015a636a91e8572a4a652b04a4fcd6c54259
url: "https://pub.dev"
source: hosted
version: "4.0.1"
sky_engine:
dependency: transitive
description: flutter
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dependencies:
dio: ^5.4.3+1
get: ^4.6.6
flutter_dotenv: ^5.1.0
pedometer: ^4.0.1

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 96b3c1a

Please sign in to comment.