mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-22 07:20:39 +00:00
Compare commits
No commits in common. "03f57fd20f4b55314d77ebb9db69905609c20bc3" and "bd740cc7dc41bf448197d11a6765ec57a131edd0" have entirely different histories.
03f57fd20f
...
bd740cc7dc
9 changed files with 30 additions and 28 deletions
|
@ -9,7 +9,7 @@ class HapticsService {
|
||||||
|
|
||||||
Future<void> responseVibration() async => _tryVibrate(duration: 50, amplitude: 128);
|
Future<void> responseVibration() async => _tryVibrate(duration: 50, amplitude: 128);
|
||||||
|
|
||||||
Future<void> errorVibration() async => _tryVibrate(duration: 500, amplitude: 128);
|
Future<void> errorVibration() async => _tryVibrate(duration: 100, amplitude: 128);
|
||||||
|
|
||||||
Future<void> _tryVibrate({required int duration, required int amplitude}) async {
|
Future<void> _tryVibrate({required int duration, required int amplitude}) async {
|
||||||
if (await _canVibrate()) {
|
if (await _canVibrate()) {
|
||||||
|
|
|
@ -11,13 +11,13 @@ class TimerInteractor {
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Executes vibration if haptics are enabled in settings
|
/// Executes vibration if haptics are enabled in settings
|
||||||
Future<void> startVibration() async {
|
Future<void> quickVibration() async {
|
||||||
if (_userPreferencesService.haptics) await _hapticsService.quickVibration();
|
if (_userPreferencesService.haptics) await _hapticsService.quickVibration();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Executes vibration if haptics are enabled in settings
|
/// Executes vibration if haptics are enabled in settings
|
||||||
Future<void> endVibration() async {
|
Future<void> responseVibration() async {
|
||||||
if (_userPreferencesService.haptics) await _hapticsService.errorVibration();
|
if (_userPreferencesService.haptics) await _hapticsService.responseVibration();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get isAutostartTimerEnabled => _userPreferencesService.autostartTimer;
|
bool get isAutostartTimerEnabled => _userPreferencesService.autostartTimer;
|
||||||
|
|
|
@ -44,8 +44,9 @@ class ExposurePairsListItem<T extends PhotographyStopValue> extends StatelessWid
|
||||||
case StopType.full:
|
case StopType.full:
|
||||||
return Theme.of(context).textTheme.bodyLarge!;
|
return Theme.of(context).textTheme.bodyLarge!;
|
||||||
case StopType.half:
|
case StopType.half:
|
||||||
case StopType.third:
|
|
||||||
return Theme.of(context).textTheme.bodyMedium!;
|
return Theme.of(context).textTheme.bodyMedium!;
|
||||||
|
case StopType.third:
|
||||||
|
return Theme.of(context).textTheme.bodySmall!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +55,7 @@ class ExposurePairsListItem<T extends PhotographyStopValue> extends StatelessWid
|
||||||
case StopType.full:
|
case StopType.full:
|
||||||
return Dimens.grid16;
|
return Dimens.grid16;
|
||||||
case StopType.half:
|
case StopType.half:
|
||||||
|
return Dimens.grid8;
|
||||||
case StopType.third:
|
case StopType.third:
|
||||||
return Dimens.grid8;
|
return Dimens.grid8;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ class ReadingValueContainer extends StatelessWidget implements AnimatedDialogClo
|
||||||
top: 0,
|
top: 0,
|
||||||
right: 0,
|
right: 0,
|
||||||
child: Icon(
|
child: Icon(
|
||||||
Icons.lock,
|
Icons.lock_outline,
|
||||||
size: Theme.of(context).textTheme.labelMedium!.fontSize,
|
size: Theme.of(context).textTheme.labelMedium!.fontSize,
|
||||||
color: Theme.of(context).colorScheme.onPrimaryContainer,
|
color: Theme.of(context).colorScheme.onPrimaryContainer,
|
||||||
),
|
),
|
||||||
|
|
|
@ -19,19 +19,19 @@ class TimerBloc extends Bloc<TimerEvent, TimerState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onStartTimer(StartTimerEvent _, Emitter emit) async {
|
Future<void> _onStartTimer(StartTimerEvent _, Emitter emit) async {
|
||||||
_timerInteractor.startVibration();
|
_timerInteractor.quickVibration();
|
||||||
emit(const TimerResumedState());
|
emit(const TimerResumedState());
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onTimerEnded(TimerEndedEvent event, Emitter emit) async {
|
Future<void> _onTimerEnded(TimerEndedEvent event, Emitter emit) async {
|
||||||
if (state is! TimerResetState) {
|
if (state is! TimerResetState) {
|
||||||
_timerInteractor.endVibration();
|
_timerInteractor.responseVibration();
|
||||||
emit(const TimerStoppedState());
|
emit(const TimerStoppedState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onStopTimer(StopTimerEvent _, Emitter emit) async {
|
Future<void> _onStopTimer(StopTimerEvent _, Emitter emit) async {
|
||||||
_timerInteractor.startVibration();
|
_timerInteractor.quickVibration();
|
||||||
emit(const TimerStoppedState());
|
emit(const TimerStoppedState());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,36 +27,36 @@ void main() {
|
||||||
group(
|
group(
|
||||||
'Haptics',
|
'Haptics',
|
||||||
() {
|
() {
|
||||||
test('startVibration() - true', () async {
|
test('quickVibration() - true', () async {
|
||||||
when(() => mockUserPreferencesService.haptics).thenReturn(true);
|
when(() => mockUserPreferencesService.haptics).thenReturn(true);
|
||||||
when(() => mockHapticsService.quickVibration()).thenAnswer((_) async {});
|
when(() => mockHapticsService.quickVibration()).thenAnswer((_) async {});
|
||||||
interactor.startVibration();
|
interactor.quickVibration();
|
||||||
verify(() => mockUserPreferencesService.haptics).called(1);
|
verify(() => mockUserPreferencesService.haptics).called(1);
|
||||||
verify(() => mockHapticsService.quickVibration()).called(1);
|
verify(() => mockHapticsService.quickVibration()).called(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('startVibration() - false', () async {
|
test('quickVibration() - false', () async {
|
||||||
when(() => mockUserPreferencesService.haptics).thenReturn(false);
|
when(() => mockUserPreferencesService.haptics).thenReturn(false);
|
||||||
when(() => mockHapticsService.quickVibration()).thenAnswer((_) async {});
|
when(() => mockHapticsService.quickVibration()).thenAnswer((_) async {});
|
||||||
interactor.startVibration();
|
interactor.quickVibration();
|
||||||
verify(() => mockUserPreferencesService.haptics).called(1);
|
verify(() => mockUserPreferencesService.haptics).called(1);
|
||||||
verifyNever(() => mockHapticsService.quickVibration());
|
verifyNever(() => mockHapticsService.quickVibration());
|
||||||
});
|
});
|
||||||
|
|
||||||
test('endVibration() - true', () async {
|
test('responseVibration() - true', () async {
|
||||||
when(() => mockUserPreferencesService.haptics).thenReturn(true);
|
when(() => mockUserPreferencesService.haptics).thenReturn(true);
|
||||||
when(() => mockHapticsService.errorVibration()).thenAnswer((_) async {});
|
when(() => mockHapticsService.responseVibration()).thenAnswer((_) async {});
|
||||||
interactor.endVibration();
|
interactor.responseVibration();
|
||||||
verify(() => mockUserPreferencesService.haptics).called(1);
|
verify(() => mockUserPreferencesService.haptics).called(1);
|
||||||
verify(() => mockHapticsService.errorVibration()).called(1);
|
verify(() => mockHapticsService.responseVibration()).called(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('endVibration() - false', () async {
|
test('responseVibration() - false', () async {
|
||||||
when(() => mockUserPreferencesService.haptics).thenReturn(false);
|
when(() => mockUserPreferencesService.haptics).thenReturn(false);
|
||||||
when(() => mockHapticsService.errorVibration()).thenAnswer((_) async {});
|
when(() => mockHapticsService.responseVibration()).thenAnswer((_) async {});
|
||||||
interactor.endVibration();
|
interactor.responseVibration();
|
||||||
verify(() => mockUserPreferencesService.haptics).called(1);
|
verify(() => mockUserPreferencesService.haptics).called(1);
|
||||||
verifyNever(() => mockHapticsService.errorVibration());
|
verifyNever(() => mockHapticsService.responseVibration());
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 1.6 MiB |
|
@ -14,15 +14,15 @@ void main() {
|
||||||
setUpAll(() {
|
setUpAll(() {
|
||||||
timerInteractor = _MockTimerInteractor();
|
timerInteractor = _MockTimerInteractor();
|
||||||
when(() => timerInteractor.isAutostartTimerEnabled).thenReturn(true);
|
when(() => timerInteractor.isAutostartTimerEnabled).thenReturn(true);
|
||||||
when(timerInteractor.startVibration).thenAnswer((_) async {});
|
when(timerInteractor.quickVibration).thenAnswer((_) async {});
|
||||||
when(timerInteractor.endVibration).thenAnswer((_) async {});
|
when(timerInteractor.responseVibration).thenAnswer((_) async {});
|
||||||
});
|
});
|
||||||
|
|
||||||
blocTest<TimerBloc, TimerState>(
|
blocTest<TimerBloc, TimerState>(
|
||||||
'Autostart',
|
'Autostart',
|
||||||
build: () => TimerBloc(timerInteractor, const Duration(seconds: 1)),
|
build: () => TimerBloc(timerInteractor, const Duration(seconds: 1)),
|
||||||
verify: (_) {
|
verify: (_) {
|
||||||
verify(() => timerInteractor.startVibration()).called(1);
|
verify(() => timerInteractor.quickVibration()).called(1);
|
||||||
},
|
},
|
||||||
expect: () => [
|
expect: () => [
|
||||||
isA<TimerResumedState>(),
|
isA<TimerResumedState>(),
|
||||||
|
@ -41,8 +41,8 @@ void main() {
|
||||||
bloc.add(const ResetTimerEvent());
|
bloc.add(const ResetTimerEvent());
|
||||||
},
|
},
|
||||||
verify: (_) {
|
verify: (_) {
|
||||||
verify(() => timerInteractor.startVibration()).called(1);
|
verify(() => timerInteractor.quickVibration()).called(1);
|
||||||
verify(() => timerInteractor.endVibration()).called(1);
|
verify(() => timerInteractor.responseVibration()).called(1);
|
||||||
},
|
},
|
||||||
expect: () => [
|
expect: () => [
|
||||||
isA<TimerResumedState>(),
|
isA<TimerResumedState>(),
|
||||||
|
@ -64,8 +64,8 @@ void main() {
|
||||||
bloc.add(const TimerEndedEvent());
|
bloc.add(const TimerEndedEvent());
|
||||||
},
|
},
|
||||||
verify: (_) {
|
verify: (_) {
|
||||||
verify(() => timerInteractor.startVibration()).called(3);
|
verify(() => timerInteractor.quickVibration()).called(3);
|
||||||
verify(() => timerInteractor.endVibration()).called(1);
|
verify(() => timerInteractor.responseVibration()).called(1);
|
||||||
},
|
},
|
||||||
expect: () => [
|
expect: () => [
|
||||||
isA<TimerResumedState>(),
|
isA<TimerResumedState>(),
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 854 KiB After Width: | Height: | Size: 854 KiB |
Loading…
Reference in a new issue