Skip to content

Commit

Permalink
Handle back button during recording
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkrieger committed Dec 28, 2021
1 parent 76c2a82 commit 92a76c2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
15 changes: 12 additions & 3 deletions lib/views/notes_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,17 @@ class _NotesViewState extends State<_NotesView> {
context.read<OutlinesModel>().toggleArchive(outline);
}

Future<void> _goToOutlines() async {
final playerModel = context.read<PlayerModel>();
if (playerModel.playerState == PlayerState.recordingContinuously) {
await context.read<NotesModel>().stopRecording(0);
}
if (playerModel.playerState == PlayerState.playing) {
await playerModel.stopPlaying();
}
Navigator.pushNamedAndRemoveUntil(context, "/", (_) => false);
}

@override
Widget build(BuildContext context) {
final ready = context.select<NotesModel, bool>((value) => value.isReady);
Expand Down Expand Up @@ -341,9 +352,7 @@ class _NotesViewState extends State<_NotesView> {
),
leading: IconButton(
tooltip: "all outlines",
onPressed: () {
Navigator.pushNamedAndRemoveUntil(context, "/", (_) => false);
},
onPressed: _goToOutlines,
icon: const Icon(Icons.chevron_left)),
actions: [
if (currentOutlineArchived)
Expand Down
5 changes: 3 additions & 2 deletions lib/widgets/record_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ class _RecordButtonState extends State<RecordButton> {
}

_stopRecord(_) async {
// final playerState = context.read<PlayerModel>().playerState;
if (_stopwatch.elapsedMilliseconds > 200) {
final playerState = context.read<PlayerModel>().playerState;
if (_stopwatch.elapsedMilliseconds > 200 ||
playerState == PlayerState.recordingContinuously) {
_stopwatch.stop();
_stopwatch.reset();
int magnitude = max(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.18.1+76
version: 1.18.2+77

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down

0 comments on commit 92a76c2

Please sign in to comment.