open Pro screen on tap

This commit is contained in:
Vadim 2025-08-09 18:40:35 +02:00
parent f9246e15d6
commit c8e75167eb
9 changed files with 87 additions and 91 deletions

View file

@ -112,20 +112,17 @@ class CameraContainer extends StatelessWidget {
double _meteringContainerHeight(BuildContext context) {
double enabledFeaturesHeight = 0;
if (!context.isPro) {
if (RemoteConfig.isEnabled(context, Feature.showUnlockProOnMainScreen)) {
enabledFeaturesHeight += Dimens.readingContainerSingleValueHeight;
enabledFeaturesHeight += Dimens.paddingS;
}
} else {
if (context.meteringFeature(MeteringScreenLayoutFeature.equipmentProfiles)) {
enabledFeaturesHeight += Dimens.readingContainerSingleValueHeight;
enabledFeaturesHeight += Dimens.paddingS;
}
if (context.meteringFeature(MeteringScreenLayoutFeature.filmPicker)) {
enabledFeaturesHeight += Dimens.readingContainerSingleValueHeight;
enabledFeaturesHeight += Dimens.paddingS;
}
if (!context.isPro && RemoteConfig.isEnabled(context, Feature.showUnlockProOnMainScreen)) {
enabledFeaturesHeight += Dimens.readingContainerSingleValueHeight;
enabledFeaturesHeight += Dimens.paddingS;
}
if (context.meteringFeature(MeteringScreenLayoutFeature.equipmentProfiles)) {
enabledFeaturesHeight += Dimens.readingContainerSingleValueHeight;
enabledFeaturesHeight += Dimens.paddingS;
}
if (context.meteringFeature(MeteringScreenLayoutFeature.filmPicker)) {
enabledFeaturesHeight += Dimens.readingContainerSingleValueHeight;
enabledFeaturesHeight += Dimens.paddingS;
}
if (context.meteringFeature(MeteringScreenLayoutFeature.extremeExposurePairs)) {
enabledFeaturesHeight += Dimens.readingContainerDoubleValueHeight;

View file

@ -41,7 +41,7 @@ class ReadingsContainer extends StatelessWidget {
const LightmeterProAnimatedDialog(),
const _InnerPadding(),
],
if (context.isPro && context.meteringFeature(MeteringScreenLayoutFeature.equipmentProfiles)) ...[
if (context.meteringFeature(MeteringScreenLayoutFeature.equipmentProfiles)) ...[
const EquipmentProfilePicker(),
const _InnerPadding(),
],
@ -52,7 +52,7 @@ class ReadingsContainer extends StatelessWidget {
),
const _InnerPadding(),
],
if (context.isPro && context.meteringFeature(MeteringScreenLayoutFeature.filmPicker)) ...[
if (context.meteringFeature(MeteringScreenLayoutFeature.filmPicker)) ...[
FilmPicker(selectedIso: iso),
const _InnerPadding(),
],

View file

@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'package:lightmeter/data/models/camera_feature.dart';
import 'package:lightmeter/generated/l10n.dart';
import 'package:lightmeter/providers/services_provider.dart';
import 'package:lightmeter/providers/user_preferences_provider.dart';
import 'package:lightmeter/screens/settings/components/shared/dialog_switch/widget_dialog_switch.dart';
import 'package:lightmeter/screens/settings/components/shared/iap_list_tile/widget_list_tile_iap.dart';
@ -21,12 +20,6 @@ class CameraFeaturesListTile extends StatelessWidget {
icon: Icons.camera_alt_outlined,
title: S.of(context).cameraFeatures,
values: UserPreferencesProvider.cameraConfigOf(context),
enabledAdapter: (feature) => switch (feature) {
CameraFeature.spotMetering => true,
CameraFeature.histogram => true,
CameraFeature.showFocalLength =>
ServicesProvider.of(context).userPreferencesService.cameraFocalLength != null,
},
titleAdapter: (context, feature) => switch (feature) {
CameraFeature.spotMetering => S.of(context).cameraFeatureSpotMetering,
CameraFeature.histogram => S.of(context).cameraFeatureHistogram,

View file

@ -1,26 +1,20 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:lightmeter/generated/l10n.dart';
import 'package:lightmeter/res/dimens.dart';
import 'package:lightmeter/screens/settings/components/general/components/timer/bloc_list_tile_timer.dart';
import 'package:lightmeter/screens/settings/components/shared/disable/widget_disable.dart';
import 'package:lightmeter/utils/context_utils.dart';
import 'package:lightmeter/screens/settings/components/shared/iap_switch_list_tile/widget_iap_switch_list_tile.dart';
class TimerListTile extends StatelessWidget {
const TimerListTile({super.key});
@override
Widget build(BuildContext context) {
return Disable(
disable: !context.isPro,
child: BlocBuilder<TimerListTileBloc, bool>(
builder: (context, state) => SwitchListTile(
secondary: const Icon(Icons.timer_outlined),
title: Text(S.of(context).autostartTimer),
value: state && context.isPro,
onChanged: context.read<TimerListTileBloc>().onChanged,
contentPadding: const EdgeInsets.symmetric(horizontal: Dimens.paddingM),
),
return BlocBuilder<TimerListTileBloc, bool>(
builder: (context, state) => IAPSwitchListTile(
secondary: const Icon(Icons.timer_outlined),
title: Text(S.of(context).autostartTimer),
value: state,
onChanged: context.read<TimerListTileBloc>().onChanged,
),
);
}

View file

@ -5,7 +5,6 @@ import 'package:lightmeter/providers/equipment_profile_provider.dart';
import 'package:lightmeter/providers/films_provider.dart';
import 'package:lightmeter/providers/user_preferences_provider.dart';
import 'package:lightmeter/screens/settings/components/shared/dialog_switch/widget_dialog_switch.dart';
import 'package:lightmeter/utils/context_utils.dart';
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
class MeteringScreenLayoutListTile extends StatelessWidget {
@ -25,15 +24,6 @@ class MeteringScreenLayoutListTile extends StatelessWidget {
description: S.of(context).meteringScreenLayoutHint,
values: UserPreferencesProvider.meteringScreenConfigOf(context),
titleAdapter: _toStringLocalized,
enabledAdapter: (value) {
switch (value) {
case MeteringScreenLayoutFeature.equipmentProfiles:
case MeteringScreenLayoutFeature.filmPicker:
return context.isPro;
default:
return true;
}
},
onSave: (value) {
if (!value[MeteringScreenLayoutFeature.equipmentProfiles]!) {
EquipmentProfilesProvider.of(context).selectProfile(EquipmentProfiles.of(context).first);

View file

@ -1,24 +1,18 @@
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';
import 'package:lightmeter/screens/settings/components/shared/iap_switch_list_tile/widget_iap_switch_list_tile.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_outlined),
title: Text(S.of(context).showEv100),
value: context.isPro && UserPreferencesProvider.showEv100Of(context),
onChanged: (_) => UserPreferencesProvider.of(context).toggleShowEv100(),
contentPadding: const EdgeInsets.symmetric(horizontal: Dimens.paddingM),
),
return IAPSwitchListTile(
secondary: const Icon(Icons.adjust_outlined),
title: Text(S.of(context).showEv100),
value: UserPreferencesProvider.showEv100Of(context),
onChanged: (_) => UserPreferencesProvider.of(context).toggleShowEv100(),
);
}
}

View file

@ -12,7 +12,6 @@ class DialogSwitch<T> extends StatefulWidget {
final Map<T, bool> values;
final StringAdapter<T> titleAdapter;
final StringAdapter<T>? subtitleAdapter;
final bool Function(T value)? enabledAdapter;
final ValueChanged<Map<T, bool>> onSave;
const DialogSwitch({
@ -22,7 +21,6 @@ class DialogSwitch<T> extends StatefulWidget {
required this.values,
required this.titleAdapter,
this.subtitleAdapter,
this.enabledAdapter,
required this.onSave,
super.key,
});
@ -57,25 +55,21 @@ class _DialogSwitchState<T> extends State<DialogSwitch<T>> {
shrinkWrap: true,
children: _features.entries.map(
(entry) {
final isEnabled = widget.enabledAdapter?.call(entry.key) ?? true;
return Disable(
disable: !isEnabled,
child: SwitchListTile(
contentPadding: EdgeInsets.symmetric(horizontal: Dimens.dialogTitlePadding.left),
title: Text(widget.titleAdapter(context, entry.key)),
subtitle: widget.subtitleAdapter != null
? Text(
widget.subtitleAdapter!.call(context, entry.key),
style: Theme.of(context).listTileTheme.subtitleTextStyle,
)
: null,
value: isEnabled && _features[entry.key]!,
onChanged: (value) {
setState(() {
_features.update(entry.key, (_) => value);
});
},
),
return SwitchListTile(
contentPadding: EdgeInsets.symmetric(horizontal: Dimens.dialogTitlePadding.left),
title: Text(widget.titleAdapter(context, entry.key)),
subtitle: widget.subtitleAdapter != null
? Text(
widget.subtitleAdapter!.call(context, entry.key),
style: Theme.of(context).listTileTheme.subtitleTextStyle,
)
: null,
value: _features[entry.key]!,
onChanged: (value) {
setState(() {
_features.update(entry.key, (_) => value);
});
},
);
},
).toList(),

View file

@ -1,32 +1,29 @@
import 'package:flutter/material.dart';
import 'package:lightmeter/screens/settings/components/shared/disable/widget_disable.dart';
import 'package:lightmeter/navigation/routes.dart';
import 'package:lightmeter/utils/context_utils.dart';
/// Depends on the product status and replaces [onTap] with purchase callback
/// if the product is purchasable.
class IAPListTile extends StatelessWidget {
final Icon leading;
final Text title;
final VoidCallback onTap;
final bool showPendingTrailing;
const IAPListTile({
required this.leading,
required this.title,
required this.onTap,
this.showPendingTrailing = false,
super.key,
});
@override
Widget build(BuildContext context) {
return Disable(
disable: !context.isPro,
child: ListTile(
leading: leading,
title: title,
onTap: onTap,
),
return ListTile(
leading: leading,
title: title,
onTap: context.isPro
? onTap
: () {
Navigator.of(context).pushNamed(NavigationRoutes.proFeaturesScreen.name);
},
);
}
}

View file

@ -0,0 +1,37 @@
import 'package:flutter/material.dart';
import 'package:lightmeter/navigation/routes.dart';
import 'package:lightmeter/res/dimens.dart';
import 'package:lightmeter/utils/context_utils.dart';
class IAPSwitchListTile extends StatelessWidget {
final Icon secondary;
final Text title;
final Text? subtitle;
final bool value;
final ValueChanged<bool>? onChanged;
const IAPSwitchListTile({
required this.secondary,
required this.title,
this.subtitle,
required this.value,
required this.onChanged,
super.key,
});
@override
Widget build(BuildContext context) {
return SwitchListTile(
secondary: secondary,
title: title,
subtitle: subtitle,
value: context.isPro && value,
contentPadding: const EdgeInsets.symmetric(horizontal: Dimens.paddingM),
onChanged: context.isPro
? onChanged
: (_) {
Navigator.of(context).pushNamed(NavigationRoutes.proFeaturesScreen.name);
},
);
}
}