mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-25 08:50:40 +00:00
Merge branch 'main' of https://github.com/vodemn/m3_lightmeter into bugfix/ML-134
This commit is contained in:
commit
147e74461a
5 changed files with 25 additions and 19 deletions
|
@ -1,5 +1,5 @@
|
||||||
enum Feature { unlockProFeaturesText }
|
enum Feature { showUnlockProOnMainScreen }
|
||||||
|
|
||||||
const featuresDefaultValues = {
|
const featuresDefaultValues = {
|
||||||
Feature.unlockProFeaturesText: true,
|
Feature.showUnlockProOnMainScreen: false,
|
||||||
};
|
};
|
||||||
|
|
|
@ -130,7 +130,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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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(),
|
||||||
],
|
],
|
||||||
|
|
|
@ -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)}",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue