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 = {
Feature.unlockProFeaturesText: true,
Feature.showUnlockProOnMainScreen: false,
};

View file

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

View file

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

View file

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

View file

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