filter equipment profile update/delete

This commit is contained in:
Vadim 2023-03-23 23:12:14 +03:00
parent 21c1d94af7
commit ce4af92b4d
7 changed files with 9 additions and 24 deletions

View file

@ -63,12 +63,18 @@ class EquipmentProfileProviderState extends State<EquipmentProfileProvider> {
final indexToUpdate = _profiles.indexWhere((element) => element.id == data.id); final indexToUpdate = _profiles.indexWhere((element) => element.id == data.id);
if (indexToUpdate >= 0) { if (indexToUpdate >= 0) {
_profiles[indexToUpdate] = data; _profiles[indexToUpdate] = data;
if (data.id == _selectedProfile.id) {
_selectedProfile = _profiles[indexToUpdate];
}
setState(() {}); setState(() {});
} }
} }
void deleteProfile(EquipmentProfileData data) { void deleteProfile(EquipmentProfileData data) {
_profiles.remove(data); _profiles.remove(data);
if (data.id == _selectedProfile.id) {
_selectedProfile = _profiles.first;
}
setState(() {}); setState(() {});
} }
} }

View file

@ -10,7 +10,6 @@ import 'bloc_container_camera.dart';
import 'widget_container_camera.dart'; import 'widget_container_camera.dart';
class CameraContainerProvider extends StatelessWidget { class CameraContainerProvider extends StatelessWidget {
final ValueChanged<EquipmentProfileData> onEquipmentProfileChanged;
final ExposurePair? fastest; final ExposurePair? fastest;
final ExposurePair? slowest; final ExposurePair? slowest;
final IsoValue iso; final IsoValue iso;
@ -20,7 +19,6 @@ class CameraContainerProvider extends StatelessWidget {
final List<ExposurePair> exposurePairs; final List<ExposurePair> exposurePairs;
const CameraContainerProvider({ const CameraContainerProvider({
required this.onEquipmentProfileChanged,
required this.fastest, required this.fastest,
required this.slowest, required this.slowest,
required this.iso, required this.iso,
@ -40,7 +38,6 @@ class CameraContainerProvider extends StatelessWidget {
context.read<MeteringCommunicationBloc>(), context.read<MeteringCommunicationBloc>(),
), ),
child: CameraContainer( child: CameraContainer(
onEquipmentProfileChanged: onEquipmentProfileChanged,
fastest: fastest, fastest: fastest,
slowest: slowest, slowest: slowest,
isoValues: EquipmentProfile.of(context)?.isoValues ?? isoValues, isoValues: EquipmentProfile.of(context)?.isoValues ?? isoValues,

View file

@ -19,7 +19,6 @@ import 'event_container_camera.dart';
import 'state_container_camera.dart'; import 'state_container_camera.dart';
class CameraContainer extends StatelessWidget { class CameraContainer extends StatelessWidget {
final ValueChanged<EquipmentProfileData> onEquipmentProfileChanged;
final ExposurePair? fastest; final ExposurePair? fastest;
final ExposurePair? slowest; final ExposurePair? slowest;
final List<IsoValue> isoValues; final List<IsoValue> isoValues;
@ -31,7 +30,6 @@ class CameraContainer extends StatelessWidget {
final List<ExposurePair> exposurePairs; final List<ExposurePair> exposurePairs;
const CameraContainer({ const CameraContainer({
required this.onEquipmentProfileChanged,
required this.fastest, required this.fastest,
required this.slowest, required this.slowest,
required this.isoValues, required this.isoValues,
@ -60,7 +58,6 @@ class CameraContainer extends StatelessWidget {
children: [ children: [
MeteringTopBar( MeteringTopBar(
readingsContainer: ReadingsContainer( readingsContainer: ReadingsContainer(
onEquipmentProfileChanged: onEquipmentProfileChanged,
fastest: fastest, fastest: fastest,
slowest: slowest, slowest: slowest,
isoValues: isoValues, isoValues: isoValues,

View file

@ -10,7 +10,6 @@ import 'bloc_container_light_sensor.dart';
import 'widget_container_light_sensor.dart'; import 'widget_container_light_sensor.dart';
class LightSensorContainerProvider extends StatelessWidget { class LightSensorContainerProvider extends StatelessWidget {
final ValueChanged<EquipmentProfileData> onEquipmentProfileChanged;
final ExposurePair? fastest; final ExposurePair? fastest;
final ExposurePair? slowest; final ExposurePair? slowest;
final IsoValue iso; final IsoValue iso;
@ -20,7 +19,6 @@ class LightSensorContainerProvider extends StatelessWidget {
final List<ExposurePair> exposurePairs; final List<ExposurePair> exposurePairs;
const LightSensorContainerProvider({ const LightSensorContainerProvider({
required this.onEquipmentProfileChanged,
required this.fastest, required this.fastest,
required this.slowest, required this.slowest,
required this.iso, required this.iso,
@ -40,7 +38,6 @@ class LightSensorContainerProvider extends StatelessWidget {
context.read<MeteringCommunicationBloc>(), context.read<MeteringCommunicationBloc>(),
), ),
child: LightSensorContainer( child: LightSensorContainer(
onEquipmentProfileChanged: onEquipmentProfileChanged,
fastest: fastest, fastest: fastest,
slowest: slowest, slowest: slowest,
isoValues: EquipmentProfile.of(context)?.isoValues ?? isoValues, isoValues: EquipmentProfile.of(context)?.isoValues ?? isoValues,

View file

@ -7,7 +7,6 @@ import 'package:lightmeter/screens/metering/components/shared/readings_container
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
class LightSensorContainer extends StatelessWidget { class LightSensorContainer extends StatelessWidget {
final ValueChanged<EquipmentProfileData> onEquipmentProfileChanged;
final ExposurePair? fastest; final ExposurePair? fastest;
final ExposurePair? slowest; final ExposurePair? slowest;
final List<IsoValue> isoValues; final List<IsoValue> isoValues;
@ -19,7 +18,6 @@ class LightSensorContainer extends StatelessWidget {
final List<ExposurePair> exposurePairs; final List<ExposurePair> exposurePairs;
const LightSensorContainer({ const LightSensorContainer({
required this.onEquipmentProfileChanged,
required this.fastest, required this.fastest,
required this.slowest, required this.slowest,
required this.isoValues, required this.isoValues,
@ -38,7 +36,6 @@ class LightSensorContainer extends StatelessWidget {
children: [ children: [
MeteringTopBar( MeteringTopBar(
readingsContainer: ReadingsContainer( readingsContainer: ReadingsContainer(
onEquipmentProfileChanged: onEquipmentProfileChanged,
fastest: fastest, fastest: fastest,
slowest: slowest, slowest: slowest,
isoValues: isoValues, isoValues: isoValues,

View file

@ -10,7 +10,6 @@ import 'components/reading_value_container/widget_container_reading_value.dart';
/// Contains a column of fastest & slowest exposure pairs + a row of ISO and ND pickers /// Contains a column of fastest & slowest exposure pairs + a row of ISO and ND pickers
class ReadingsContainer extends StatelessWidget { class ReadingsContainer extends StatelessWidget {
final ValueChanged<EquipmentProfileData> onEquipmentProfileChanged;
final ExposurePair? fastest; final ExposurePair? fastest;
final ExposurePair? slowest; final ExposurePair? slowest;
final List<IsoValue> isoValues; final List<IsoValue> isoValues;
@ -21,7 +20,6 @@ class ReadingsContainer extends StatelessWidget {
final ValueChanged<NdValue> onNdChanged; final ValueChanged<NdValue> onNdChanged;
const ReadingsContainer({ const ReadingsContainer({
required this.onEquipmentProfileChanged,
required this.fastest, required this.fastest,
required this.slowest, required this.slowest,
required this.isoValues, required this.isoValues,
@ -43,10 +41,7 @@ class ReadingsContainer extends StatelessWidget {
_EquipmentProfilePicker( _EquipmentProfilePicker(
selectedValue: EquipmentProfile.of(context)!, selectedValue: EquipmentProfile.of(context)!,
values: EquipmentProfiles.of(context)!, values: EquipmentProfiles.of(context)!,
onChanged: (value) { onChanged: EquipmentProfileProvider.of(context).setProfile,
EquipmentProfileProvider.of(context).setProfile(value);
onEquipmentProfileChanged(value);
},
), ),
const _InnerPadding(), const _InnerPadding(),
], ],

View file

@ -3,6 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:lightmeter/data/models/ev_source_type.dart'; import 'package:lightmeter/data/models/ev_source_type.dart';
import 'package:lightmeter/data/models/exposure_pair.dart'; import 'package:lightmeter/data/models/exposure_pair.dart';
import 'package:lightmeter/environment.dart'; import 'package:lightmeter/environment.dart';
import 'package:lightmeter/providers/equipment_profile_provider.dart';
import 'package:lightmeter/providers/ev_source_type_provider.dart'; import 'package:lightmeter/providers/ev_source_type_provider.dart';
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
@ -26,6 +27,7 @@ class _MeteringScreenState extends State<MeteringScreen> {
@override @override
void didChangeDependencies() { void didChangeDependencies() {
super.didChangeDependencies(); super.didChangeDependencies();
_bloc.add(EquipmentProfileChangedEvent(EquipmentProfile.of(context)!));
_bloc.add(StopTypeChangedEvent(context.watch<StopType>())); _bloc.add(StopTypeChangedEvent(context.watch<StopType>()));
} }
@ -40,8 +42,6 @@ class _MeteringScreenState extends State<MeteringScreen> {
buildWhen: (_, current) => current is MeteringDataState, buildWhen: (_, current) => current is MeteringDataState,
builder: (_, state) => state is MeteringDataState builder: (_, state) => state is MeteringDataState
? _MeteringContainerBuidler( ? _MeteringContainerBuidler(
onEquipmentProfileChanged: (value) =>
_bloc.add(EquipmentProfileChangedEvent(value)),
fastest: state.fastest, fastest: state.fastest,
slowest: state.slowest, slowest: state.slowest,
iso: state.iso, iso: state.iso,
@ -71,7 +71,6 @@ class _MeteringScreenState extends State<MeteringScreen> {
} }
class _MeteringContainerBuidler extends StatelessWidget { class _MeteringContainerBuidler extends StatelessWidget {
final ValueChanged<EquipmentProfileData> onEquipmentProfileChanged;
final ExposurePair? fastest; final ExposurePair? fastest;
final ExposurePair? slowest; final ExposurePair? slowest;
final IsoValue iso; final IsoValue iso;
@ -81,7 +80,6 @@ class _MeteringContainerBuidler extends StatelessWidget {
final List<ExposurePair> exposurePairs; final List<ExposurePair> exposurePairs;
const _MeteringContainerBuidler({ const _MeteringContainerBuidler({
required this.onEquipmentProfileChanged,
required this.fastest, required this.fastest,
required this.slowest, required this.slowest,
required this.iso, required this.iso,
@ -95,7 +93,6 @@ class _MeteringContainerBuidler extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return context.watch<EvSourceType>() == EvSourceType.camera return context.watch<EvSourceType>() == EvSourceType.camera
? CameraContainerProvider( ? CameraContainerProvider(
onEquipmentProfileChanged: onEquipmentProfileChanged,
fastest: fastest, fastest: fastest,
slowest: slowest, slowest: slowest,
iso: iso, iso: iso,
@ -105,7 +102,6 @@ class _MeteringContainerBuidler extends StatelessWidget {
exposurePairs: exposurePairs, exposurePairs: exposurePairs,
) )
: LightSensorContainerProvider( : LightSensorContainerProvider(
onEquipmentProfileChanged: onEquipmentProfileChanged,
fastest: fastest, fastest: fastest,
slowest: slowest, slowest: slowest,
iso: iso, iso: iso,