mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-22 15:30:59 +00:00
get iso & nd values from equipment profile
This commit is contained in:
parent
b160ff6ad0
commit
86c7a9c839
8 changed files with 183 additions and 34 deletions
|
@ -16,6 +16,7 @@ import 'data/permissions_service.dart';
|
|||
import 'data/shared_prefs_service.dart';
|
||||
import 'environment.dart';
|
||||
import 'generated/l10n.dart';
|
||||
import 'providers/equipment_profile_provider.dart';
|
||||
import 'providers/ev_source_type_provider.dart';
|
||||
import 'providers/theme_provider.dart';
|
||||
import 'screens/metering/flow_metering.dart';
|
||||
|
@ -47,29 +48,31 @@ class Application extends StatelessWidget {
|
|||
Provider(create: (_) => const LightSensorService()),
|
||||
],
|
||||
child: StopTypeProvider(
|
||||
child: EvSourceTypeProvider(
|
||||
child: SupportedLocaleProvider(
|
||||
child: ThemeProvider(
|
||||
builder: (context, _) => _AnnotatedRegionWrapper(
|
||||
child: MaterialApp(
|
||||
theme: context.watch<ThemeData>(),
|
||||
locale: Locale(context.watch<SupportedLocale>().intlName),
|
||||
localizationsDelegates: const [
|
||||
S.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: S.delegate.supportedLocales,
|
||||
builder: (context, child) => MediaQuery(
|
||||
data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
|
||||
child: child!,
|
||||
child: EquipmentProfileProvider(
|
||||
child: EvSourceTypeProvider(
|
||||
child: SupportedLocaleProvider(
|
||||
child: ThemeProvider(
|
||||
builder: (context, _) => _AnnotatedRegionWrapper(
|
||||
child: MaterialApp(
|
||||
theme: context.watch<ThemeData>(),
|
||||
locale: Locale(context.watch<SupportedLocale>().intlName),
|
||||
localizationsDelegates: const [
|
||||
S.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: S.delegate.supportedLocales,
|
||||
builder: (context, child) => MediaQuery(
|
||||
data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
|
||||
child: child!,
|
||||
),
|
||||
initialRoute: "metering",
|
||||
routes: {
|
||||
"metering": (context) => const MeteringFlow(),
|
||||
"settings": (context) => const SettingsFlow(),
|
||||
},
|
||||
),
|
||||
initialRoute: "metering",
|
||||
routes: {
|
||||
"metering": (context) => const MeteringFlow(),
|
||||
"settings": (context) => const SettingsFlow(),
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
22
lib/data/models/equipment_profile_data.dart
Normal file
22
lib/data/models/equipment_profile_data.dart
Normal file
|
@ -0,0 +1,22 @@
|
|||
import 'package:lightmeter/data/models/photography_values/aperture_value.dart';
|
||||
import 'package:lightmeter/data/models/photography_values/iso_value.dart';
|
||||
import 'package:lightmeter/data/models/photography_values/nd_value.dart';
|
||||
import 'package:lightmeter/data/models/photography_values/shutter_speed_value.dart';
|
||||
|
||||
class EquipmentProfileData {
|
||||
final String id;
|
||||
final String name;
|
||||
final List<ApertureValue> apertureValues;
|
||||
final List<NdValue> ndValues;
|
||||
final List<ShutterSpeedValue> shutterSpeedValues;
|
||||
final List<IsoValue> isoValues;
|
||||
|
||||
const EquipmentProfileData({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.apertureValues,
|
||||
required this.ndValues,
|
||||
required this.shutterSpeedValues,
|
||||
required this.isoValues,
|
||||
});
|
||||
}
|
90
lib/providers/equipment_profile_provider.dart
Normal file
90
lib/providers/equipment_profile_provider.dart
Normal file
|
@ -0,0 +1,90 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:lightmeter/data/models/equipment_profile_data.dart';
|
||||
import 'package:lightmeter/data/models/photography_values/aperture_value.dart';
|
||||
import 'package:lightmeter/data/models/photography_values/iso_value.dart';
|
||||
import 'package:lightmeter/data/models/photography_values/nd_value.dart';
|
||||
import 'package:lightmeter/data/models/photography_values/shutter_speed_value.dart';
|
||||
|
||||
class EquipmentProfileProvider extends StatefulWidget {
|
||||
final Widget child;
|
||||
|
||||
const EquipmentProfileProvider({required this.child, super.key});
|
||||
|
||||
static EquipmentProfileProviderState of(BuildContext context) {
|
||||
return context.findAncestorStateOfType<EquipmentProfileProviderState>()!;
|
||||
}
|
||||
|
||||
@override
|
||||
State<EquipmentProfileProvider> createState() => EquipmentProfileProviderState();
|
||||
}
|
||||
|
||||
class EquipmentProfileProviderState extends State<EquipmentProfileProvider> {
|
||||
final List<EquipmentProfileData> _profiles = [
|
||||
const EquipmentProfileData(
|
||||
id: '0',
|
||||
name: 'Default',
|
||||
apertureValues: apertureValues,
|
||||
ndValues: ndValues,
|
||||
shutterSpeedValues: shutterSpeedValues,
|
||||
isoValues: isoValues,
|
||||
),
|
||||
];
|
||||
late EquipmentProfileData? _selectedProfile = _profiles.isNotEmpty ? _profiles.first : null;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return EquipmentProfiles(
|
||||
profiles: _profiles,
|
||||
child: EquipmentProfile(
|
||||
data: _selectedProfile,
|
||||
child: widget.child,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void setProfile(EquipmentProfileData data) {
|
||||
setState(() {
|
||||
_selectedProfile = data;
|
||||
});
|
||||
}
|
||||
|
||||
void addProfile(EquipmentProfileData data) {}
|
||||
|
||||
void updateProdile(EquipmentProfileData data) {}
|
||||
|
||||
void deleteProfile(EquipmentProfileData data) {}
|
||||
}
|
||||
|
||||
class EquipmentProfiles extends InheritedWidget {
|
||||
final List<EquipmentProfileData> profiles;
|
||||
|
||||
const EquipmentProfiles({
|
||||
required this.profiles,
|
||||
required super.child,
|
||||
super.key,
|
||||
});
|
||||
|
||||
static List<EquipmentProfileData>? of(BuildContext context) {
|
||||
return context.dependOnInheritedWidgetOfExactType<EquipmentProfiles>()?.profiles;
|
||||
}
|
||||
|
||||
@override
|
||||
bool updateShouldNotify(EquipmentProfiles oldWidget) => true;
|
||||
}
|
||||
|
||||
class EquipmentProfile extends InheritedWidget {
|
||||
final EquipmentProfileData? data;
|
||||
|
||||
const EquipmentProfile({
|
||||
required this.data,
|
||||
required super.child,
|
||||
super.key,
|
||||
});
|
||||
|
||||
static EquipmentProfileData? of(BuildContext context) {
|
||||
return context.dependOnInheritedWidgetOfExactType<EquipmentProfile>()?.data;
|
||||
}
|
||||
|
||||
@override
|
||||
bool updateShouldNotify(EquipmentProfile oldWidget) => true;
|
||||
}
|
|
@ -4,6 +4,7 @@ import 'package:lightmeter/data/models/exposure_pair.dart';
|
|||
import 'package:lightmeter/data/models/photography_values/iso_value.dart';
|
||||
import 'package:lightmeter/data/models/photography_values/nd_value.dart';
|
||||
import 'package:lightmeter/interactors/metering_interactor.dart';
|
||||
import 'package:lightmeter/providers/equipment_profile_provider.dart';
|
||||
import 'package:lightmeter/screens/metering/communication/bloc_communication_metering.dart';
|
||||
|
||||
import 'bloc_container_camera.dart';
|
||||
|
@ -40,7 +41,9 @@ class CameraContainerProvider extends StatelessWidget {
|
|||
child: CameraContainer(
|
||||
fastest: fastest,
|
||||
slowest: slowest,
|
||||
isoValues: EquipmentProfile.of(context)?.isoValues ?? isoValues,
|
||||
iso: iso,
|
||||
ndValues: EquipmentProfile.of(context)?.ndValues ?? ndValues,
|
||||
nd: nd,
|
||||
onIsoChanged: onIsoChanged,
|
||||
onNdChanged: onNdChanged,
|
||||
|
|
|
@ -21,7 +21,9 @@ import 'state_container_camera.dart';
|
|||
class CameraContainer extends StatelessWidget {
|
||||
final ExposurePair? fastest;
|
||||
final ExposurePair? slowest;
|
||||
final List<IsoValue> isoValues;
|
||||
final IsoValue iso;
|
||||
final List<NdValue> ndValues;
|
||||
final NdValue nd;
|
||||
final ValueChanged<IsoValue> onIsoChanged;
|
||||
final ValueChanged<NdValue> onNdChanged;
|
||||
|
@ -30,7 +32,9 @@ class CameraContainer extends StatelessWidget {
|
|||
const CameraContainer({
|
||||
required this.fastest,
|
||||
required this.slowest,
|
||||
required this.isoValues,
|
||||
required this.iso,
|
||||
required this.ndValues,
|
||||
required this.nd,
|
||||
required this.onIsoChanged,
|
||||
required this.onNdChanged,
|
||||
|
@ -49,7 +53,9 @@ class CameraContainer extends StatelessWidget {
|
|||
readingsContainer: ReadingsContainer(
|
||||
fastest: fastest,
|
||||
slowest: slowest,
|
||||
isoValues: isoValues,
|
||||
iso: iso,
|
||||
ndValues: ndValues,
|
||||
nd: nd,
|
||||
onIsoChanged: onIsoChanged,
|
||||
onNdChanged: onNdChanged,
|
||||
|
|
|
@ -4,6 +4,7 @@ import 'package:lightmeter/data/models/exposure_pair.dart';
|
|||
import 'package:lightmeter/data/models/photography_values/iso_value.dart';
|
||||
import 'package:lightmeter/data/models/photography_values/nd_value.dart';
|
||||
import 'package:lightmeter/interactors/metering_interactor.dart';
|
||||
import 'package:lightmeter/providers/equipment_profile_provider.dart';
|
||||
import 'package:lightmeter/screens/metering/communication/bloc_communication_metering.dart';
|
||||
|
||||
import 'bloc_container_light_sensor.dart';
|
||||
|
@ -40,7 +41,9 @@ class LightSensorContainerProvider extends StatelessWidget {
|
|||
child: LightSensorContainer(
|
||||
fastest: fastest,
|
||||
slowest: slowest,
|
||||
isoValues: EquipmentProfile.of(context)?.isoValues ?? isoValues,
|
||||
iso: iso,
|
||||
ndValues: EquipmentProfile.of(context)?.ndValues ?? ndValues,
|
||||
nd: nd,
|
||||
onIsoChanged: onIsoChanged,
|
||||
onNdChanged: onNdChanged,
|
||||
|
|
|
@ -10,7 +10,9 @@ import 'package:lightmeter/screens/metering/components/shared/readings_container
|
|||
class LightSensorContainer extends StatelessWidget {
|
||||
final ExposurePair? fastest;
|
||||
final ExposurePair? slowest;
|
||||
final List<IsoValue> isoValues;
|
||||
final IsoValue iso;
|
||||
final List<NdValue> ndValues;
|
||||
final NdValue nd;
|
||||
final ValueChanged<IsoValue> onIsoChanged;
|
||||
final ValueChanged<NdValue> onNdChanged;
|
||||
|
@ -19,7 +21,9 @@ class LightSensorContainer extends StatelessWidget {
|
|||
const LightSensorContainer({
|
||||
required this.fastest,
|
||||
required this.slowest,
|
||||
required this.isoValues,
|
||||
required this.iso,
|
||||
required this.ndValues,
|
||||
required this.nd,
|
||||
required this.onIsoChanged,
|
||||
required this.onNdChanged,
|
||||
|
@ -35,7 +39,9 @@ class LightSensorContainer extends StatelessWidget {
|
|||
readingsContainer: ReadingsContainer(
|
||||
fastest: fastest,
|
||||
slowest: slowest,
|
||||
isoValues: isoValues,
|
||||
iso: iso,
|
||||
ndValues: ndValues,
|
||||
nd: nd,
|
||||
onIsoChanged: onIsoChanged,
|
||||
onNdChanged: onNdChanged,
|
||||
|
|
|
@ -12,7 +12,9 @@ import 'components/reading_value_container/widget_container_reading_value.dart';
|
|||
class ReadingsContainer extends StatelessWidget {
|
||||
final ExposurePair? fastest;
|
||||
final ExposurePair? slowest;
|
||||
final List<IsoValue> isoValues;
|
||||
final IsoValue iso;
|
||||
final List<NdValue> ndValues;
|
||||
final NdValue nd;
|
||||
final ValueChanged<IsoValue> onIsoChanged;
|
||||
final ValueChanged<NdValue> onNdChanged;
|
||||
|
@ -20,7 +22,9 @@ class ReadingsContainer extends StatelessWidget {
|
|||
const ReadingsContainer({
|
||||
required this.fastest,
|
||||
required this.slowest,
|
||||
required this.isoValues,
|
||||
required this.iso,
|
||||
required this.ndValues,
|
||||
required this.nd,
|
||||
required this.onIsoChanged,
|
||||
required this.onNdChanged,
|
||||
|
@ -49,14 +53,16 @@ class ReadingsContainer extends StatelessWidget {
|
|||
children: [
|
||||
Expanded(
|
||||
child: _IsoValueTile(
|
||||
value: iso,
|
||||
selectedValue: iso,
|
||||
values: isoValues,
|
||||
onChanged: onIsoChanged,
|
||||
),
|
||||
),
|
||||
const _InnerPadding(),
|
||||
Expanded(
|
||||
child: _NdValueTile(
|
||||
value: nd,
|
||||
selectedValue: nd,
|
||||
values: ndValues,
|
||||
onChanged: onNdChanged,
|
||||
),
|
||||
),
|
||||
|
@ -72,18 +78,23 @@ class _InnerPadding extends SizedBox {
|
|||
}
|
||||
|
||||
class _IsoValueTile extends StatelessWidget {
|
||||
final IsoValue value;
|
||||
final List<IsoValue> values;
|
||||
final IsoValue selectedValue;
|
||||
final ValueChanged<IsoValue> onChanged;
|
||||
|
||||
const _IsoValueTile({required this.value, required this.onChanged});
|
||||
const _IsoValueTile({
|
||||
required this.selectedValue,
|
||||
required this.values,
|
||||
required this.onChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AnimatedDialogPicker<IsoValue>(
|
||||
title: S.of(context).iso,
|
||||
subtitle: S.of(context).filmSpeed,
|
||||
selectedValue: value,
|
||||
values: isoValues,
|
||||
selectedValue: selectedValue,
|
||||
values: values,
|
||||
itemTitleBuilder: (_, value) => Text(value.value.toString()),
|
||||
// using ascending order, because increase in film speed rises EV
|
||||
evDifferenceBuilder: (selected, other) => selected.toStringDifference(other),
|
||||
|
@ -91,7 +102,7 @@ class _IsoValueTile extends StatelessWidget {
|
|||
closedChild: ReadingValueContainer.singleValue(
|
||||
value: ReadingValue(
|
||||
label: S.of(context).iso,
|
||||
value: value.value.toString(),
|
||||
value: selectedValue.value.toString(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -99,18 +110,23 @@ class _IsoValueTile extends StatelessWidget {
|
|||
}
|
||||
|
||||
class _NdValueTile extends StatelessWidget {
|
||||
final NdValue value;
|
||||
final List<NdValue> values;
|
||||
final NdValue selectedValue;
|
||||
final ValueChanged<NdValue> onChanged;
|
||||
|
||||
const _NdValueTile({required this.value, required this.onChanged});
|
||||
const _NdValueTile({
|
||||
required this.selectedValue,
|
||||
required this.values,
|
||||
required this.onChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AnimatedDialogPicker<NdValue>(
|
||||
title: S.of(context).nd,
|
||||
subtitle: S.of(context).ndFilterFactor,
|
||||
selectedValue: value,
|
||||
values: ndValues,
|
||||
selectedValue: selectedValue,
|
||||
values: values,
|
||||
itemTitleBuilder: (_, value) => Text(
|
||||
value.value == 0 ? S.of(context).none : value.value.toString(),
|
||||
),
|
||||
|
@ -120,7 +136,7 @@ class _NdValueTile extends StatelessWidget {
|
|||
closedChild: ReadingValueContainer.singleValue(
|
||||
value: ReadingValue(
|
||||
label: S.of(context).nd,
|
||||
value: value.value.toString(),
|
||||
value: selectedValue.value.toString(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue