mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-22 15:30:59 +00:00
non-null EquipmentProfile
This commit is contained in:
parent
96b7ec0440
commit
eb78b0b80b
8 changed files with 21 additions and 22 deletions
|
@ -88,11 +88,11 @@ class EquipmentProfiles extends InheritedWidget {
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
static List<EquipmentProfileData>? of(BuildContext context, {bool listen = true}) {
|
static List<EquipmentProfileData> of(BuildContext context, {bool listen = true}) {
|
||||||
if (listen) {
|
if (listen) {
|
||||||
return context.dependOnInheritedWidgetOfExactType<EquipmentProfiles>()?.profiles;
|
return context.dependOnInheritedWidgetOfExactType<EquipmentProfiles>()!.profiles;
|
||||||
} else {
|
} else {
|
||||||
return context.findAncestorWidgetOfExactType<EquipmentProfiles>()?.profiles;
|
return context.findAncestorWidgetOfExactType<EquipmentProfiles>()!.profiles;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ class EquipmentProfiles extends InheritedWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class EquipmentProfile extends InheritedWidget {
|
class EquipmentProfile extends InheritedWidget {
|
||||||
final EquipmentProfileData? data;
|
final EquipmentProfileData data;
|
||||||
|
|
||||||
const EquipmentProfile({
|
const EquipmentProfile({
|
||||||
required this.data,
|
required this.data,
|
||||||
|
@ -109,11 +109,11 @@ class EquipmentProfile extends InheritedWidget {
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
static EquipmentProfileData? of(BuildContext context, {bool listen = true}) {
|
static EquipmentProfileData of(BuildContext context, {bool listen = true}) {
|
||||||
if (listen) {
|
if (listen) {
|
||||||
return context.dependOnInheritedWidgetOfExactType<EquipmentProfile>()?.data;
|
return context.dependOnInheritedWidgetOfExactType<EquipmentProfile>()!.data;
|
||||||
} else {
|
} else {
|
||||||
return context.findAncestorWidgetOfExactType<EquipmentProfile>()?.data;
|
return context.findAncestorWidgetOfExactType<EquipmentProfile>()!.data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,9 +40,9 @@ class CameraContainerProvider extends StatelessWidget {
|
||||||
child: CameraContainer(
|
child: CameraContainer(
|
||||||
fastest: fastest,
|
fastest: fastest,
|
||||||
slowest: slowest,
|
slowest: slowest,
|
||||||
isoValues: EquipmentProfile.of(context)?.isoValues ?? isoValues,
|
isoValues: EquipmentProfile.of(context).isoValues,
|
||||||
iso: iso,
|
iso: iso,
|
||||||
ndValues: EquipmentProfile.of(context)?.ndValues ?? ndValues,
|
ndValues: EquipmentProfile.of(context).ndValues,
|
||||||
nd: nd,
|
nd: nd,
|
||||||
onIsoChanged: onIsoChanged,
|
onIsoChanged: onIsoChanged,
|
||||||
onNdChanged: onNdChanged,
|
onNdChanged: onNdChanged,
|
||||||
|
|
|
@ -49,7 +49,7 @@ class CameraContainer extends StatelessWidget {
|
||||||
PlatformConfig.cameraPreviewAspectRatio;
|
PlatformConfig.cameraPreviewAspectRatio;
|
||||||
|
|
||||||
double topBarOverflow = Dimens.readingContainerDefaultHeight - cameraViewHeight;
|
double topBarOverflow = Dimens.readingContainerDefaultHeight - cameraViewHeight;
|
||||||
if (EquipmentProfiles.of(context)?.isNotEmpty ?? false) {
|
if (EquipmentProfiles.of(context).isNotEmpty) {
|
||||||
topBarOverflow += Dimens.readingContainerSingleValueHeight;
|
topBarOverflow += Dimens.readingContainerSingleValueHeight;
|
||||||
topBarOverflow += Dimens.paddingS;
|
topBarOverflow += Dimens.paddingS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,9 +40,9 @@ class LightSensorContainerProvider extends StatelessWidget {
|
||||||
child: LightSensorContainer(
|
child: LightSensorContainer(
|
||||||
fastest: fastest,
|
fastest: fastest,
|
||||||
slowest: slowest,
|
slowest: slowest,
|
||||||
isoValues: EquipmentProfile.of(context)?.isoValues ?? isoValues,
|
isoValues: EquipmentProfile.of(context).isoValues,
|
||||||
iso: iso,
|
iso: iso,
|
||||||
ndValues: EquipmentProfile.of(context)?.ndValues ?? ndValues,
|
ndValues: EquipmentProfile.of(context).ndValues,
|
||||||
nd: nd,
|
nd: nd,
|
||||||
onIsoChanged: onIsoChanged,
|
onIsoChanged: onIsoChanged,
|
||||||
onNdChanged: onNdChanged,
|
onNdChanged: onNdChanged,
|
||||||
|
|
|
@ -36,11 +36,10 @@ class ReadingsContainer extends StatelessWidget {
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
if (EquipmentProfile.of(context) != null &&
|
if (EquipmentProfiles.of(context).isNotEmpty) ...[
|
||||||
(EquipmentProfiles.of(context)?.isNotEmpty ?? false)) ...[
|
|
||||||
_EquipmentProfilePicker(
|
_EquipmentProfilePicker(
|
||||||
selectedValue: EquipmentProfile.of(context)!,
|
selectedValue: EquipmentProfile.of(context),
|
||||||
values: EquipmentProfiles.of(context)!,
|
values: EquipmentProfiles.of(context),
|
||||||
onChanged: EquipmentProfileProvider.of(context).setProfile,
|
onChanged: EquipmentProfileProvider.of(context).setProfile,
|
||||||
),
|
),
|
||||||
const _InnerPadding(),
|
const _InnerPadding(),
|
||||||
|
|
|
@ -40,7 +40,7 @@ class _MeteringFlowState extends State<MeteringFlow> {
|
||||||
context.read<MeteringCommunicationBloc>(),
|
context.read<MeteringCommunicationBloc>(),
|
||||||
context.read<UserPreferencesService>(),
|
context.read<UserPreferencesService>(),
|
||||||
context.read<MeteringInteractor>(),
|
context.read<MeteringInteractor>(),
|
||||||
EquipmentProfile.of(context, listen: false)!,
|
EquipmentProfile.of(context, listen: false),
|
||||||
context.read<StopType>(),
|
context.read<StopType>(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -27,7 +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(EquipmentProfileChangedEvent(EquipmentProfile.of(context)));
|
||||||
_bloc.add(StopTypeChangedEvent(context.watch<StopType>()));
|
_bloc.add(StopTypeChangedEvent(context.watch<StopType>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,13 +18,13 @@ class _EquipmentProfilesScreenState extends State<EquipmentProfilesScreen> {
|
||||||
static const maxProfiles = 5; // replace with a constant from iap
|
static const maxProfiles = 5; // replace with a constant from iap
|
||||||
|
|
||||||
late List<GlobalKey<EquipmentProfileContainerState>> profileContainersKeys = [];
|
late List<GlobalKey<EquipmentProfileContainerState>> profileContainersKeys = [];
|
||||||
int get profilesCount => EquipmentProfiles.of(context)?.length ?? 0;
|
int get profilesCount => EquipmentProfiles.of(context).length;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
profileContainersKeys = List.filled(
|
profileContainersKeys = List.filled(
|
||||||
EquipmentProfiles.of(context, listen: false)?.length ?? 0,
|
EquipmentProfiles.of(context, listen: false).length,
|
||||||
GlobalKey<EquipmentProfileContainerState>(),
|
GlobalKey<EquipmentProfileContainerState>(),
|
||||||
growable: true,
|
growable: true,
|
||||||
);
|
);
|
||||||
|
@ -56,7 +56,7 @@ class _EquipmentProfilesScreenState extends State<EquipmentProfilesScreen> {
|
||||||
itemBuilder: (context, index) => index > 0
|
itemBuilder: (context, index) => index > 0
|
||||||
? EquipmentProfileContainer(
|
? EquipmentProfileContainer(
|
||||||
key: profileContainersKeys[index],
|
key: profileContainersKeys[index],
|
||||||
data: EquipmentProfiles.of(context)![index],
|
data: EquipmentProfiles.of(context)[index],
|
||||||
onExpand: () => _keepExpandedAt(index),
|
onExpand: () => _keepExpandedAt(index),
|
||||||
onUpdate: (profileData) => _updateProfileAt(profileData, index),
|
onUpdate: (profileData) => _updateProfileAt(profileData, index),
|
||||||
onDelete: () => _removeProfileAt(index),
|
onDelete: () => _removeProfileAt(index),
|
||||||
|
@ -91,7 +91,7 @@ class _EquipmentProfilesScreenState extends State<EquipmentProfilesScreen> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void _removeProfileAt(int index) {
|
void _removeProfileAt(int index) {
|
||||||
EquipmentProfileProvider.of(context).deleteProfile(EquipmentProfiles.of(context)![index]);
|
EquipmentProfileProvider.of(context).deleteProfile(EquipmentProfiles.of(context)[index]);
|
||||||
profileContainersKeys.removeAt(index);
|
profileContainersKeys.removeAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue