From 490aebccd096eb6c4867274496dd4bc3643cdafe Mon Sep 17 00:00:00 2001 From: Vadim <44135514+vodemn@users.noreply.github.com> Date: Mon, 4 Aug 2025 00:34:20 +0200 Subject: [PATCH] added yearly subscription --- lib/l10n/intl_de.arb | 2 + lib/l10n/intl_en.arb | 2 + lib/l10n/intl_fr.arb | 2 + lib/l10n/intl_ru.arb | 2 + lib/l10n/intl_zh.arb | 2 + .../widget_offering_lightmeter_pro.dart | 44 +++++++++++++------ 6 files changed, 40 insertions(+), 14 deletions(-) diff --git a/lib/l10n/intl_de.arb b/lib/l10n/intl_de.arb index e02ad8f..49e4a59 100644 --- a/lib/l10n/intl_de.arb +++ b/lib/l10n/intl_de.arb @@ -179,8 +179,10 @@ "noPhotos": "Keine Fotos", "continuePurchase": "Weiter", "monthly": "Monatlich", + "yearly": "Jährlich", "lifetime": "Für immer", "pricePerMonth": "{price}/Monat", + "pricePerYear": "{price}/Jahr", "@pricePerMonth": { "placeholders": { "price": { diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index 18be365..3c6542e 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -179,8 +179,10 @@ "noPhotos": "No photos", "continuePurchase": "Continue", "monthly": "Monthly", + "yearly": "Yearly", "lifetime": "Lifetime", "pricePerMonth": "{price}/month", + "pricePerYear": "{price}/year", "@pricePerMonth": { "placeholders": { "price": { diff --git a/lib/l10n/intl_fr.arb b/lib/l10n/intl_fr.arb index 9c5214a..a64a52b 100644 --- a/lib/l10n/intl_fr.arb +++ b/lib/l10n/intl_fr.arb @@ -170,8 +170,10 @@ "noPhotos": "Aucune photo", "continuePurchase": "Continuer", "monthly": "Mensuel", + "yearly": "Annuel", "lifetime": "Pour toujours", "pricePerMonth": "{price}/mois", + "pricePerYear": "{price}/an", "@pricePerMonth": { "placeholders": { "price": { diff --git a/lib/l10n/intl_ru.arb b/lib/l10n/intl_ru.arb index 986c6d2..5d12fda 100644 --- a/lib/l10n/intl_ru.arb +++ b/lib/l10n/intl_ru.arb @@ -169,8 +169,10 @@ "noPhotos": "Нет фотографий", "continuePurchase": "Продолжить", "monthly": "Ежемесячно", + "yearly": "Ежегодно", "lifetime": "Навсегда", "pricePerMonth": "{price}/месяц", + "pricePerYear": "{price}/год", "@pricePerMonth": { "placeholders": { "price": { diff --git a/lib/l10n/intl_zh.arb b/lib/l10n/intl_zh.arb index d4612f3..5484593 100644 --- a/lib/l10n/intl_zh.arb +++ b/lib/l10n/intl_zh.arb @@ -167,8 +167,10 @@ "noPhotos": "没有照片", "continuePurchase": "继续", "monthly": "月付", + "yearly": "年付", "lifetime": "永久", "pricePerMonth": "{price}/月", + "pricePerYear": "{price}/年", "@pricePerMonth": { "placeholders": { "price": { diff --git a/lib/screens/lightmeter_pro/components/offering/widget_offering_lightmeter_pro.dart b/lib/screens/lightmeter_pro/components/offering/widget_offering_lightmeter_pro.dart index f1424fc..53e2796 100644 --- a/lib/screens/lightmeter_pro/components/offering/widget_offering_lightmeter_pro.dart +++ b/lib/screens/lightmeter_pro/components/offering/widget_offering_lightmeter_pro.dart @@ -17,6 +17,7 @@ class _LightmeterProOfferingState extends State { late final Future> productsFuture; bool _isLoading = true; IAPProduct? monthly; + IAPProduct? yearly; IAPProduct? lifetime; IAPProduct? selected; @@ -24,8 +25,9 @@ class _LightmeterProOfferingState extends State { void initState() { super.initState(); productsFuture = IAPProductsProvider.of(context).fetchProducts(); - productsFuture.then((products) { + productsFuture.then((products) async { monthly = products.firstWhereOrNull((p) => p.type == PurchaseType.monthly); + yearly = products.firstWhereOrNull((p) => p.type == PurchaseType.yearly); lifetime = products.firstWhereOrNull((p) => p.type == PurchaseType.lifetime); selected = monthly ?? lifetime; }).onError((_, __) { @@ -68,9 +70,13 @@ class _LightmeterProOfferingState extends State { AnimatedSwitcher( duration: Dimens.durationM, child: _isLoading - ? const CircularProgressIndicator() + ? const SizedBox( + height: 120, + child: Center(child: CircularProgressIndicator()), + ) : _Products( monthly: monthly, + yearly: yearly, lifetime: lifetime, selected: selected, onProductSelected: (value) { @@ -98,12 +104,14 @@ class _LightmeterProOfferingState extends State { class _Products extends StatelessWidget { const _Products({ this.monthly, + this.yearly, this.lifetime, required this.selected, required this.onProductSelected, }); final IAPProduct? monthly; + final IAPProduct? yearly; final IAPProduct? lifetime; final IAPProduct? selected; final ValueChanged onProductSelected; @@ -114,13 +122,25 @@ class _Products extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ if (monthly case final monthly?) - _ProductItem( - title: S.of(context).monthly, - price: S.of(context).pricePerMonth(monthly.price), - isSelected: selected == monthly, - onPressed: () => onProductSelected(monthly), + Padding( + padding: const EdgeInsets.only(bottom: Dimens.paddingS), + child: _ProductItem( + title: S.of(context).monthly, + price: S.of(context).pricePerMonth(monthly.price), + isSelected: selected == monthly, + onPressed: () => onProductSelected(monthly), + ), + ), + if (yearly case final yearly?) + Padding( + padding: const EdgeInsets.only(bottom: Dimens.paddingS), + child: _ProductItem( + title: S.of(context).yearly, + price: S.of(context).pricePerYear(yearly.price), + isSelected: selected == yearly, + onPressed: () => onProductSelected(yearly), + ), ), - const SizedBox(height: Dimens.grid8), if (lifetime case final lifetime?) _ProductItem( title: S.of(context).lifetime, @@ -149,9 +169,8 @@ class _ProductItem extends StatelessWidget { @override Widget build(BuildContext context) { return Material( - color: isSelected - ? Theme.of(context).colorScheme.primaryContainer - : Theme.of(context).colorScheme.surfaceElevated2, + color: + isSelected ? Theme.of(context).colorScheme.primaryContainer : Theme.of(context).colorScheme.surfaceElevated2, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(Dimens.borderRadiusM), side: isSelected @@ -216,6 +235,3 @@ class _ProductAnimatedText extends StatelessWidget { ); } } - -/// rgba(212,227,252,255) #d4e3fc -/// \ No newline at end of file