diff --git a/lib/screens/metering/components/camera_container/widget_container_camera.dart b/lib/screens/metering/components/camera_container/widget_container_camera.dart index a23545e..a4cb3e8 100644 --- a/lib/screens/metering/components/camera_container/widget_container_camera.dart +++ b/lib/screens/metering/components/camera_container/widget_container_camera.dart @@ -5,7 +5,6 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:lightmeter/data/models/exposure_pair.dart'; import 'package:lightmeter/data/models/metering_screen_layout_config.dart'; import 'package:lightmeter/platform_config.dart'; -import 'package:lightmeter/providers/user_preferences_provider.dart'; import 'package:lightmeter/res/dimens.dart'; import 'package:lightmeter/screens/metering/components/camera_container/bloc_container_camera.dart'; import 'package:lightmeter/screens/metering/components/camera_container/components/camera_controls/widget_camera_controls.dart'; @@ -17,6 +16,8 @@ import 'package:lightmeter/screens/metering/components/camera_container/state_co import 'package:lightmeter/screens/metering/components/shared/exposure_pairs_list/widget_list_exposure_pairs.dart'; import 'package:lightmeter/screens/metering/components/shared/metering_top_bar/widget_top_bar_metering.dart'; import 'package:lightmeter/screens/metering/components/shared/readings_container/widget_container_readings.dart'; +import 'package:lightmeter/utils/context_utils.dart'; +import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart'; import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; class CameraContainer extends StatelessWidget { @@ -101,28 +102,25 @@ class CameraContainer extends StatelessWidget { } double _meteringContainerHeight(BuildContext context) { + final isPro = IAPProducts.isPurchased(context, IAPProductType.paidFeatures); double enabledFeaturesHeight = 0; - if (UserPreferencesProvider.meteringScreenFeatureOf( - context, - MeteringScreenLayoutFeature.equipmentProfiles, - )) { + if (!isPro) { enabledFeaturesHeight += Dimens.readingContainerSingleValueHeight; enabledFeaturesHeight += Dimens.paddingS; + } else { + if (context.meteringFeature(MeteringScreenLayoutFeature.equipmentProfiles)) { + enabledFeaturesHeight += Dimens.readingContainerSingleValueHeight; + enabledFeaturesHeight += Dimens.paddingS; + } + if (context.meteringFeature(MeteringScreenLayoutFeature.filmPicker)) { + enabledFeaturesHeight += Dimens.readingContainerSingleValueHeight; + enabledFeaturesHeight += Dimens.paddingS; + } } - if (UserPreferencesProvider.meteringScreenFeatureOf( - context, - MeteringScreenLayoutFeature.extremeExposurePairs, - )) { + if (context.meteringFeature(MeteringScreenLayoutFeature.extremeExposurePairs)) { enabledFeaturesHeight += Dimens.readingContainerDoubleValueHeight; enabledFeaturesHeight += Dimens.paddingS; } - if (UserPreferencesProvider.meteringScreenFeatureOf( - context, - MeteringScreenLayoutFeature.filmPicker, - )) { - enabledFeaturesHeight += Dimens.readingContainerSingleValueHeight; - enabledFeaturesHeight += Dimens.paddingS; - } return enabledFeaturesHeight + Dimens.readingContainerSingleValueHeight; // ISO & ND } diff --git a/lib/screens/metering/components/shared/readings_container/components/lightmeter_pro/widget_lightmeter_pro.dart b/lib/screens/metering/components/shared/readings_container/components/lightmeter_pro/widget_lightmeter_pro.dart new file mode 100644 index 0000000..5360f41 --- /dev/null +++ b/lib/screens/metering/components/shared/readings_container/components/lightmeter_pro/widget_lightmeter_pro.dart @@ -0,0 +1,36 @@ +import 'package:flutter/material.dart'; +import 'package:lightmeter/generated/l10n.dart'; +import 'package:lightmeter/res/dimens.dart'; +import 'package:lightmeter/screens/metering/components/shared/readings_container/components/shared/animated_dialog_picker/components/animated_dialog/widget_dialog_animated.dart'; +import 'package:lightmeter/screens/metering/components/shared/readings_container/components/shared/reading_value_container/widget_container_reading_value.dart'; +import 'package:lightmeter/screens/settings/utils/show_buy_pro_dialog.dart'; +import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart'; + +class LightmeterProAnimatedDialog extends StatefulWidget { + const LightmeterProAnimatedDialog({super.key}); + + @override + State createState() => _LightmeterProAnimatedDialogState(); +} + +class _LightmeterProAnimatedDialogState extends State { + final _key = GlobalKey(); + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: () { + IAPProductsProvider.maybeOf(context)?.buy(IAPProductType.paidFeatures); + }, + child: ReadingValueContainer( + color: Theme.of(context).colorScheme.errorContainer, + values: [ + ReadingValue( + label: S.of(context).proFeatures, + value: S.of(context).unlock, + ), + ], + ), + ); + } +} diff --git a/lib/screens/metering/components/shared/readings_container/components/shared/reading_value_container/widget_container_reading_value.dart b/lib/screens/metering/components/shared/readings_container/components/shared/reading_value_container/widget_container_reading_value.dart index 3254456..e524854 100644 --- a/lib/screens/metering/components/shared/readings_container/components/shared/reading_value_container/widget_container_reading_value.dart +++ b/lib/screens/metering/components/shared/readings_container/components/shared/reading_value_container/widget_container_reading_value.dart @@ -13,9 +13,11 @@ class ReadingValue { class ReadingValueContainer extends StatelessWidget { late final List _items; + final Color? color; ReadingValueContainer({ required List values, + this.color, super.key, }) { _items = []; @@ -29,6 +31,7 @@ class ReadingValueContainer extends StatelessWidget { ReadingValueContainer.singleValue({ required ReadingValue value, + this.color, super.key, }) : _items = [_ReadingValueBuilder(value)]; @@ -37,7 +40,7 @@ class ReadingValueContainer extends StatelessWidget { return ClipRRect( borderRadius: BorderRadius.circular(Dimens.borderRadiusM), child: ColoredBox( - color: Theme.of(context).colorScheme.primaryContainer, + color: color ?? Theme.of(context).colorScheme.primaryContainer, child: Padding( padding: const EdgeInsets.all(Dimens.paddingM), child: Column( diff --git a/lib/screens/metering/components/shared/readings_container/widget_container_readings.dart b/lib/screens/metering/components/shared/readings_container/widget_container_readings.dart index cb8af05..30d1392 100644 --- a/lib/screens/metering/components/shared/readings_container/widget_container_readings.dart +++ b/lib/screens/metering/components/shared/readings_container/widget_container_readings.dart @@ -2,13 +2,15 @@ import 'package:flutter/material.dart'; import 'package:lightmeter/data/models/exposure_pair.dart'; import 'package:lightmeter/data/models/metering_screen_layout_config.dart'; import 'package:lightmeter/providers/equipment_profile_provider.dart'; -import 'package:lightmeter/providers/user_preferences_provider.dart'; import 'package:lightmeter/res/dimens.dart'; import 'package:lightmeter/screens/metering/components/shared/readings_container/components/equipment_profile_picker/widget_picker_equipment_profiles.dart'; import 'package:lightmeter/screens/metering/components/shared/readings_container/components/extreme_exposure_pairs_container/widget_container_extreme_exposure_pairs.dart'; import 'package:lightmeter/screens/metering/components/shared/readings_container/components/film_picker/widget_picker_film.dart'; import 'package:lightmeter/screens/metering/components/shared/readings_container/components/iso_picker/widget_picker_iso.dart'; +import 'package:lightmeter/screens/metering/components/shared/readings_container/components/lightmeter_pro/widget_lightmeter_pro.dart'; import 'package:lightmeter/screens/metering/components/shared/readings_container/components/nd_picker/widget_picker_nd.dart'; +import 'package:lightmeter/utils/context_utils.dart'; +import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart'; import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; class ReadingsContainer extends StatelessWidget { @@ -31,30 +33,26 @@ class ReadingsContainer extends StatelessWidget { @override Widget build(BuildContext context) { + final isPro = IAPProducts.isPurchased(context, IAPProductType.paidFeatures); return Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - if (UserPreferencesProvider.meteringScreenFeatureOf( - context, - MeteringScreenLayoutFeature.equipmentProfiles, - )) ...[ + if (!isPro) ...[ + const LightmeterProAnimatedDialog(), + const _InnerPadding(), + ], + if (isPro && context.meteringFeature(MeteringScreenLayoutFeature.equipmentProfiles)) ...[ const EquipmentProfilePicker(), const _InnerPadding(), ], - if (UserPreferencesProvider.meteringScreenFeatureOf( - context, - MeteringScreenLayoutFeature.extremeExposurePairs, - )) ...[ + if (context.meteringFeature(MeteringScreenLayoutFeature.extremeExposurePairs)) ...[ ExtremeExposurePairsContainer( fastest: fastest, slowest: slowest, ), const _InnerPadding(), ], - if (UserPreferencesProvider.meteringScreenFeatureOf( - context, - MeteringScreenLayoutFeature.filmPicker, - )) ...[ + if (isPro && context.meteringFeature(MeteringScreenLayoutFeature.filmPicker)) ...[ FilmPicker(selectedIso: iso), const _InnerPadding(), ], diff --git a/lib/utils/context_utils.dart b/lib/utils/context_utils.dart new file mode 100644 index 0000000..f64ea76 --- /dev/null +++ b/lib/utils/context_utils.dart @@ -0,0 +1,12 @@ +import 'package:flutter/material.dart'; +import 'package:lightmeter/data/models/metering_screen_layout_config.dart'; +import 'package:lightmeter/providers/user_preferences_provider.dart'; +import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart'; + +extension BuildContextUtils on BuildContext { + bool meteringFeature(MeteringScreenLayoutFeature feature) { + return UserPreferencesProvider.meteringScreenFeatureOf(this, feature); + } + + bool get isPro => IAPProducts.isPurchased(this, IAPProductType.paidFeatures); +}