ML-130 Added ff for the "Pro features" tile on the main screen (#149)

* added ff for Pro features tile on main screen
This commit is contained in:
Vadim 2024-01-15 22:57:40 +01:00 committed by GitHub
parent 8f5893c7d2
commit 2b2a5441c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 19 deletions

View file

@ -1,5 +1,5 @@
enum Feature { unlockProFeaturesText } enum Feature { showUnlockProOnMainScreen }
const featuresDefaultValues = { const featuresDefaultValues = {
Feature.unlockProFeaturesText: true, Feature.showUnlockProOnMainScreen: false,
}; };

View file

@ -124,7 +124,7 @@ class MockRemoteConfigService implements IRemoteConfigService {
extension on RemoteConfigValue { extension on RemoteConfigValue {
dynamic toValue(Feature feature) { dynamic toValue(Feature feature) {
switch (feature) { switch (feature) {
case Feature.unlockProFeaturesText: case Feature.showUnlockProOnMainScreen:
return asBool(); return asBool();
} }
} }

View file

@ -3,8 +3,10 @@ import 'dart:math';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; 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/feature.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/remote_config_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';
@ -103,8 +105,10 @@ class CameraContainer extends StatelessWidget {
double _meteringContainerHeight(BuildContext context) { double _meteringContainerHeight(BuildContext context) {
double enabledFeaturesHeight = 0; double enabledFeaturesHeight = 0;
if (!context.isPro) { if (!context.isPro) {
if (RemoteConfig.isEnabled(context, Feature.showUnlockProOnMainScreen)) {
enabledFeaturesHeight += Dimens.readingContainerSingleValueHeight; enabledFeaturesHeight += Dimens.readingContainerSingleValueHeight;
enabledFeaturesHeight += Dimens.paddingS; enabledFeaturesHeight += Dimens.paddingS;
}
} else { } else {
if (context.meteringFeature(MeteringScreenLayoutFeature.equipmentProfiles)) { if (context.meteringFeature(MeteringScreenLayoutFeature.equipmentProfiles)) {
enabledFeaturesHeight += Dimens.readingContainerSingleValueHeight; enabledFeaturesHeight += Dimens.readingContainerSingleValueHeight;

View file

@ -1,7 +1,9 @@
import 'package:flutter/material.dart'; 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/feature.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/remote_config_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';
@ -35,7 +37,7 @@ class ReadingsContainer extends StatelessWidget {
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
if (!context.isPro) ...[ if (!context.isPro && RemoteConfig.isEnabled(context, Feature.showUnlockProOnMainScreen)) ...[
const LightmeterProAnimatedDialog(), const LightmeterProAnimatedDialog(),
const _InnerPadding(), const _InnerPadding(),
], ],

View file

@ -19,8 +19,8 @@ void main() {
setUp(() { setUp(() {
when(() => mockRemoteConfigService.fetchConfig()).thenAnswer((_) async {}); when(() => mockRemoteConfigService.fetchConfig()).thenAnswer((_) async {});
when(() => mockRemoteConfigService.getValue(Feature.unlockProFeaturesText)).thenReturn(false); when(() => mockRemoteConfigService.getValue(Feature.showUnlockProOnMainScreen)).thenReturn(false);
when(() => mockRemoteConfigService.getAll()).thenReturn({Feature.unlockProFeaturesText: false}); when(() => mockRemoteConfigService.getAll()).thenReturn({Feature.showUnlockProOnMainScreen: false});
}); });
tearDown(() { tearDown(() {
@ -42,7 +42,7 @@ void main() {
when(() => mockRemoteConfigService.onConfigUpdated()).thenAnswer((_) => const Stream.empty()); when(() => mockRemoteConfigService.onConfigUpdated()).thenAnswer((_) => const Stream.empty());
await pumpTestWidget(tester); await pumpTestWidget(tester);
expect(find.text('unlockProFeaturesText: false'), findsOneWidget); expect(find.text('showUnlockProOnMainScreen: false'), findsOneWidget);
}, },
); );
@ -53,34 +53,34 @@ void main() {
when(() => mockRemoteConfigService.onConfigUpdated()).thenAnswer((_) => remoteConfigUpdateController.stream); when(() => mockRemoteConfigService.onConfigUpdated()).thenAnswer((_) => remoteConfigUpdateController.stream);
await pumpTestWidget(tester); await pumpTestWidget(tester);
expect(find.text('unlockProFeaturesText: false'), findsOneWidget); expect(find.text('showUnlockProOnMainScreen: false'), findsOneWidget);
when(() => mockRemoteConfigService.getValue(Feature.unlockProFeaturesText)).thenReturn(true); when(() => mockRemoteConfigService.getValue(Feature.showUnlockProOnMainScreen)).thenReturn(true);
remoteConfigUpdateController.add({Feature.unlockProFeaturesText}); remoteConfigUpdateController.add({Feature.showUnlockProOnMainScreen});
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.text('unlockProFeaturesText: true'), findsOneWidget); expect(find.text('showUnlockProOnMainScreen: true'), findsOneWidget);
await remoteConfigUpdateController.close(); await remoteConfigUpdateController.close();
}, },
); );
test('RemoteConfig.updateShouldNotifyDependent', () { test('RemoteConfig.updateShouldNotifyDependent', () {
const config = RemoteConfig(config: {Feature.unlockProFeaturesText: false}, child: SizedBox()); const config = RemoteConfig(config: {Feature.showUnlockProOnMainScreen: false}, child: SizedBox());
expect( expect(
config.updateShouldNotifyDependent(config, {}), config.updateShouldNotifyDependent(config, {}),
false, false,
); );
expect( expect(
config.updateShouldNotifyDependent( config.updateShouldNotifyDependent(
const RemoteConfig(config: {Feature.unlockProFeaturesText: false}, child: SizedBox()), const RemoteConfig(config: {Feature.showUnlockProOnMainScreen: false}, child: SizedBox()),
{Feature.unlockProFeaturesText}, {Feature.showUnlockProOnMainScreen},
), ),
false, false,
); );
expect( expect(
config.updateShouldNotifyDependent( config.updateShouldNotifyDependent(
const RemoteConfig(config: {Feature.unlockProFeaturesText: true}, child: SizedBox()), const RemoteConfig(config: {Feature.showUnlockProOnMainScreen: true}, child: SizedBox()),
{Feature.unlockProFeaturesText}, {Feature.showUnlockProOnMainScreen},
), ),
true, true,
); );
@ -96,7 +96,7 @@ class _Application extends StatelessWidget {
home: Scaffold( home: Scaffold(
body: Center( body: Center(
child: Text( child: Text(
"${Feature.unlockProFeaturesText.name}: ${RemoteConfig.isEnabled(context, Feature.unlockProFeaturesText)}", "${Feature.showUnlockProOnMainScreen.name}: ${RemoteConfig.isEnabled(context, Feature.showUnlockProOnMainScreen)}",
), ),
), ),
), ),