From 0fc3f512f398a495f38d6247c869e1e4c4c6dfe7 Mon Sep 17 00:00:00 2001 From: Vadim Date: Mon, 17 Apr 2023 12:16:46 +0300 Subject: [PATCH] added equipment profiles to layout config --- .vscode/launch.json | 2 + ios/Runner.xcodeproj/project.pbxproj | 16 ++++--- .../models/metering_screen_layout_config.dart | 2 +- lib/data/shared_prefs_service.dart | 1 + lib/features.dart | 3 -- lib/providers.dart | 46 ++++++++++--------- .../widget_container_camera.dart | 4 +- .../widget_container_readings.dart | 6 ++- .../widget_list_tile_equipment_profiles.dart | 11 +++-- ...ialog_metering_screen_layout_features.dart | 2 + .../widget_settings_section_metering.dart | 3 +- pubspec.yaml | 4 +- 12 files changed, 56 insertions(+), 44 deletions(-) delete mode 100644 lib/features.dart diff --git a/.vscode/launch.json b/.vscode/launch.json index fb960be..9984519 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -31,6 +31,7 @@ { "name": "prod (android)", "request": "launch", + //"flutterMode": "release", "type": "dart", "args": [ "--flavor", @@ -43,6 +44,7 @@ { "name": "prod (ios)", "request": "launch", + //"flutterMode": "release", "type": "dart", "args": [ "--flavor", diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index a858962..73ce339 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 51; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -237,6 +237,7 @@ }; 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -268,6 +269,7 @@ }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -371,7 +373,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = 74JQ9DBXY6; + DEVELOPMENT_TEAM = 489Z6UQMGN; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( @@ -500,7 +502,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = 74JQ9DBXY6; + DEVELOPMENT_TEAM = 489Z6UQMGN; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( @@ -523,7 +525,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = 74JQ9DBXY6; + DEVELOPMENT_TEAM = 489Z6UQMGN; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( @@ -600,7 +602,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = 74JQ9DBXY6; + DEVELOPMENT_TEAM = 489Z6UQMGN; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( @@ -675,7 +677,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = 74JQ9DBXY6; + DEVELOPMENT_TEAM = 489Z6UQMGN; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( @@ -747,7 +749,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = 74JQ9DBXY6; + DEVELOPMENT_TEAM = 489Z6UQMGN; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( diff --git a/lib/data/models/metering_screen_layout_config.dart b/lib/data/models/metering_screen_layout_config.dart index 3410632..dffaab4 100644 --- a/lib/data/models/metering_screen_layout_config.dart +++ b/lib/data/models/metering_screen_layout_config.dart @@ -1,4 +1,4 @@ -enum MeteringScreenLayoutFeature { extremeExposurePairs, filmPicker } +enum MeteringScreenLayoutFeature { equipmentProfiles, extremeExposurePairs, filmPicker } typedef MeteringScreenLayoutConfig = Map; diff --git a/lib/data/shared_prefs_service.dart b/lib/data/shared_prefs_service.dart index 76f9045..49e1e73 100644 --- a/lib/data/shared_prefs_service.dart +++ b/lib/data/shared_prefs_service.dart @@ -95,6 +95,7 @@ class UserPreferencesService { ); } else { return { + MeteringScreenLayoutFeature.equipmentProfiles: true, MeteringScreenLayoutFeature.extremeExposurePairs: true, MeteringScreenLayoutFeature.filmPicker: true, }; diff --git a/lib/features.dart b/lib/features.dart deleted file mode 100644 index deede30..0000000 --- a/lib/features.dart +++ /dev/null @@ -1,3 +0,0 @@ -class FeaturesConfig { - static const bool equipmentProfilesEnabled = false; -} diff --git a/lib/providers.dart b/lib/providers.dart index d7907ab..26630a9 100644 --- a/lib/providers.dart +++ b/lib/providers.dart @@ -31,28 +31,30 @@ class LightmeterProviders extends StatelessWidget { ]), builder: (_, snapshot) { if (snapshot.data != null) { - return InheritedWidgetBase( - data: env.copyWith(hasLightSensor: snapshot.data![1] as bool), - child: InheritedWidgetBase( - data: UserPreferencesService(snapshot.data![0] as SharedPreferences), - child: InheritedWidgetBase( - data: const LightSensorService(LocalPlatform()), - child: InheritedWidgetBase( - data: const CaffeineService(), - child: InheritedWidgetBase( - data: const HapticsService(), - child: InheritedWidgetBase( - data: const VolumeEventsService(LocalPlatform()), - child: InheritedWidgetBase( - data: const PermissionsService(), - child: MeteringScreenLayoutProvider( - child: StopTypeProvider( - child: EquipmentProfileProvider( - child: EvSourceTypeProvider( - child: SupportedLocaleProvider( - child: ThemeProvider( - child: Builder( - builder: (context) => builder(context, true), + return IAPProductsProvider( + child: InheritedWidgetBase( + data: env.copyWith(hasLightSensor: snapshot.data![1] as bool), + child: InheritedWidgetBase( + data: UserPreferencesService(snapshot.data![0] as SharedPreferences), + child: InheritedWidgetBase( + data: const LightSensorService(LocalPlatform()), + child: InheritedWidgetBase( + data: const CaffeineService(), + child: InheritedWidgetBase( + data: const HapticsService(), + child: InheritedWidgetBase( + data: const VolumeEventsService(LocalPlatform()), + child: InheritedWidgetBase( + data: const PermissionsService(), + child: MeteringScreenLayoutProvider( + child: StopTypeProvider( + child: EquipmentProfileProvider( + child: EvSourceTypeProvider( + child: SupportedLocaleProvider( + child: ThemeProvider( + child: Builder( + builder: (context) => builder(context, true), + ), ), ), ), 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 2f8ef45..8d2885d 100644 --- a/lib/screens/metering/components/camera_container/widget_container_camera.dart +++ b/lib/screens/metering/components/camera_container/widget_container_camera.dart @@ -3,7 +3,6 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:lightmeter/data/models/exposure_pair.dart'; import 'package:lightmeter/data/models/film.dart'; import 'package:lightmeter/data/models/metering_screen_layout_config.dart'; -import 'package:lightmeter/features.dart'; import 'package:lightmeter/platform_config.dart'; import 'package:lightmeter/providers/metering_screen_layout_provider.dart'; import 'package:lightmeter/res/dimens.dart'; @@ -18,6 +17,7 @@ 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:m3_lightmeter_iap/m3_lightmeter_iap.dart'; import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; class CameraContainer extends StatelessWidget { @@ -52,7 +52,7 @@ class CameraContainer extends StatelessWidget { double topBarOverflow = Dimens.readingContainerSingleValueHeight + // ISO & ND -cameraViewHeight; - if (FeaturesConfig.equipmentProfilesEnabled) { + if (IAPProducts.isPurchased(context, IAPProductType.equipment)) { topBarOverflow += Dimens.readingContainerSingleValueHeight; topBarOverflow += Dimens.paddingS; } 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 09f8bce..98badc1 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,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:lightmeter/data/models/exposure_pair.dart'; import 'package:lightmeter/data/models/film.dart'; import 'package:lightmeter/data/models/metering_screen_layout_config.dart'; -import 'package:lightmeter/features.dart'; import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/providers/equipment_profile_provider.dart'; import 'package:lightmeter/providers/metering_screen_layout_provider.dart'; @@ -10,6 +9,7 @@ import 'package:lightmeter/res/dimens.dart'; import 'package:lightmeter/screens/metering/components/shared/readings_container/components/animated_dialog_picker/widget_picker_dialog_animated.dart'; import 'package:lightmeter/screens/metering/components/shared/readings_container/components/reading_value_container/widget_container_reading_value.dart'; import 'package:lightmeter/utils/inherited_generics.dart'; +import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart'; import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; class ReadingsContainer extends StatelessWidget { @@ -36,10 +36,12 @@ class ReadingsContainer extends StatelessWidget { @override Widget build(BuildContext context) { + final layout = MeteringScreenLayout.of(context); return Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - if (FeaturesConfig.equipmentProfilesEnabled) ...[ + if (IAPProducts.isPurchased(context, IAPProductType.equipment) && + layout[MeteringScreenLayoutFeature.equipmentProfiles]!) ...[ const _EquipmentProfilePicker(), const _InnerPadding(), ], diff --git a/lib/screens/settings/components/metering/components/equipment_profiles/widget_list_tile_equipment_profiles.dart b/lib/screens/settings/components/metering/components/equipment_profiles/widget_list_tile_equipment_profiles.dart index 13cb6f0..f2efa4d 100644 --- a/lib/screens/settings/components/metering/components/equipment_profiles/widget_list_tile_equipment_profiles.dart +++ b/lib/screens/settings/components/metering/components/equipment_profiles/widget_list_tile_equipment_profiles.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/screen_equipment_profile.dart'; +import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart'; import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; class EquipmentProfilesListTile extends StatelessWidget { @@ -12,9 +13,13 @@ class EquipmentProfilesListTile extends StatelessWidget { leading: const Icon(Icons.camera), title: Text(S.of(context).equipmentProfiles), onTap: () { - Navigator.of(context).push( - MaterialPageRoute(builder: (_) => const EquipmentProfilesScreen()), - ); + if (IAPProducts.isPurchased(context, IAPProductType.equipment)) { + Navigator.of(context).push( + MaterialPageRoute(builder: (_) => const EquipmentProfilesScreen()), + ); + } else { + IAPProductsProvider.of(context).buy(IAPProductType.equipment); + } }, ); } diff --git a/lib/screens/settings/components/metering/components/metering_screen_layout/components/meterins_screen_layout_features_dialog/widget_dialog_metering_screen_layout_features.dart b/lib/screens/settings/components/metering/components/metering_screen_layout/components/meterins_screen_layout_features_dialog/widget_dialog_metering_screen_layout_features.dart index 654a6c4..53e8451 100644 --- a/lib/screens/settings/components/metering/components/metering_screen_layout/components/meterins_screen_layout_features_dialog/widget_dialog_metering_screen_layout_features.dart +++ b/lib/screens/settings/components/metering/components/metering_screen_layout/components/meterins_screen_layout_features_dialog/widget_dialog_metering_screen_layout_features.dart @@ -67,6 +67,8 @@ class _MeteringScreenLayoutFeaturesDialogState extends State