From 99eebff9a43d8dc9adbc70f1e4c001a8d4e8777d Mon Sep 17 00:00:00 2001 From: Vadim Date: Fri, 21 Jul 2023 11:59:08 +0200 Subject: [PATCH] Improved `EquipmentProfilesListTile` statuses visualization --- .../widget_list_tile_equipment_profiles.dart | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/lib/screens/settings/components/metering/components/equipment_profiles/widget_list_tile_equipment_profiles.dart b/lib/screens/settings/components/metering/components/equipment_profiles/widget_list_tile_equipment_profiles.dart index 29ffae9..c07f64a 100644 --- a/lib/screens/settings/components/metering/components/equipment_profiles/widget_list_tile_equipment_profiles.dart +++ b/lib/screens/settings/components/metering/components/equipment_profiles/widget_list_tile_equipment_profiles.dart @@ -1,8 +1,8 @@ +import 'dart:developer'; + import 'package:flutter/material.dart'; -import 'package:lightmeter/environment.dart'; import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/screen_equipment_profile.dart'; -import 'package:lightmeter/utils/inherited_generics.dart'; import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart'; import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; @@ -11,18 +11,25 @@ class EquipmentProfilesListTile extends StatelessWidget { @override Widget build(BuildContext context) { + final paidStatus = IAPProducts.productOf(context, IAPProductType.paidFeatures)?.status; + log(paidStatus.toString()); return ListTile( leading: const Icon(Icons.camera), title: Text(S.of(context).equipmentProfiles), - onTap: () { - if (context.get().buildType == BuildType.dev || - IAPProducts.isPurchased(context, IAPProductType.paidFeatures)) { - Navigator.of(context).push( - MaterialPageRoute(builder: (_) => const EquipmentProfilesScreen()), - ); - } else { - IAPProductsProvider.of(context).buy(IAPProductType.paidFeatures); - } + onTap: switch (paidStatus) { + IAPProductStatus.purchased => () { + Navigator.of(context).push( + MaterialPageRoute(builder: (_) => const EquipmentProfilesScreen()), + ); + }, + IAPProductStatus.purchasable => () { + IAPProductsProvider.of(context).buy(IAPProductType.paidFeatures); + }, + _ => null, + }, + trailing: switch (paidStatus) { + IAPProductStatus.purchasable => const Icon(Icons.lock), + _ => null, }, ); }