Skip to content

Commit

Permalink
fix of #341
Browse files Browse the repository at this point in the history
  • Loading branch information
bardram committed Oct 29, 2024
1 parent 64b70f1 commit 92452af
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 29 deletions.
8 changes: 4 additions & 4 deletions lib/blocs/app_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -370,13 +370,13 @@ class StudyAppBLoC extends ChangeNotifier {
Sensing().controller?.dispose();
}

/// Add a [Measurement] object to the stream of measurements.
/// Add [measurement] to the stream of collected measurements.
void addMeasurement(Measurement measurement) =>
Sensing().controller!.executor.addMeasurement(measurement);
Sensing().controller?.executor.addMeasurement(measurement);

/// Add a error to the stream of measurements.
/// Add [error] to the stream of measurements.
void addError(Object error, [StackTrace? stacktrace]) =>
Sensing().controller!.executor.addError(error, stacktrace);
Sensing().controller?.executor.addError(error, stacktrace);

/// Leave the study deployed on this phone.
///
Expand Down
8 changes: 5 additions & 3 deletions lib/ui/pages/audio_task_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ class AudioTaskPageState extends State<AudioTaskPage> {
body: SafeArea(
child: PopScope(
canPop: true,
onPopInvoked: (didPop) async =>
_showCancelConfirmationDialog() as FutureOr<bool>,
// onPopInvokedWithResult: (didPop, result) =>
// _showCancelConfirmationDialog(),
// onPopInvoked: (didPop) async =>
// _showCancelConfirmationDialog() as FutureOr<bool>,
child: Scaffold(
body: Container(
padding: const EdgeInsets.symmetric(horizontal: 15),
Expand Down Expand Up @@ -311,7 +313,7 @@ class AudioTaskPageState extends State<AudioTaskPage> {
radius: 30,
backgroundColor: CACHET.GREEN_1,
child: IconButton(
onPressed: () => Navigator.pop(context),
onPressed: () => Navigator.of(context).pop(),
padding: const EdgeInsets.all(0),
icon: const Icon(Icons.check_circle_outline,
color: Colors.white, size: 30),
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/pages/camera_task_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class CameraTaskPageState extends State<CameraTaskPage> {
@override
Widget build(BuildContext context) => PopScope(
canPop: true,
onPopInvoked: (didPop) async =>
_showCancelConfirmationDialog() as FutureOr<bool>,
// onPopInvoked: (didPop) async =>
// _showCancelConfirmationDialog() as FutureOr<bool>,
child: Scaffold(
body: Container(
padding: const EdgeInsets.symmetric(horizontal: 15),
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/pages/login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class _LoginPageState extends State<LoginPage> {
showDialog<bool>(
context: context,
builder: (context) => PopScope(
onPopInvoked: (didPop) async {
onPopInvokedWithResult: (didPop, result) async {
Navigator.of(context).pop();
},
child: EnableInternetConnectionDialog(),
Expand Down
21 changes: 15 additions & 6 deletions lib/view_models/user_tasks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,16 @@ class AppUserTaskFactory implements UserTaskFactory {
}

/// A user task handling audio recordings.
/// When started, creates a [AudioTaskPage] and shows it to the user.
///
/// The [widget] returns an [AudioTaskPage] that can be shown on the UI.
///
/// When the recording is started (calling the [onRecordStart] method),
/// the background task collecting sensor measures is started.
class AudioUserTask extends UserTask {
final StreamController<int> _countDownController =
StreamController.broadcast();
Stream<int>? get countDownEvents => _countDownController.stream;
Timer? _timer;

/// Total duration of audio recording in seconds.
int recordingDuration = 60;
Expand All @@ -46,7 +51,11 @@ class AudioUserTask extends UserTask {
: 60;
}

Timer? _timer;
@override
bool get hasWidget => true;

@override
Widget? get widget => AudioTaskPage(audioUserTask: this);

/// Callback when recording is to start.
void onRecordStart() {
Expand Down Expand Up @@ -80,17 +89,17 @@ class AudioUserTask extends UserTask {
/// A user task handling video and image recordings.
/// When started, creates a [CameraTaskPage].
class VideoUserTask extends UserTask {
VideoUserTask(super.executor);
DateTime? _startRecordingTime, _endRecordingTime;
XFile? _file;
MediaType _mediaType = MediaType.image;

@override
bool get hasWidget => true;

@override
Widget? get widget => CameraTaskPage(mediaUserTask: this);

DateTime? _startRecordingTime, _endRecordingTime;
XFile? _file;
MediaType _mediaType = MediaType.image;
VideoUserTask(super.executor);

/// Callback when a picture is captured.
void onPictureCapture(XFile image) {
Expand Down
25 changes: 12 additions & 13 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@ packages:
dependency: "direct main"
description:
name: carp_audio_package
sha256: "49c6ce45287d4d922d52bad1c998e2239c637dc1fb3b1a335282acca106da8e8"
sha256: "3d6e3eccd58d4deabab5e1fc687e2d8205b92b489faeeecc33175d923895760e"
url: "https://pub.dev"
source: hosted
version: "1.7.0"
version: "1.7.1"
carp_backend:
dependency: "direct main"
description:
Expand Down Expand Up @@ -282,10 +282,10 @@ packages:
dependency: "direct main"
description:
name: carp_mobile_sensing
sha256: b7fcae43c84363f834f5f9143094720e4655c49614e438fa17d05d79c08a8a58
sha256: "58fdc4d7a4b9a6d2484fcc08153610971efe90992a03da874a77c8b33f164165"
url: "https://pub.dev"
source: hosted
version: "1.11.2"
version: "1.11.3"
carp_movesense_package:
dependency: "direct main"
description:
Expand Down Expand Up @@ -1358,10 +1358,10 @@ packages:
dependency: transitive
description:
name: path_parsing
sha256: e3e67b1629e6f7e8100b367d3db6ba6af4b1f0bb80f64db18ef1fbabd2fa9ccf
sha256: "45f7d6bba1128761de5540f39d5ca000ea8a1f22f06b76b61094a60a2997bd0e"
url: "https://pub.dev"
source: hosted
version: "1.0.1"
version: "1.0.2"
path_provider:
dependency: "direct main"
description:
Expand Down Expand Up @@ -2091,11 +2091,10 @@ packages:
dependency: transitive
description:
name: video_player_android
sha256: "641fc7221cfb3f25dd761d30cbe733046a3a4932fee09962adb80fd7d11fc663"
sha256: "391e092ba4abe2f93b3e625bd6b6a6ec7d7414279462c1c0ee42b5ab8d0a0898"
url: "https://pub.dev"
source: hosted
version: "2.7.15"

version: "2.7.16"
video_player_avfoundation:
dependency: transitive
description:
Expand All @@ -2116,10 +2115,10 @@ packages:
dependency: transitive
description:
name: video_player_web
sha256: "6dcdd298136523eaf7dfc31abaf0dfba9aa8a8dbc96670e87e9d42b6f2caf774"
sha256: "881b375a934d8ebf868c7fb1423b2bfaa393a0a265fa3f733079a86536064a10"
url: "https://pub.dev"
source: hosted
version: "2.3.2"
version: "2.3.3"
vm_service:
dependency: transitive
description:
Expand Down Expand Up @@ -2180,10 +2179,10 @@ packages:
dependency: transitive
description:
name: win32
sha256: e1d0cc62e65dc2561f5071fcbccecf58ff20c344f8f3dc7d4922df372a11df1f
sha256: "10169d3934549017f0ae278ccb07f828f9d6ea21573bab0fb77b0e1ef0fce454"
url: "https://pub.dev"
source: hosted
version: "5.7.1"
version: "5.7.2"
win32_registry:
dependency: transitive
description:
Expand Down

0 comments on commit 92452af

Please sign in to comment.