This commit is contained in:
Vadim 2023-01-26 23:04:22 +03:00
parent 8c9f3d98f7
commit 827c5e1981
3 changed files with 7 additions and 7 deletions

View file

@ -4,11 +4,11 @@ import 'package:lightmeter/screens/metering/communication/bloc_communication_met
import 'package:lightmeter/screens/metering/communication/state_communication_metering.dart' import 'package:lightmeter/screens/metering/communication/state_communication_metering.dart'
as communication_states; as communication_states;
abstract class EvSourceBloc<E, S> extends Bloc<E, S> { abstract class EvSourceBlocBase<E, S> extends Bloc<E, S> {
final MeteringCommunicationBloc communicationBloc; final MeteringCommunicationBloc communicationBloc;
late final StreamSubscription<communication_states.SourceState> _communicationSubscription; late final StreamSubscription<communication_states.SourceState> _communicationSubscription;
EvSourceBloc(this.communicationBloc, super.initialState) { EvSourceBlocBase(this.communicationBloc, super.initialState) {
_communicationSubscription = communicationBloc.stream _communicationSubscription = communicationBloc.stream
.where((event) => event is communication_states.SourceState) .where((event) => event is communication_states.SourceState)
.map((event) => event as communication_states.SourceState) .map((event) => event as communication_states.SourceState)
@ -18,7 +18,7 @@ abstract class EvSourceBloc<E, S> extends Bloc<E, S> {
@override @override
Future<void> close() async { Future<void> close() async {
await _communicationSubscription.cancel(); await _communicationSubscription.cancel();
super.close(); return super.close();
} }
void onCommunicationState(communication_states.SourceState communicationState); void onCommunicationState(communication_states.SourceState communicationState);

View file

@ -7,7 +7,7 @@ import 'package:exif/exif.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:lightmeter/interactors/metering_interactor.dart'; import 'package:lightmeter/interactors/metering_interactor.dart';
import 'package:lightmeter/screens/metering/ev_source/ev_source_bloc.dart'; import 'package:lightmeter/screens/metering/ev_source/bloc_base_ev_source.dart';
import 'package:lightmeter/screens/metering/communication/bloc_communication_metering.dart'; import 'package:lightmeter/screens/metering/communication/bloc_communication_metering.dart';
import 'package:lightmeter/screens/metering/communication/event_communication_metering.dart' import 'package:lightmeter/screens/metering/communication/event_communication_metering.dart'
as communication_event; as communication_event;
@ -18,7 +18,7 @@ import 'package:lightmeter/utils/log_2.dart';
import 'event_camera.dart'; import 'event_camera.dart';
import 'state_camera.dart'; import 'state_camera.dart';
class CameraBloc extends EvSourceBloc<CameraEvent, CameraState> { class CameraBloc extends EvSourceBlocBase<CameraEvent, CameraState> {
final MeteringInteractor _meteringInteractor; final MeteringInteractor _meteringInteractor;
late final _WidgetsBindingObserver _observer; late final _WidgetsBindingObserver _observer;
CameraController? _cameraController; CameraController? _cameraController;

View file

@ -1,6 +1,6 @@
import 'dart:async'; import 'dart:async';
import 'package:lightmeter/interactors/metering_interactor.dart'; import 'package:lightmeter/interactors/metering_interactor.dart';
import 'package:lightmeter/screens/metering/ev_source/ev_source_bloc.dart'; import 'package:lightmeter/screens/metering/ev_source/bloc_base_ev_source.dart';
import 'package:lightmeter/screens/metering/communication/bloc_communication_metering.dart'; import 'package:lightmeter/screens/metering/communication/bloc_communication_metering.dart';
import 'package:lightmeter/screens/metering/communication/event_communication_metering.dart' import 'package:lightmeter/screens/metering/communication/event_communication_metering.dart'
as communication_event; as communication_event;
@ -11,7 +11,7 @@ import 'package:lightmeter/utils/log_2.dart';
import 'event_light_sensor.dart'; import 'event_light_sensor.dart';
import 'state_light_sensor.dart'; import 'state_light_sensor.dart';
class LightSensorBloc extends EvSourceBloc<LightSensorEvent, LightSensorState> { class LightSensorBloc extends EvSourceBlocBase<LightSensorEvent, LightSensorState> {
final MeteringInteractor _meteringInteractor; final MeteringInteractor _meteringInteractor;
StreamSubscription<int>? _luxSubscriptions; StreamSubscription<int>? _luxSubscriptions;