From 26752073f693622d11331905a87d81910c59f6d1 Mon Sep 17 00:00:00 2001 From: Vadim <44135514+vodemn@users.noreply.github.com> Date: Mon, 6 May 2024 14:14:50 +0200 Subject: [PATCH] increased timer vibration duration --- lib/data/haptics_service.dart | 2 +- lib/interactors/timer_interactor.dart | 6 +++--- lib/screens/timer/bloc_timer.dart | 6 +++--- test/interactors/timer_interactor_test.dart | 24 ++++++++++----------- test/screens/timer/bloc_timer_test.dart | 14 ++++++------ 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/lib/data/haptics_service.dart b/lib/data/haptics_service.dart index f1bdc6b..09113b4 100644 --- a/lib/data/haptics_service.dart +++ b/lib/data/haptics_service.dart @@ -9,7 +9,7 @@ class HapticsService { Future responseVibration() async => _tryVibrate(duration: 50, amplitude: 128); - Future errorVibration() async => _tryVibrate(duration: 100, amplitude: 128); + Future errorVibration() async => _tryVibrate(duration: 500, amplitude: 128); Future _tryVibrate({required int duration, required int amplitude}) async { if (await _canVibrate()) { diff --git a/lib/interactors/timer_interactor.dart b/lib/interactors/timer_interactor.dart index 65f1b59..08b88ed 100644 --- a/lib/interactors/timer_interactor.dart +++ b/lib/interactors/timer_interactor.dart @@ -11,13 +11,13 @@ class TimerInteractor { ); /// Executes vibration if haptics are enabled in settings - Future quickVibration() async { + Future startVibration() async { if (_userPreferencesService.haptics) await _hapticsService.quickVibration(); } /// Executes vibration if haptics are enabled in settings - Future responseVibration() async { - if (_userPreferencesService.haptics) await _hapticsService.responseVibration(); + Future endVibration() async { + if (_userPreferencesService.haptics) await _hapticsService.errorVibration(); } bool get isAutostartTimerEnabled => _userPreferencesService.autostartTimer; diff --git a/lib/screens/timer/bloc_timer.dart b/lib/screens/timer/bloc_timer.dart index 93f1083..eacdf47 100644 --- a/lib/screens/timer/bloc_timer.dart +++ b/lib/screens/timer/bloc_timer.dart @@ -19,19 +19,19 @@ class TimerBloc extends Bloc { } Future _onStartTimer(StartTimerEvent _, Emitter emit) async { - _timerInteractor.quickVibration(); + _timerInteractor.startVibration(); emit(const TimerResumedState()); } Future _onTimerEnded(TimerEndedEvent event, Emitter emit) async { if (state is! TimerResetState) { - _timerInteractor.responseVibration(); + _timerInteractor.endVibration(); emit(const TimerStoppedState()); } } Future _onStopTimer(StopTimerEvent _, Emitter emit) async { - _timerInteractor.quickVibration(); + _timerInteractor.startVibration(); emit(const TimerStoppedState()); } diff --git a/test/interactors/timer_interactor_test.dart b/test/interactors/timer_interactor_test.dart index 3c153e9..7ebf350 100644 --- a/test/interactors/timer_interactor_test.dart +++ b/test/interactors/timer_interactor_test.dart @@ -27,36 +27,36 @@ void main() { group( 'Haptics', () { - test('quickVibration() - true', () async { + test('startVibration() - true', () async { when(() => mockUserPreferencesService.haptics).thenReturn(true); when(() => mockHapticsService.quickVibration()).thenAnswer((_) async {}); - interactor.quickVibration(); + interactor.startVibration(); verify(() => mockUserPreferencesService.haptics).called(1); verify(() => mockHapticsService.quickVibration()).called(1); }); - test('quickVibration() - false', () async { + test('startVibration() - false', () async { when(() => mockUserPreferencesService.haptics).thenReturn(false); when(() => mockHapticsService.quickVibration()).thenAnswer((_) async {}); - interactor.quickVibration(); + interactor.startVibration(); verify(() => mockUserPreferencesService.haptics).called(1); verifyNever(() => mockHapticsService.quickVibration()); }); - test('responseVibration() - true', () async { + test('endVibration() - true', () async { when(() => mockUserPreferencesService.haptics).thenReturn(true); - when(() => mockHapticsService.responseVibration()).thenAnswer((_) async {}); - interactor.responseVibration(); + when(() => mockHapticsService.errorVibration()).thenAnswer((_) async {}); + interactor.endVibration(); verify(() => mockUserPreferencesService.haptics).called(1); - verify(() => mockHapticsService.responseVibration()).called(1); + verify(() => mockHapticsService.errorVibration()).called(1); }); - test('responseVibration() - false', () async { + test('endVibration() - false', () async { when(() => mockUserPreferencesService.haptics).thenReturn(false); - when(() => mockHapticsService.responseVibration()).thenAnswer((_) async {}); - interactor.responseVibration(); + when(() => mockHapticsService.errorVibration()).thenAnswer((_) async {}); + interactor.endVibration(); verify(() => mockUserPreferencesService.haptics).called(1); - verifyNever(() => mockHapticsService.responseVibration()); + verifyNever(() => mockHapticsService.errorVibration()); }); }, ); diff --git a/test/screens/timer/bloc_timer_test.dart b/test/screens/timer/bloc_timer_test.dart index 845edb0..35d795b 100644 --- a/test/screens/timer/bloc_timer_test.dart +++ b/test/screens/timer/bloc_timer_test.dart @@ -14,15 +14,15 @@ void main() { setUpAll(() { timerInteractor = _MockTimerInteractor(); when(() => timerInteractor.isAutostartTimerEnabled).thenReturn(true); - when(timerInteractor.quickVibration).thenAnswer((_) async {}); - when(timerInteractor.responseVibration).thenAnswer((_) async {}); + when(timerInteractor.startVibration).thenAnswer((_) async {}); + when(timerInteractor.endVibration).thenAnswer((_) async {}); }); blocTest( 'Autostart', build: () => TimerBloc(timerInteractor, const Duration(seconds: 1)), verify: (_) { - verify(() => timerInteractor.quickVibration()).called(1); + verify(() => timerInteractor.startVibration()).called(1); }, expect: () => [ isA(), @@ -41,8 +41,8 @@ void main() { bloc.add(const ResetTimerEvent()); }, verify: (_) { - verify(() => timerInteractor.quickVibration()).called(1); - verify(() => timerInteractor.responseVibration()).called(1); + verify(() => timerInteractor.startVibration()).called(1); + verify(() => timerInteractor.endVibration()).called(1); }, expect: () => [ isA(), @@ -64,8 +64,8 @@ void main() { bloc.add(const TimerEndedEvent()); }, verify: (_) { - verify(() => timerInteractor.quickVibration()).called(3); - verify(() => timerInteractor.responseVibration()).called(1); + verify(() => timerInteractor.startVibration()).called(3); + verify(() => timerInteractor.endVibration()).called(1); }, expect: () => [ isA(),