mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-22 15:30:59 +00:00
wip
This commit is contained in:
parent
c5179e71ea
commit
284e95854d
7 changed files with 62 additions and 76 deletions
|
@ -8,6 +8,7 @@ import 'package:lightmeter/data/caffeine_service.dart';
|
|||
import 'package:lightmeter/data/haptics_service.dart';
|
||||
import 'package:lightmeter/data/models/supported_locale.dart';
|
||||
import 'package:lightmeter/providers/supported_locale_provider.dart';
|
||||
import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
|
@ -47,31 +48,33 @@ class Application extends StatelessWidget {
|
|||
Provider(create: (_) => PermissionsService()),
|
||||
Provider(create: (_) => const LightSensorService()),
|
||||
],
|
||||
child: StopTypeProvider(
|
||||
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!,
|
||||
child: IAPProductsProvider(
|
||||
child: StopTypeProvider(
|
||||
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(),
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -15,17 +15,18 @@ class EquipmentProfileProvider extends StatefulWidget {
|
|||
}
|
||||
|
||||
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;
|
||||
final List<EquipmentProfileData> _profiles = [];
|
||||
|
||||
late EquipmentProfileData _selectedProfile = _profiles.isNotEmpty
|
||||
? _profiles.first
|
||||
: const EquipmentProfileData(
|
||||
id: 'default',
|
||||
name: '',
|
||||
apertureValues: apertureValues,
|
||||
ndValues: ndValues,
|
||||
shutterSpeedValues: shutterSpeedValues,
|
||||
isoValues: isoValues,
|
||||
);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -77,8 +78,12 @@ class EquipmentProfile extends InheritedWidget {
|
|||
super.key,
|
||||
});
|
||||
|
||||
static EquipmentProfileData? of(BuildContext context) {
|
||||
return context.dependOnInheritedWidgetOfExactType<EquipmentProfile>()?.data;
|
||||
static EquipmentProfileData? of(BuildContext context, {bool listen = true}) {
|
||||
if (listen) {
|
||||
return context.dependOnInheritedWidgetOfExactType<EquipmentProfile>()?.data;
|
||||
} else {
|
||||
return context.findAncestorWidgetOfExactType<EquipmentProfile>()?.data;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -21,9 +21,12 @@ class MeteringBloc extends Bloc<MeteringEvent, MeteringState> {
|
|||
final MeteringInteractor _meteringInteractor;
|
||||
late final StreamSubscription<communication_states.ScreenState> _communicationSubscription;
|
||||
|
||||
List<ApertureValue> get _apertureValues => apertureValues.whereStopType(stopType);
|
||||
List<ShutterSpeedValue> get _shutterSpeedValues => shutterSpeedValues.whereStopType(stopType);
|
||||
List<ApertureValue> get _apertureValues =>
|
||||
_equipmentProfileData.apertureValues.whereStopType(stopType);
|
||||
List<ShutterSpeedValue> get _shutterSpeedValues =>
|
||||
_equipmentProfileData.shutterSpeedValues.whereStopType(stopType);
|
||||
|
||||
EquipmentProfileData _equipmentProfileData;
|
||||
StopType stopType;
|
||||
|
||||
late IsoValue _iso = _userPreferencesService.iso;
|
||||
|
@ -35,6 +38,7 @@ class MeteringBloc extends Bloc<MeteringEvent, MeteringState> {
|
|||
this._communicationBloc,
|
||||
this._userPreferencesService,
|
||||
this._meteringInteractor,
|
||||
this._equipmentProfileData,
|
||||
this.stopType,
|
||||
) : super(
|
||||
MeteringEndedState(
|
||||
|
@ -76,6 +80,8 @@ class MeteringBloc extends Bloc<MeteringEvent, MeteringState> {
|
|||
}
|
||||
|
||||
void _onEquipmentProfileChanged(EquipmentProfileChangedEvent event, Emitter emit) {
|
||||
_equipmentProfileData = event.equipmentProfileData;
|
||||
|
||||
/// Update selected ISO value, if selected equipment profile
|
||||
/// doesn't contain currently selected value
|
||||
if (!event.equipmentProfileData.isoValues.any((v) => _iso.value == v.value)) {
|
||||
|
@ -90,6 +96,7 @@ class MeteringBloc extends Bloc<MeteringEvent, MeteringState> {
|
|||
_ev = _ev - event.equipmentProfileData.ndValues.first.stopReduction + _nd.stopReduction;
|
||||
_nd = event.equipmentProfileData.ndValues.first;
|
||||
}
|
||||
|
||||
_emitMeasuredState(emit);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:lightmeter/data/models/exposure_pair.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 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart';
|
||||
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
||||
|
||||
import 'bloc_container_camera.dart';
|
||||
|
|
|
@ -2,8 +2,8 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:lightmeter/data/models/exposure_pair.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 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart';
|
||||
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
||||
|
||||
import 'bloc_container_light_sensor.dart';
|
||||
|
|
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:lightmeter/data/models/exposure_pair.dart';
|
||||
import 'package:lightmeter/generated/l10n.dart';
|
||||
import 'package:lightmeter/providers/equipment_profile_provider.dart';
|
||||
import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart';
|
||||
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
||||
|
||||
import 'components/animated_dialog_picker/widget_dialog_animated_picker.dart';
|
||||
|
@ -37,11 +38,12 @@ class ReadingsContainer extends StatelessWidget {
|
|||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
if (EquipmentProfiles.of(context)!.isNotEmpty) ...[
|
||||
if (IAPProducts.of(context, IAPProductType.equipment)?.status ==
|
||||
IAPProductStatus.purchased) ...[
|
||||
ReadingValueContainer.singleValue(
|
||||
value: ReadingValue(
|
||||
label: S.of(context).equipment,
|
||||
value: 'Parktica + Zenitar',
|
||||
value: EquipmentProfile.of(context)!.name,
|
||||
),
|
||||
),
|
||||
const _InnerPadding(),
|
||||
|
@ -87,39 +89,6 @@ class _InnerPadding extends SizedBox {
|
|||
const _InnerPadding() : super(height: Dimens.grid8, width: Dimens.grid8);
|
||||
}
|
||||
|
||||
|
||||
class _EquipmentProfileDataTile extends StatelessWidget {
|
||||
final List<IsoValue> values;
|
||||
final IsoValue selectedValue;
|
||||
final ValueChanged<IsoValue> onChanged;
|
||||
|
||||
const _EquipmentProfileDataTile({
|
||||
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: 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),
|
||||
onChanged: onChanged,
|
||||
closedChild: ReadingValueContainer.singleValue(
|
||||
value: ReadingValue(
|
||||
label: S.of(context).iso,
|
||||
value: selectedValue.value.toString(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _IsoValueTile extends StatelessWidget {
|
||||
final List<IsoValue> values;
|
||||
final IsoValue selectedValue;
|
||||
|
|
|
@ -6,6 +6,7 @@ import 'package:lightmeter/data/light_sensor_service.dart';
|
|||
import 'package:lightmeter/data/permissions_service.dart';
|
||||
import 'package:lightmeter/data/shared_prefs_service.dart';
|
||||
import 'package:lightmeter/interactors/metering_interactor.dart';
|
||||
import 'package:lightmeter/providers/equipment_profile_provider.dart';
|
||||
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
|
@ -39,6 +40,7 @@ class _MeteringFlowState extends State<MeteringFlow> {
|
|||
context.read<MeteringCommunicationBloc>(),
|
||||
context.read<UserPreferencesService>(),
|
||||
context.read<MeteringInteractor>(),
|
||||
EquipmentProfile.of(context, listen: false)!,
|
||||
context.read<StopType>(),
|
||||
),
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue