mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-21 23:10:40 +00:00
removed UserPreferencesService
from MeteringBloc
This commit is contained in:
parent
423694a50c
commit
46d4727629
4 changed files with 21 additions and 18 deletions
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
|
@ -8,7 +8,6 @@
|
|||
"name": "dev (android)",
|
||||
"request": "launch",
|
||||
"type": "dart",
|
||||
//"flutterMode": "profile",
|
||||
"args": [
|
||||
"--flavor",
|
||||
"dev",
|
||||
|
@ -21,7 +20,6 @@
|
|||
"name": "dev (ios)",
|
||||
"request": "launch",
|
||||
"type": "dart",
|
||||
//"flutterMode": "release",
|
||||
"args": [
|
||||
"--flavor",
|
||||
"dev",
|
||||
|
|
|
@ -4,8 +4,10 @@ import 'package:app_settings/app_settings.dart';
|
|||
import 'package:lightmeter/data/caffeine_service.dart';
|
||||
import 'package:lightmeter/data/haptics_service.dart';
|
||||
import 'package:lightmeter/data/light_sensor_service.dart';
|
||||
import 'package:lightmeter/data/models/film.dart';
|
||||
import 'package:lightmeter/data/permissions_service.dart';
|
||||
import 'package:lightmeter/data/shared_prefs_service.dart';
|
||||
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
class MeteringInteractor {
|
||||
|
@ -30,7 +32,14 @@ class MeteringInteractor {
|
|||
double get cameraEvCalibration => _userPreferencesService.cameraEvCalibration;
|
||||
double get lightSensorEvCalibration => _userPreferencesService.lightSensorEvCalibration;
|
||||
|
||||
bool get isHapticsEnabled => _userPreferencesService.haptics;
|
||||
IsoValue get iso => _userPreferencesService.iso;
|
||||
set iso(IsoValue value) => _userPreferencesService.iso = value;
|
||||
|
||||
NdValue get ndFilter => _userPreferencesService.ndFilter;
|
||||
set ndFilter(NdValue value) => _userPreferencesService.ndFilter = value;
|
||||
|
||||
Film get film => _userPreferencesService.film;
|
||||
set film(Film value) => _userPreferencesService.film = value;
|
||||
|
||||
/// Executes vibration if haptics are enabled in settings
|
||||
Future<void> quickVibration() async {
|
||||
|
|
|
@ -4,7 +4,6 @@ import 'dart:math';
|
|||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:lightmeter/data/models/exposure_pair.dart';
|
||||
import 'package:lightmeter/data/models/film.dart';
|
||||
import 'package:lightmeter/data/shared_prefs_service.dart';
|
||||
import 'package:lightmeter/interactors/metering_interactor.dart';
|
||||
import 'package:lightmeter/screens/metering/communication/bloc_communication_metering.dart';
|
||||
import 'package:lightmeter/screens/metering/communication/event_communication_metering.dart'
|
||||
|
@ -17,7 +16,6 @@ import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
|||
|
||||
class MeteringBloc extends Bloc<MeteringEvent, MeteringState> {
|
||||
final MeteringCommunicationBloc _communicationBloc;
|
||||
final UserPreferencesService _userPreferencesService;
|
||||
final MeteringInteractor _meteringInteractor;
|
||||
late final StreamSubscription<communication_states.ScreenState> _communicationSubscription;
|
||||
|
||||
|
@ -29,24 +27,23 @@ class MeteringBloc extends Bloc<MeteringEvent, MeteringState> {
|
|||
EquipmentProfileData _equipmentProfileData;
|
||||
StopType stopType;
|
||||
|
||||
late IsoValue _iso = _userPreferencesService.iso;
|
||||
late NdValue _nd = _userPreferencesService.ndFilter;
|
||||
late Film _film = _userPreferencesService.film;
|
||||
late IsoValue _iso = _meteringInteractor.iso;
|
||||
late NdValue _nd = _meteringInteractor.ndFilter;
|
||||
late Film _film = _meteringInteractor.film;
|
||||
double? _ev100 = 0.0;
|
||||
bool _isMeteringInProgress = false;
|
||||
|
||||
MeteringBloc(
|
||||
this._communicationBloc,
|
||||
this._userPreferencesService,
|
||||
this._meteringInteractor,
|
||||
this._equipmentProfileData,
|
||||
this.stopType,
|
||||
) : super(
|
||||
MeteringDataState(
|
||||
ev: 0.0,
|
||||
film: _userPreferencesService.film,
|
||||
iso: _userPreferencesService.iso,
|
||||
nd: _userPreferencesService.ndFilter,
|
||||
film: _meteringInteractor.film,
|
||||
iso: _meteringInteractor.iso,
|
||||
nd: _meteringInteractor.ndFilter,
|
||||
exposurePairs: const [],
|
||||
continuousMetering: false,
|
||||
),
|
||||
|
@ -90,13 +87,13 @@ class MeteringBloc extends Bloc<MeteringEvent, MeteringState> {
|
|||
/// Update selected ISO value, if selected equipment profile
|
||||
/// doesn't contain currently selected value
|
||||
if (!event.equipmentProfileData.isoValues.any((v) => _iso.value == v.value)) {
|
||||
_userPreferencesService.iso = event.equipmentProfileData.isoValues.first;
|
||||
_meteringInteractor.iso = event.equipmentProfileData.isoValues.first;
|
||||
_iso = event.equipmentProfileData.isoValues.first;
|
||||
}
|
||||
|
||||
/// The same for ND filter
|
||||
if (!event.equipmentProfileData.ndValues.any((v) => _nd.value == v.value)) {
|
||||
_userPreferencesService.ndFilter = event.equipmentProfileData.ndValues.first;
|
||||
_meteringInteractor.ndFilter = event.equipmentProfileData.ndValues.first;
|
||||
_nd = event.equipmentProfileData.ndValues.first;
|
||||
}
|
||||
|
||||
|
@ -112,7 +109,7 @@ class MeteringBloc extends Bloc<MeteringEvent, MeteringState> {
|
|||
add(IsoChangedEvent(newIso));
|
||||
}
|
||||
_film = event.data;
|
||||
_userPreferencesService.film = event.data;
|
||||
_meteringInteractor.film = event.data;
|
||||
_updateMeasurements();
|
||||
}
|
||||
|
||||
|
@ -120,13 +117,13 @@ class MeteringBloc extends Bloc<MeteringEvent, MeteringState> {
|
|||
if (event.isoValue.value != _film.iso) {
|
||||
_film = Film.values.first;
|
||||
}
|
||||
_userPreferencesService.iso = event.isoValue;
|
||||
_meteringInteractor.iso = event.isoValue;
|
||||
_iso = event.isoValue;
|
||||
_updateMeasurements();
|
||||
}
|
||||
|
||||
void _onNdChanged(NdChangedEvent event, Emitter emit) {
|
||||
_userPreferencesService.ndFilter = event.ndValue;
|
||||
_meteringInteractor.ndFilter = event.ndValue;
|
||||
_nd = event.ndValue;
|
||||
_updateMeasurements();
|
||||
}
|
||||
|
|
|
@ -37,7 +37,6 @@ class _MeteringFlowState extends State<MeteringFlow> {
|
|||
BlocProvider(
|
||||
create: (context) => MeteringBloc(
|
||||
context.read<MeteringCommunicationBloc>(),
|
||||
context.read<UserPreferencesService>(),
|
||||
context.read<MeteringInteractor>(),
|
||||
EquipmentProfile.of(context, listen: false),
|
||||
context.read<StopType>(),
|
||||
|
|
Loading…
Reference in a new issue