mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-23 16:00:41 +00:00
replaced IAPProducts.isPurchased
with context extension
This commit is contained in:
parent
d2383d2685
commit
3fbe9ce046
7 changed files with 16 additions and 21 deletions
|
@ -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,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -17,7 +17,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,9 +101,8 @@ class CameraContainer extends StatelessWidget {
|
|||
}
|
||||
|
||||
double _meteringContainerHeight(BuildContext context) {
|
||||
final isPro = IAPProducts.isPurchased(context, IAPProductType.paidFeatures);
|
||||
double enabledFeaturesHeight = 0;
|
||||
if (!isPro) {
|
||||
if (!context.isPro) {
|
||||
enabledFeaturesHeight += Dimens.readingContainerSingleValueHeight;
|
||||
enabledFeaturesHeight += Dimens.paddingS;
|
||||
} else {
|
||||
|
|
|
@ -10,7 +10,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 +32,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) ...[
|
||||
const LightmeterProAnimatedDialog(),
|
||||
const _InnerPadding(),
|
||||
],
|
||||
if (isPro && context.meteringFeature(MeteringScreenLayoutFeature.equipmentProfiles)) ...[
|
||||
if (context.isPro && context.meteringFeature(MeteringScreenLayoutFeature.equipmentProfiles)) ...[
|
||||
const EquipmentProfilePicker(),
|
||||
const _InnerPadding(),
|
||||
],
|
||||
|
@ -52,7 +50,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(),
|
||||
],
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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(),
|
||||
|
|
Loading…
Reference in a new issue