Compare commits

..

4 commits

Author SHA1 Message Date
github-actions[bot]
d66404e085 Version bump 2024-01-15 22:28:33 +00:00
Vadim
85c409fbe8
ML-134 Firebase Remote Config issues (#150)
* added try-catch to config fetch
2024-01-15 23:13:26 +01:00
Vadim
2b2a5441c7
ML-130 Added ff for the "Pro features" tile on the main screen (#149)
* added ff for Pro features tile on main screen
2024-01-15 22:57:40 +01:00
Vadim
8f5893c7d2
ML-143 EV100 indication (#148)
* added `showEV100` to user preferences

* integrated EV100 setting to UI

* available for pro

* replaced `IAPProducts.isPurchased` with context extension

* fixed `UserPreferencesProvider` tests

* EV100 -> Ev100
2024-01-15 20:47:10 +01:00
25 changed files with 175 additions and 46 deletions

View file

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

View file

@ -52,9 +52,15 @@ class RemoteConfigService implements IRemoteConfigService {
@override
Future<void> fetchConfig() async {
try {
// https://github.com/firebase/flutterfire/issues/6196#issuecomment-927751667
await Future.delayed(const Duration(seconds: 1));
await FirebaseRemoteConfig.instance.fetch();
} on FirebaseException catch (e) {
_logError('Firebase exception during Firebase Remote Config fetch: $e');
} catch (e) {
_logError('Error during Firebase Remote Config fetch: $e');
}
}
@override
@ -124,7 +130,7 @@ class MockRemoteConfigService implements IRemoteConfigService {
extension on RemoteConfigValue {
dynamic toValue(Feature feature) {
switch (feature) {
case Feature.unlockProFeaturesText:
case Feature.showUnlockProOnMainScreen:
return asBool();
}
}

View file

@ -16,6 +16,7 @@ class UserPreferencesService {
static const evSourceTypeKey = "evSourceType";
static const stopTypeKey = "stopType";
static const showEv100Key = "showEv100";
static const cameraEvCalibrationKey = "cameraEvCalibration";
static const lightSensorEvCalibrationKey = "lightSensorEvCalibration";
static const meteringScreenLayoutKey = "meteringScreenLayout";
@ -84,6 +85,9 @@ class UserPreferencesService {
StopType get stopType => StopType.values[_sharedPreferences.getInt(stopTypeKey) ?? 2];
set stopType(StopType value) => _sharedPreferences.setInt(stopTypeKey, value.index);
bool get showEv100 => _sharedPreferences.getBool(showEv100Key) ?? false;
set showEv100(bool value) => _sharedPreferences.setBool(showEv100Key, value);
MeteringScreenLayoutConfig get meteringScreenLayout {
final configJson = _sharedPreferences.getString(meteringScreenLayoutKey);
if (configJson != null) {

View file

@ -34,6 +34,7 @@
"calibrationMessageCameraOnly": "The accuracy of the readings measured by this application depends entirely on the rear camera of the device. Therefore, consider testing this application and setting up an EV calibration value that will give you the desired measurement results.",
"camera": "Camera",
"lightSensor": "Light sensor",
"showEv100": "Show EV\u2081\u2080\u2080",
"meteringScreenLayout": "Metering screen layout",
"meteringScreenLayoutHint": "Hide elements on the metering screen that you don't need so that they don't waste exposure pairs list space.",
"meteringScreenLayoutHintEquipmentProfiles": "Equipment profile picker",

View file

@ -34,6 +34,7 @@
"calibrationMessageCameraOnly": "La précision des lectures mesurées par cette application dépend entièrement de la caméra arrière de l'appareil. Par conséquent, envisagez de tester cette application et de configurer une valeur d'étalonnage EV qui vous donnera les résultats de mesure souhaités.",
"camera": "Caméra",
"lightSensor": "Capteur de lumière",
"showEv100": "Montrer EV\u2081\u2080\u2080",
"meteringScreenLayout": "Disposition de l'écran de mesure",
"meteringScreenLayoutHint": "Masquer les éléments sur l'écran de mesure dont vous n'avez pas besoin pour qu'ils ne gaspillent pas de l'espace dans les paires d'exposition.",
"meteringScreenLayoutHintEquipmentProfiles": "Sélecteur de profil de l'équipement",

View file

@ -34,6 +34,7 @@
"calibrationMessageCameraOnly": "Точность измерений данного приложения полностью зависит от точности камеры вашего устройства. Поэтому рекомендуется самостоятельно подобрать калибровочное значение, которое даст желаемый результат измерений.",
"camera": "Камера",
"lightSensor": "Датчик освещённости",
"showEv100": "Показывать EV\u2081\u2080\u2080",
"meteringScreenLayout": "Элементы главного экрана",
"meteringScreenLayoutHint": "Здесь вы можете скрыть некоторые ненужные или неиспользуемые элементы с главного экрана.",
"meteringScreenLayoutHintEquipmentProfiles": "Выбор профиля оборудования",

View file

@ -34,6 +34,7 @@
"calibrationMessageCameraOnly": "此应用程序测量读数的准确s性完全取决于设备的后置摄像头。因此请考虑测试此应用并手动设置 EV 校准,以获得准确的测量结果。",
"camera": "摄像头",
"lightSensor": "光传感器",
"showEv100": "显示 EV\u2081\u2080\u2080",
"meteringScreenLayout": "布局",
"meteringScreenLayoutHint": "隐藏不需要的元素,以免浪费曝光列表空间",
"meteringScreenLayoutHintEquipmentProfiles": "设备配置选择",

View file

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:lightmeter/utils/context_utils.dart';
import 'package:lightmeter/utils/selectable_provider.dart';
import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart';
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
@ -52,9 +53,9 @@ class EquipmentProfileProviderState extends State<EquipmentProfileProvider> {
return EquipmentProfiles(
values: [
_defaultProfile,
if (IAPProducts.isPurchased(context, IAPProductType.paidFeatures)) ..._customProfiles,
if (context.isPro) ..._customProfiles,
],
selected: IAPProducts.isPurchased(context, IAPProductType.paidFeatures) ? _selectedProfile : _defaultProfile,
selected: context.isPro ? _selectedProfile : _defaultProfile,
child: widget.child,
);
}

View file

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:lightmeter/utils/context_utils.dart';
import 'package:lightmeter/utils/selectable_provider.dart';
import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart';
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
@ -44,11 +45,9 @@ class FilmsProviderState extends State<FilmsProvider> {
],
filmsInUse: [
const Film.other(),
if (IAPProducts.isPurchased(context, IAPProductType.paidFeatures)) ..._filmsInUse,
if (context.isPro) ..._filmsInUse,
],
selected: IAPProducts.isPurchased(context, IAPProductType.paidFeatures)
? _selected
: const Film.other(),
selected: context.isPro ? _selected : const Film.other(),
child: widget.child,
);
}

View file

@ -53,6 +53,10 @@ class UserPreferencesProvider extends StatefulWidget {
return _inheritFromEnumsModel(context, _Aspect.stopType).stopType;
}
static bool showEv100Of(BuildContext context) {
return _inheritFromEnumsModel(context, _Aspect.showEv100).showEv100;
}
static CameraFeaturesConfig cameraConfigOf(BuildContext context) {
return context.findAncestorWidgetOfExactType<_CameraFeaturesModel>()!.data;
}
@ -83,6 +87,7 @@ class UserPreferencesProvider extends StatefulWidget {
class _UserPreferencesProviderState extends State<UserPreferencesProvider> with WidgetsBindingObserver {
late EvSourceType _evSourceType;
late StopType _stopType = widget.userPreferencesService.stopType;
late bool _showEv100 = widget.userPreferencesService.showEv100;
late MeteringScreenLayoutConfig _meteringScreenLayout = widget.userPreferencesService.meteringScreenLayout;
late CameraFeaturesConfig _cameraFeatures = widget.userPreferencesService.cameraFeatures;
late SupportedLocale _locale = widget.userPreferencesService.locale;
@ -135,6 +140,7 @@ class _UserPreferencesProviderState extends State<UserPreferencesProvider> with
evSourceType: _evSourceType,
locale: _locale,
primaryColor: dynamicPrimaryColor ?? _primaryColor,
showEv100: _showEv100,
stopType: _stopType,
themeType: _themeType,
child: _MeteringScreenLayoutModel(
@ -201,6 +207,13 @@ class _UserPreferencesProviderState extends State<UserPreferencesProvider> with
widget.userPreferencesService.primaryColor = primaryColor;
}
void toggleShowEv100() {
setState(() {
_showEv100 = !_showEv100;
});
widget.userPreferencesService.showEv100 = _showEv100;
}
void setStopType(StopType stopType) {
setState(() {
_stopType = stopType;
@ -231,6 +244,7 @@ enum _Aspect {
dynamicColorState,
evSourceType,
locale,
showEv100,
stopType,
theme,
themeType,
@ -240,6 +254,7 @@ class _UserPreferencesModel extends InheritedModel<_Aspect> {
final DynamicColorState dynamicColorState;
final EvSourceType evSourceType;
final SupportedLocale locale;
final bool showEv100;
final StopType stopType;
final ThemeType themeType;
@ -252,6 +267,7 @@ class _UserPreferencesModel extends InheritedModel<_Aspect> {
required this.evSourceType,
required this.locale,
required Color primaryColor,
required this.showEv100,
required this.stopType,
required this.themeType,
required super.child,
@ -267,6 +283,7 @@ class _UserPreferencesModel extends InheritedModel<_Aspect> {
evSourceType != oldWidget.evSourceType ||
locale != oldWidget.locale ||
_primaryColor != oldWidget._primaryColor ||
showEv100 != oldWidget.showEv100 ||
stopType != oldWidget.stopType ||
themeType != oldWidget.themeType;
}
@ -279,6 +296,7 @@ class _UserPreferencesModel extends InheritedModel<_Aspect> {
return (dependencies.contains(_Aspect.dynamicColorState) && dynamicColorState != oldWidget.dynamicColorState) ||
(dependencies.contains(_Aspect.evSourceType) && evSourceType != oldWidget.evSourceType) ||
(dependencies.contains(_Aspect.locale) && locale != oldWidget.locale) ||
(dependencies.contains(_Aspect.showEv100) && showEv100 != oldWidget.showEv100) ||
(dependencies.contains(_Aspect.stopType) && stopType != oldWidget.stopType) ||
(dependencies.contains(_Aspect.theme) &&
(_brightness != oldWidget._brightness || _primaryColor != oldWidget._primaryColor)) ||

View file

@ -1,15 +1,21 @@
import 'package:flutter/material.dart';
import 'package:lightmeter/generated/l10n.dart';
import 'package:lightmeter/providers/user_preferences_provider.dart';
import 'package:lightmeter/res/dimens.dart';
import 'package:lightmeter/screens/shared/filled_circle/widget_circle_filled.dart';
import 'package:lightmeter/utils/context_utils.dart';
const String _subscript100 = '\u2081\u2080\u2080';
class MeteringMeasureButton extends StatefulWidget {
final double? ev;
final double? ev100;
final bool isMetering;
final VoidCallback onTap;
const MeteringMeasureButton({
required this.ev,
required this.ev100,
required this.isMetering,
required this.onTap,
super.key,
@ -61,7 +67,7 @@ class _MeteringMeasureButtonState extends State<MeteringMeasureButton> {
color: Theme.of(context).colorScheme.onSurface,
size: Dimens.grid72 - Dimens.grid8,
child: Center(
child: widget.ev != null ? _EvValueText(ev: widget.ev!) : null,
child: widget.ev != null ? _EvValueText(ev: widget.ev!, ev100: widget.ev100!) : null,
),
),
),
@ -83,16 +89,32 @@ class _MeteringMeasureButtonState extends State<MeteringMeasureButton> {
class _EvValueText extends StatelessWidget {
final double ev;
final double ev100;
const _EvValueText({required this.ev});
const _EvValueText({
required this.ev,
required this.ev100,
});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Text(
'${ev.toStringAsFixed(1)}\n${S.of(context).ev}',
_text(context),
style: theme.textTheme.bodyMedium?.copyWith(color: theme.colorScheme.surface),
textAlign: TextAlign.center,
);
}
String _text(BuildContext context) {
final bool showEv100 = context.isPro && UserPreferencesProvider.showEv100Of(context);
final StringBuffer buffer = StringBuffer()
..writeAll([
(showEv100 ? ev100 : ev).toStringAsFixed(1),
'\n',
S.of(context).ev,
if (showEv100) _subscript100,
]);
return buffer.toString();
}
}

View file

@ -5,6 +5,7 @@ import 'package:lightmeter/screens/metering/components/bottom_controls/widget_bo
class MeteringBottomControlsProvider extends StatelessWidget {
final double? ev;
final double? ev100;
final bool isMetering;
final VoidCallback? onSwitchEvSourceType;
final VoidCallback onMeasure;
@ -12,6 +13,7 @@ class MeteringBottomControlsProvider extends StatelessWidget {
const MeteringBottomControlsProvider({
required this.ev,
required this.ev100,
required this.isMetering,
required this.onSwitchEvSourceType,
required this.onMeasure,
@ -35,6 +37,7 @@ class MeteringBottomControlsProvider extends StatelessWidget {
),
child: MeteringBottomControls(
ev: ev,
ev100: ev100,
isMetering: isMetering,
onSwitchEvSourceType: onSwitchEvSourceType,
onMeasure: onMeasure,

View file

@ -7,6 +7,7 @@ import 'package:lightmeter/screens/metering/components/bottom_controls/component
class MeteringBottomControls extends StatelessWidget {
final double? ev;
final double? ev100;
final bool isMetering;
final VoidCallback? onSwitchEvSourceType;
final VoidCallback onMeasure;
@ -14,6 +15,7 @@ class MeteringBottomControls extends StatelessWidget {
const MeteringBottomControls({
required this.ev,
required this.ev100,
required this.isMetering,
required this.onSwitchEvSourceType,
required this.onMeasure,
@ -58,6 +60,7 @@ class MeteringBottomControls extends StatelessWidget {
const Spacer(),
MeteringMeasureButton(
ev: ev,
ev100: ev100,
isMetering: isMetering,
onTap: onMeasure,
),

View file

@ -9,7 +9,7 @@ import 'package:lightmeter/screens/metering/components/camera_container/componen
import 'package:lightmeter/screens/metering/components/camera_container/components/camera_preview/components/camera_view_placeholder/widget_placeholder_camera_view.dart';
import 'package:lightmeter/screens/metering/components/camera_container/components/camera_preview/components/histogram/widget_histogram.dart';
import 'package:lightmeter/screens/metering/components/camera_container/models/camera_error_type.dart';
import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart';
import 'package:lightmeter/utils/context_utils.dart';
class CameraPreview extends StatefulWidget {
final CameraController? controller;
@ -93,7 +93,7 @@ class _CameraPreviewBuilderState extends State<_CameraPreviewBuilder> {
alignment: Alignment.bottomCenter,
children: [
CameraView(controller: widget.controller),
if (IAPProducts.isPurchased(context, IAPProductType.paidFeatures)) ...[
if (context.isPro) ...[
if (UserPreferencesProvider.cameraFeatureOf(
context,
CameraFeature.histogram,

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';
@ -17,7 +19,6 @@ import 'package:lightmeter/screens/metering/components/shared/exposure_pairs_lis
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/utils/context_utils.dart';
import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart';
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
class CameraContainer extends StatelessWidget {
@ -102,11 +103,12 @@ class CameraContainer extends StatelessWidget {
}
double _meteringContainerHeight(BuildContext context) {
final isPro = IAPProducts.isPurchased(context, IAPProductType.paidFeatures);
double enabledFeaturesHeight = 0;
if (!isPro) {
if (!context.isPro) {
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';
@ -10,7 +12,6 @@ import 'package:lightmeter/screens/metering/components/shared/readings_container
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/utils/context_utils.dart';
import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart';
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
class ReadingsContainer extends StatelessWidget {
@ -33,15 +34,14 @@ class ReadingsContainer extends StatelessWidget {
@override
Widget build(BuildContext context) {
final isPro = IAPProducts.isPurchased(context, IAPProductType.paidFeatures);
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
if (!isPro) ...[
if (!context.isPro && RemoteConfig.isEnabled(context, Feature.showUnlockProOnMainScreen)) ...[
const LightmeterProAnimatedDialog(),
const _InnerPadding(),
],
if (isPro && context.meteringFeature(MeteringScreenLayoutFeature.equipmentProfiles)) ...[
if (context.isPro && context.meteringFeature(MeteringScreenLayoutFeature.equipmentProfiles)) ...[
const EquipmentProfilePicker(),
const _InnerPadding(),
],
@ -52,7 +52,7 @@ class ReadingsContainer extends StatelessWidget {
),
const _InnerPadding(),
],
if (isPro && context.meteringFeature(MeteringScreenLayoutFeature.filmPicker)) ...[
if (context.isPro && context.meteringFeature(MeteringScreenLayoutFeature.filmPicker)) ...[
FilmPicker(selectedIso: iso),
const _InnerPadding(),
],

View file

@ -40,6 +40,7 @@ class MeteringScreen extends StatelessWidget {
BlocBuilder<MeteringBloc, MeteringState>(
builder: (context, state) => MeteringBottomControlsProvider(
ev: state is MeteringDataState ? state.ev : null,
ev100: state is MeteringDataState ? state.ev100 : null,
isMetering: state.isMetering,
onSwitchEvSourceType: ServicesProvider.of(context).environment.hasLightSensor
? UserPreferencesProvider.of(context).toggleEvSourceType

View file

@ -0,0 +1,24 @@
import 'package:flutter/material.dart';
import 'package:lightmeter/generated/l10n.dart';
import 'package:lightmeter/providers/user_preferences_provider.dart';
import 'package:lightmeter/res/dimens.dart';
import 'package:lightmeter/screens/settings/components/shared/disable/widget_disable.dart';
import 'package:lightmeter/utils/context_utils.dart';
class ShowEv100ListTile extends StatelessWidget {
const ShowEv100ListTile({super.key});
@override
Widget build(BuildContext context) {
return Disable(
disable: !context.isPro,
child: SwitchListTile(
secondary: const Icon(Icons.adjust),
title: Text(S.of(context).showEv100),
value: context.isPro && UserPreferencesProvider.showEv100Of(context),
onChanged: (_) => UserPreferencesProvider.of(context).toggleShowEv100(),
contentPadding: const EdgeInsets.symmetric(horizontal: Dimens.paddingM),
),
);
}
}

View file

@ -6,6 +6,7 @@ import 'package:lightmeter/screens/settings/components/metering/components/equip
import 'package:lightmeter/screens/settings/components/metering/components/films/widget_list_tile_films.dart';
import 'package:lightmeter/screens/settings/components/metering/components/fractional_stops/widget_list_tile_fractional_stops.dart';
import 'package:lightmeter/screens/settings/components/metering/components/metering_screen_layout/widget_list_tile_metering_screen_layout.dart';
import 'package:lightmeter/screens/settings/components/metering/components/show_ev_100/widget_list_tile_show_ev_100.dart';
import 'package:lightmeter/screens/settings/components/shared/settings_section/widget_settings_section.dart';
class MeteringSettingsSection extends StatelessWidget {
@ -18,6 +19,7 @@ class MeteringSettingsSection extends StatelessWidget {
children: const [
StopTypeListTile(),
CalibrationListTile(),
ShowEv100ListTile(),
MeteringScreenLayoutListTile(),
EquipmentProfilesListTile(),
FilmsListTile(),

View file

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:lightmeter/screens/settings/components/shared/disable/widget_disable.dart';
import 'package:lightmeter/utils/context_utils.dart';
import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart';
/// Depends on the product status and replaces [onTap] with purchase callback
@ -22,9 +23,8 @@ class IAPListTile extends StatelessWidget {
@override
Widget build(BuildContext context) {
final isPurchased = IAPProducts.isPurchased(context, IAPProductType.paidFeatures);
return Disable(
disable: !isPurchased,
disable: !context.isPro,
child: ListTile(
leading: leading,
title: title,

View file

@ -7,7 +7,7 @@ import 'package:lightmeter/screens/settings/components/metering/widget_settings_
import 'package:lightmeter/screens/settings/components/theme/widget_settings_section_theme.dart';
import 'package:lightmeter/screens/settings/flow_settings.dart';
import 'package:lightmeter/screens/shared/sliver_screen/screen_sliver.dart';
import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart';
import 'package:lightmeter/utils/context_utils.dart';
class SettingsScreen extends StatefulWidget {
const SettingsScreen({super.key});
@ -38,8 +38,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
SliverList(
delegate: SliverChildListDelegate(
<Widget>[
if (!IAPProducts.isPurchased(context, IAPProductType.paidFeatures))
const LightmeterProSettingsSection(),
if (!context.isPro) const LightmeterProSettingsSection(),
const MeteringSettingsSection(),
const GeneralSettingsSection(),
const ThemeSettingsSection(),

View file

@ -1,7 +1,7 @@
name: lightmeter
description: Lightmeter app inspired by Material 3 design system.
publish_to: "none"
version: 0.16.0+45
version: 0.17.0+46
environment:
sdk: ">=3.0.0 <4.0.0"

View file

@ -181,6 +181,25 @@ void main() {
});
});
group('showEv100', () {
test('get default', () {
when(() => sharedPreferences.getBool(UserPreferencesService.showEv100Key)).thenReturn(null);
expect(service.showEv100, false);
});
test('get', () {
when(() => sharedPreferences.getBool(UserPreferencesService.showEv100Key)).thenReturn(true);
expect(service.showEv100, true);
});
test('set', () {
when(() => sharedPreferences.setBool(UserPreferencesService.showEv100Key, false))
.thenAnswer((_) => Future.value(true));
service.showEv100 = false;
verify(() => sharedPreferences.setBool(UserPreferencesService.showEv100Key, false)).called(1);
});
});
group('meteringScreenLayout', () {
test('get default', () {
when(

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)}",
),
),
),

View file

@ -27,6 +27,7 @@ void main() {
setUp(() {
when(() => mockUserPreferencesService.evSourceType).thenReturn(EvSourceType.camera);
when(() => mockUserPreferencesService.showEv100).thenReturn(false);
when(() => mockUserPreferencesService.stopType).thenReturn(StopType.third);
when(() => mockUserPreferencesService.meteringScreenLayout).thenReturn({
MeteringScreenLayoutFeature.extremeExposurePairs: true,
@ -164,6 +165,27 @@ void main() {
},
);
testWidgets(
'Toggle Ev100',
(tester) async {
when(() => mockUserPreferencesService.showEv100).thenReturn(false);
await pumpTestWidget(
tester,
builder: (context) => ElevatedButton(
onPressed: () => UserPreferencesProvider.of(context).toggleShowEv100(),
child: Text('${UserPreferencesProvider.showEv100Of(context)}'),
),
);
await tester.pumpAndSettle();
expect(find.text("${false}"), findsOneWidget);
await tester.tap(find.text("${false}"));
await tester.pumpAndSettle();
expect(find.text("${true}"), findsOneWidget);
verify(() => mockUserPreferencesService.showEv100 = true).called(1);
},
);
testWidgets(
'Set metering screen layout config',
(tester) async {