mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-21 15:00:40 +00:00
Compare commits
3 commits
bd740cc7dc
...
03f57fd20f
Author | SHA1 | Date | |
---|---|---|---|
|
03f57fd20f | ||
|
1ae8b0913e | ||
|
26752073f6 |
9 changed files with 28 additions and 30 deletions
|
@ -9,7 +9,7 @@ class HapticsService {
|
|||
|
||||
Future<void> responseVibration() async => _tryVibrate(duration: 50, amplitude: 128);
|
||||
|
||||
Future<void> errorVibration() async => _tryVibrate(duration: 100, amplitude: 128);
|
||||
Future<void> errorVibration() async => _tryVibrate(duration: 500, amplitude: 128);
|
||||
|
||||
Future<void> _tryVibrate({required int duration, required int amplitude}) async {
|
||||
if (await _canVibrate()) {
|
||||
|
|
|
@ -11,13 +11,13 @@ class TimerInteractor {
|
|||
);
|
||||
|
||||
/// Executes vibration if haptics are enabled in settings
|
||||
Future<void> quickVibration() async {
|
||||
Future<void> startVibration() async {
|
||||
if (_userPreferencesService.haptics) await _hapticsService.quickVibration();
|
||||
}
|
||||
|
||||
/// Executes vibration if haptics are enabled in settings
|
||||
Future<void> responseVibration() async {
|
||||
if (_userPreferencesService.haptics) await _hapticsService.responseVibration();
|
||||
Future<void> endVibration() async {
|
||||
if (_userPreferencesService.haptics) await _hapticsService.errorVibration();
|
||||
}
|
||||
|
||||
bool get isAutostartTimerEnabled => _userPreferencesService.autostartTimer;
|
||||
|
|
|
@ -44,9 +44,8 @@ class ExposurePairsListItem<T extends PhotographyStopValue> extends StatelessWid
|
|||
case StopType.full:
|
||||
return Theme.of(context).textTheme.bodyLarge!;
|
||||
case StopType.half:
|
||||
return Theme.of(context).textTheme.bodyMedium!;
|
||||
case StopType.third:
|
||||
return Theme.of(context).textTheme.bodySmall!;
|
||||
return Theme.of(context).textTheme.bodyMedium!;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,7 +54,6 @@ class ExposurePairsListItem<T extends PhotographyStopValue> extends StatelessWid
|
|||
case StopType.full:
|
||||
return Dimens.grid16;
|
||||
case StopType.half:
|
||||
return Dimens.grid8;
|
||||
case StopType.third:
|
||||
return Dimens.grid8;
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ class ReadingValueContainer extends StatelessWidget implements AnimatedDialogClo
|
|||
top: 0,
|
||||
right: 0,
|
||||
child: Icon(
|
||||
Icons.lock_outline,
|
||||
Icons.lock,
|
||||
size: Theme.of(context).textTheme.labelMedium!.fontSize,
|
||||
color: Theme.of(context).colorScheme.onPrimaryContainer,
|
||||
),
|
||||
|
|
|
@ -19,19 +19,19 @@ class TimerBloc extends Bloc<TimerEvent, TimerState> {
|
|||
}
|
||||
|
||||
Future<void> _onStartTimer(StartTimerEvent _, Emitter emit) async {
|
||||
_timerInteractor.quickVibration();
|
||||
_timerInteractor.startVibration();
|
||||
emit(const TimerResumedState());
|
||||
}
|
||||
|
||||
Future<void> _onTimerEnded(TimerEndedEvent event, Emitter emit) async {
|
||||
if (state is! TimerResetState) {
|
||||
_timerInteractor.responseVibration();
|
||||
_timerInteractor.endVibration();
|
||||
emit(const TimerStoppedState());
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onStopTimer(StopTimerEvent _, Emitter emit) async {
|
||||
_timerInteractor.quickVibration();
|
||||
_timerInteractor.startVibration();
|
||||
emit(const TimerStoppedState());
|
||||
}
|
||||
|
||||
|
|
|
@ -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());
|
||||
});
|
||||
},
|
||||
);
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.6 MiB After Width: | Height: | Size: 1.5 MiB |
|
@ -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<TimerBloc, TimerState>(
|
||||
'Autostart',
|
||||
build: () => TimerBloc(timerInteractor, const Duration(seconds: 1)),
|
||||
verify: (_) {
|
||||
verify(() => timerInteractor.quickVibration()).called(1);
|
||||
verify(() => timerInteractor.startVibration()).called(1);
|
||||
},
|
||||
expect: () => [
|
||||
isA<TimerResumedState>(),
|
||||
|
@ -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<TimerResumedState>(),
|
||||
|
@ -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<TimerResumedState>(),
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 854 KiB After Width: | Height: | Size: 854 KiB |
Loading…
Reference in a new issue