mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-26 01:10:39 +00:00
hide pro features from metering screen
This commit is contained in:
parent
174f4612f2
commit
bab8679159
5 changed files with 77 additions and 30 deletions
|
@ -5,7 +5,6 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:lightmeter/data/models/exposure_pair.dart';
|
import 'package:lightmeter/data/models/exposure_pair.dart';
|
||||||
import 'package:lightmeter/data/models/metering_screen_layout_config.dart';
|
import 'package:lightmeter/data/models/metering_screen_layout_config.dart';
|
||||||
import 'package:lightmeter/platform_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/res/dimens.dart';
|
||||||
import 'package:lightmeter/screens/metering/components/camera_container/bloc_container_camera.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';
|
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/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/metering_top_bar/widget_top_bar_metering.dart';
|
||||||
import 'package:lightmeter/screens/metering/components/shared/readings_container/widget_container_readings.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';
|
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
||||||
|
|
||||||
class CameraContainer extends StatelessWidget {
|
class CameraContainer extends StatelessWidget {
|
||||||
|
@ -101,28 +102,25 @@ class CameraContainer extends StatelessWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
double _meteringContainerHeight(BuildContext context) {
|
double _meteringContainerHeight(BuildContext context) {
|
||||||
|
final isPro = IAPProducts.isPurchased(context, IAPProductType.paidFeatures);
|
||||||
double enabledFeaturesHeight = 0;
|
double enabledFeaturesHeight = 0;
|
||||||
if (UserPreferencesProvider.meteringScreenFeatureOf(
|
if (!isPro) {
|
||||||
context,
|
|
||||||
MeteringScreenLayoutFeature.equipmentProfiles,
|
|
||||||
)) {
|
|
||||||
enabledFeaturesHeight += Dimens.readingContainerSingleValueHeight;
|
enabledFeaturesHeight += Dimens.readingContainerSingleValueHeight;
|
||||||
enabledFeaturesHeight += Dimens.paddingS;
|
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(
|
if (context.meteringFeature(MeteringScreenLayoutFeature.extremeExposurePairs)) {
|
||||||
context,
|
|
||||||
MeteringScreenLayoutFeature.extremeExposurePairs,
|
|
||||||
)) {
|
|
||||||
enabledFeaturesHeight += Dimens.readingContainerDoubleValueHeight;
|
enabledFeaturesHeight += Dimens.readingContainerDoubleValueHeight;
|
||||||
enabledFeaturesHeight += Dimens.paddingS;
|
enabledFeaturesHeight += Dimens.paddingS;
|
||||||
}
|
}
|
||||||
if (UserPreferencesProvider.meteringScreenFeatureOf(
|
|
||||||
context,
|
|
||||||
MeteringScreenLayoutFeature.filmPicker,
|
|
||||||
)) {
|
|
||||||
enabledFeaturesHeight += Dimens.readingContainerSingleValueHeight;
|
|
||||||
enabledFeaturesHeight += Dimens.paddingS;
|
|
||||||
}
|
|
||||||
|
|
||||||
return enabledFeaturesHeight + Dimens.readingContainerSingleValueHeight; // ISO & ND
|
return enabledFeaturesHeight + Dimens.readingContainerSingleValueHeight; // ISO & ND
|
||||||
}
|
}
|
||||||
|
|
|
@ -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<LightmeterProAnimatedDialog> createState() => _LightmeterProAnimatedDialogState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LightmeterProAnimatedDialogState extends State<LightmeterProAnimatedDialog> {
|
||||||
|
final _key = GlobalKey<AnimatedDialogState>();
|
||||||
|
|
||||||
|
@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,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,9 +13,11 @@ class ReadingValue {
|
||||||
|
|
||||||
class ReadingValueContainer extends StatelessWidget {
|
class ReadingValueContainer extends StatelessWidget {
|
||||||
late final List<Widget> _items;
|
late final List<Widget> _items;
|
||||||
|
final Color? color;
|
||||||
|
|
||||||
ReadingValueContainer({
|
ReadingValueContainer({
|
||||||
required List<ReadingValue> values,
|
required List<ReadingValue> values,
|
||||||
|
this.color,
|
||||||
super.key,
|
super.key,
|
||||||
}) {
|
}) {
|
||||||
_items = [];
|
_items = [];
|
||||||
|
@ -29,6 +31,7 @@ class ReadingValueContainer extends StatelessWidget {
|
||||||
|
|
||||||
ReadingValueContainer.singleValue({
|
ReadingValueContainer.singleValue({
|
||||||
required ReadingValue value,
|
required ReadingValue value,
|
||||||
|
this.color,
|
||||||
super.key,
|
super.key,
|
||||||
}) : _items = [_ReadingValueBuilder(value)];
|
}) : _items = [_ReadingValueBuilder(value)];
|
||||||
|
|
||||||
|
@ -37,7 +40,7 @@ class ReadingValueContainer extends StatelessWidget {
|
||||||
return ClipRRect(
|
return ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(Dimens.borderRadiusM),
|
borderRadius: BorderRadius.circular(Dimens.borderRadiusM),
|
||||||
child: ColoredBox(
|
child: ColoredBox(
|
||||||
color: Theme.of(context).colorScheme.primaryContainer,
|
color: color ?? Theme.of(context).colorScheme.primaryContainer,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(Dimens.paddingM),
|
padding: const EdgeInsets.all(Dimens.paddingM),
|
||||||
child: Column(
|
child: Column(
|
||||||
|
|
|
@ -2,13 +2,15 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:lightmeter/data/models/exposure_pair.dart';
|
import 'package:lightmeter/data/models/exposure_pair.dart';
|
||||||
import 'package:lightmeter/data/models/metering_screen_layout_config.dart';
|
import 'package:lightmeter/data/models/metering_screen_layout_config.dart';
|
||||||
import 'package:lightmeter/providers/equipment_profile_provider.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/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/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/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/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/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/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';
|
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
||||||
|
|
||||||
class ReadingsContainer extends StatelessWidget {
|
class ReadingsContainer extends StatelessWidget {
|
||||||
|
@ -31,30 +33,26 @@ class ReadingsContainer extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final isPro = IAPProducts.isPurchased(context, IAPProductType.paidFeatures);
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
if (UserPreferencesProvider.meteringScreenFeatureOf(
|
if (!isPro) ...[
|
||||||
context,
|
const LightmeterProAnimatedDialog(),
|
||||||
MeteringScreenLayoutFeature.equipmentProfiles,
|
const _InnerPadding(),
|
||||||
)) ...[
|
],
|
||||||
|
if (isPro && context.meteringFeature(MeteringScreenLayoutFeature.equipmentProfiles)) ...[
|
||||||
const EquipmentProfilePicker(),
|
const EquipmentProfilePicker(),
|
||||||
const _InnerPadding(),
|
const _InnerPadding(),
|
||||||
],
|
],
|
||||||
if (UserPreferencesProvider.meteringScreenFeatureOf(
|
if (context.meteringFeature(MeteringScreenLayoutFeature.extremeExposurePairs)) ...[
|
||||||
context,
|
|
||||||
MeteringScreenLayoutFeature.extremeExposurePairs,
|
|
||||||
)) ...[
|
|
||||||
ExtremeExposurePairsContainer(
|
ExtremeExposurePairsContainer(
|
||||||
fastest: fastest,
|
fastest: fastest,
|
||||||
slowest: slowest,
|
slowest: slowest,
|
||||||
),
|
),
|
||||||
const _InnerPadding(),
|
const _InnerPadding(),
|
||||||
],
|
],
|
||||||
if (UserPreferencesProvider.meteringScreenFeatureOf(
|
if (isPro && context.meteringFeature(MeteringScreenLayoutFeature.filmPicker)) ...[
|
||||||
context,
|
|
||||||
MeteringScreenLayoutFeature.filmPicker,
|
|
||||||
)) ...[
|
|
||||||
FilmPicker(selectedIso: iso),
|
FilmPicker(selectedIso: iso),
|
||||||
const _InnerPadding(),
|
const _InnerPadding(),
|
||||||
],
|
],
|
||||||
|
|
12
lib/utils/context_utils.dart
Normal file
12
lib/utils/context_utils.dart
Normal file
|
@ -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);
|
||||||
|
}
|
Loading…
Reference in a new issue