m3_lightmeter/lib/screens/metering/utils/notifier_volume_keys.dart

35 lines
918 B
Dart
Raw Permalink Normal View History

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:lightmeter/data/models/volume_action.dart';
import 'package:lightmeter/data/volume_events_service.dart';
class VolumeKeysNotifier extends ChangeNotifier with RouteAware {
ML-62 Utils tests (#133) * removed redundant `UserPreferencesService` from `MeteringBloc` * wip * post-merge fixes * `MeasureEvent` tests * `MeasureEvent` tests revision * `MeasureEvent` tests added timeout * added stubs for other `MeteringBloc` events * rewritten `MeteringBloc` logic * wip * `IsoChangedEvent` tests * refined `IsoChangedEvent` tests * `NdChangedEvent` tests * `FilmChangedEvent` tests * `MeteringCommunicationBloc` tests * added test run to ci * overriden `==` for `MeasuredState` * `LuxMeteringEvent` tests * refined `LuxMeteringEvent` tests * rename * wip * wip * `InitializeEvent`/`DeinitializeEvent` tests * clamp minZoomLevel * fixed `MeteringCommunicationBloc` tests * wip * `ZoomChangedEvent` tests * `ExposureOffsetChangedEvent`/`ExposureOffsetResetEvent` tests * renamed test groups * added test coverage script * improved `CameraContainerBloc` test coverage * `EquipmentProfileChangedEvent` tests * verify response vibration * fixed running all tests * `MeteringCommunicationBloc` equality tests * `CameraContainerBloc` equality tests * removed generated code from coverage * `MeteringScreenLayoutFeature` tests * `SupportedLocale` tests * `Film` tests * `CaffeineService` tests * `UserPreferencesService` tests (wip) * `LightSensorService` tests (wip) * `migrateOldKeys()` tests * ignore currently unused getters & setters * gradle upgrade * `reset(sharedPreferences);` calls count * typo * `MeteringInteractor` tests * `SettingsInteractor` tests (wip) * `MeteringInteractor` tests (wip) * `SettingsInteractor` tests * AnimatedDialog picker standalone tests * Moved Animated dialog picker to widget tests * `ExtremeExposurePairsContainer` widget test * dialog picker test * Match extreme exposure pairs & pairs list edge values * `FilmPicker` widget tests * fixed animated dialog picker tests * add not hit files to coverage percentage * Moved `EquipmentProfileProvider` & `FilmsProvider` to the main repo * Synced _iap_ stub with repo * `FilmsProvider` tests * `EquipmentProfileProvider` tests * Pass `availableFilms` to `FilmsProvider` * `FilmPicker` tests * removed unnecessary imports * Metering layout features tests * split integration tests by screens * Films in use test * mock light meter lux stream * removed mockito mocks for integration tests From no on these are the only mocks in use: - Mock shared prefs initial values - Mock platform responses (camera/light sensor) * set sharedprefs mock without redundant group * unified granting camera permission on Android * fixed metering screen tests * extracted common values * `FilmPicker` integration tests * fixed light sensor platform mocks * wip * removed integration tests for now * moved screenshots generator to screenshots folder * typo * removed `MockIAPProductsProvider` * implemented platform mocks for unit tests * data/models/ 100% coverage * `IsoValuePicker` tests * `EquipmentProfileProvider` tests * extended PR check timeout * typo * added storage action verification for `FilmsProvider` tests * `UserPreferencesProvider` tests * Update README.md * added //coverage:ignore to `ServicesProvider` * typo * typo * `toStringSignedAsFixed` tests * `SelectableInheritedModel` tests * removed unused `TextLineHeight` util * `VolumeKeysNotifier` tests * import * `EquipmentProfileListener` tests * typo * split `EquipmentProfileListener` tests * `showBuyProDialog` tests * added `maybeOf` getter for iap stub
2023-11-02 16:40:47 +00:00
final VolumeEventsService _volumeEventsService;
late final StreamSubscription<VolumeKey> _volumeKeysSubscription;
VolumeKey _value = VolumeKey.up;
ML-62 Utils tests (#133) * removed redundant `UserPreferencesService` from `MeteringBloc` * wip * post-merge fixes * `MeasureEvent` tests * `MeasureEvent` tests revision * `MeasureEvent` tests added timeout * added stubs for other `MeteringBloc` events * rewritten `MeteringBloc` logic * wip * `IsoChangedEvent` tests * refined `IsoChangedEvent` tests * `NdChangedEvent` tests * `FilmChangedEvent` tests * `MeteringCommunicationBloc` tests * added test run to ci * overriden `==` for `MeasuredState` * `LuxMeteringEvent` tests * refined `LuxMeteringEvent` tests * rename * wip * wip * `InitializeEvent`/`DeinitializeEvent` tests * clamp minZoomLevel * fixed `MeteringCommunicationBloc` tests * wip * `ZoomChangedEvent` tests * `ExposureOffsetChangedEvent`/`ExposureOffsetResetEvent` tests * renamed test groups * added test coverage script * improved `CameraContainerBloc` test coverage * `EquipmentProfileChangedEvent` tests * verify response vibration * fixed running all tests * `MeteringCommunicationBloc` equality tests * `CameraContainerBloc` equality tests * removed generated code from coverage * `MeteringScreenLayoutFeature` tests * `SupportedLocale` tests * `Film` tests * `CaffeineService` tests * `UserPreferencesService` tests (wip) * `LightSensorService` tests (wip) * `migrateOldKeys()` tests * ignore currently unused getters & setters * gradle upgrade * `reset(sharedPreferences);` calls count * typo * `MeteringInteractor` tests * `SettingsInteractor` tests (wip) * `MeteringInteractor` tests (wip) * `SettingsInteractor` tests * AnimatedDialog picker standalone tests * Moved Animated dialog picker to widget tests * `ExtremeExposurePairsContainer` widget test * dialog picker test * Match extreme exposure pairs & pairs list edge values * `FilmPicker` widget tests * fixed animated dialog picker tests * add not hit files to coverage percentage * Moved `EquipmentProfileProvider` & `FilmsProvider` to the main repo * Synced _iap_ stub with repo * `FilmsProvider` tests * `EquipmentProfileProvider` tests * Pass `availableFilms` to `FilmsProvider` * `FilmPicker` tests * removed unnecessary imports * Metering layout features tests * split integration tests by screens * Films in use test * mock light meter lux stream * removed mockito mocks for integration tests From no on these are the only mocks in use: - Mock shared prefs initial values - Mock platform responses (camera/light sensor) * set sharedprefs mock without redundant group * unified granting camera permission on Android * fixed metering screen tests * extracted common values * `FilmPicker` integration tests * fixed light sensor platform mocks * wip * removed integration tests for now * moved screenshots generator to screenshots folder * typo * removed `MockIAPProductsProvider` * implemented platform mocks for unit tests * data/models/ 100% coverage * `IsoValuePicker` tests * `EquipmentProfileProvider` tests * extended PR check timeout * typo * added storage action verification for `FilmsProvider` tests * `UserPreferencesProvider` tests * Update README.md * added //coverage:ignore to `ServicesProvider` * typo * typo * `toStringSignedAsFixed` tests * `SelectableInheritedModel` tests * removed unused `TextLineHeight` util * `VolumeKeysNotifier` tests * import * `EquipmentProfileListener` tests * typo * split `EquipmentProfileListener` tests * `showBuyProDialog` tests * added `maybeOf` getter for iap stub
2023-11-02 16:40:47 +00:00
VolumeKeysNotifier(this._volumeEventsService) {
_volumeKeysSubscription = _volumeEventsService
.volumeButtonsEventStream()
.map((event) => event == 24 ? VolumeKey.up : VolumeKey.down)
.listen((event) {
value = event;
});
}
VolumeKey get value => _value;
ML-62 Utils tests (#133) * removed redundant `UserPreferencesService` from `MeteringBloc` * wip * post-merge fixes * `MeasureEvent` tests * `MeasureEvent` tests revision * `MeasureEvent` tests added timeout * added stubs for other `MeteringBloc` events * rewritten `MeteringBloc` logic * wip * `IsoChangedEvent` tests * refined `IsoChangedEvent` tests * `NdChangedEvent` tests * `FilmChangedEvent` tests * `MeteringCommunicationBloc` tests * added test run to ci * overriden `==` for `MeasuredState` * `LuxMeteringEvent` tests * refined `LuxMeteringEvent` tests * rename * wip * wip * `InitializeEvent`/`DeinitializeEvent` tests * clamp minZoomLevel * fixed `MeteringCommunicationBloc` tests * wip * `ZoomChangedEvent` tests * `ExposureOffsetChangedEvent`/`ExposureOffsetResetEvent` tests * renamed test groups * added test coverage script * improved `CameraContainerBloc` test coverage * `EquipmentProfileChangedEvent` tests * verify response vibration * fixed running all tests * `MeteringCommunicationBloc` equality tests * `CameraContainerBloc` equality tests * removed generated code from coverage * `MeteringScreenLayoutFeature` tests * `SupportedLocale` tests * `Film` tests * `CaffeineService` tests * `UserPreferencesService` tests (wip) * `LightSensorService` tests (wip) * `migrateOldKeys()` tests * ignore currently unused getters & setters * gradle upgrade * `reset(sharedPreferences);` calls count * typo * `MeteringInteractor` tests * `SettingsInteractor` tests (wip) * `MeteringInteractor` tests (wip) * `SettingsInteractor` tests * AnimatedDialog picker standalone tests * Moved Animated dialog picker to widget tests * `ExtremeExposurePairsContainer` widget test * dialog picker test * Match extreme exposure pairs & pairs list edge values * `FilmPicker` widget tests * fixed animated dialog picker tests * add not hit files to coverage percentage * Moved `EquipmentProfileProvider` & `FilmsProvider` to the main repo * Synced _iap_ stub with repo * `FilmsProvider` tests * `EquipmentProfileProvider` tests * Pass `availableFilms` to `FilmsProvider` * `FilmPicker` tests * removed unnecessary imports * Metering layout features tests * split integration tests by screens * Films in use test * mock light meter lux stream * removed mockito mocks for integration tests From no on these are the only mocks in use: - Mock shared prefs initial values - Mock platform responses (camera/light sensor) * set sharedprefs mock without redundant group * unified granting camera permission on Android * fixed metering screen tests * extracted common values * `FilmPicker` integration tests * fixed light sensor platform mocks * wip * removed integration tests for now * moved screenshots generator to screenshots folder * typo * removed `MockIAPProductsProvider` * implemented platform mocks for unit tests * data/models/ 100% coverage * `IsoValuePicker` tests * `EquipmentProfileProvider` tests * extended PR check timeout * typo * added storage action verification for `FilmsProvider` tests * `UserPreferencesProvider` tests * Update README.md * added //coverage:ignore to `ServicesProvider` * typo * typo * `toStringSignedAsFixed` tests * `SelectableInheritedModel` tests * removed unused `TextLineHeight` util * `VolumeKeysNotifier` tests * import * `EquipmentProfileListener` tests * typo * split `EquipmentProfileListener` tests * `showBuyProDialog` tests * added `maybeOf` getter for iap stub
2023-11-02 16:40:47 +00:00
@protected
set value(VolumeKey newValue) {
_value = newValue;
notifyListeners();
}
@override
Future<void> dispose() async {
await _volumeKeysSubscription.cancel();
super.dispose();
}
}