From 781271c43c5447fa9e40d6f7921bae46ca97f13b Mon Sep 17 00:00:00 2001 From: ashilkn Date: Wed, 15 Nov 2023 18:15:38 +0530 Subject: [PATCH 1/7] Show new black friday banner only for android --- lib/ui/components/notification_widget.dart | 36 +++++++++++++++--- lib/ui/payment/stripe_subscription_page.dart | 10 +++-- lib/ui/settings_page.dart | 39 ++++++++++++++------ 3 files changed, 65 insertions(+), 20 deletions(-) diff --git a/lib/ui/components/notification_widget.dart b/lib/ui/components/notification_widget.dart index 69207ee3d..cf684f0f4 100644 --- a/lib/ui/components/notification_widget.dart +++ b/lib/ui/components/notification_widget.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import "package:flutter_animate/flutter_animate.dart"; import "package:photos/ente_theme_data.dart"; import 'package:photos/theme/colors.dart'; import "package:photos/theme/ente_theme.dart"; @@ -20,6 +21,7 @@ class NotificationWidget extends StatelessWidget { final String? subText; final GestureTapCallback onTap; final NotificationType type; + final bool isBlackFriday; const NotificationWidget({ Key? key, @@ -27,6 +29,7 @@ class NotificationWidget extends StatelessWidget { required this.actionIcon, required this.text, required this.onTap, + this.isBlackFriday = false, this.subText, this.type = NotificationType.warning, }) : super(key: key); @@ -90,11 +93,34 @@ class NotificationWidget extends StatelessWidget { child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Icon( - startIcon, - size: 36, - color: strokeColorScheme.strokeBase, - ), + isBlackFriday + ? Icon( + startIcon, + size: 36, + color: strokeColorScheme.strokeBase, + ) + .animate( + onPlay: (controller) => + controller.repeat(reverse: true), + delay: 2000.ms, + ) + .shake( + duration: 500.ms, + hz: 6, + delay: 1600.ms, + ) + .scale( + duration: 500.ms, + begin: const Offset(0.9, 0.9), + end: const Offset(1.1, 1.1), + delay: 1600.ms, + // curve: Curves.easeInOut, + ) + : Icon( + startIcon, + size: 36, + color: strokeColorScheme.strokeBase, + ), const SizedBox(width: 12), Expanded( child: Column( diff --git a/lib/ui/payment/stripe_subscription_page.dart b/lib/ui/payment/stripe_subscription_page.dart index 506e597da..54a551b7d 100644 --- a/lib/ui/payment/stripe_subscription_page.dart +++ b/lib/ui/payment/stripe_subscription_page.dart @@ -211,10 +211,12 @@ class _StripeSubscriptionPageState extends State { widgets.add(_showSubscriptionToggle()); if (_hasActiveSubscription) { - widgets.add(ValidityWidget( - currentSubscription: _currentSubscription, - bonusData: _userDetails.bonusData, - )); + widgets.add( + ValidityWidget( + currentSubscription: _currentSubscription, + bonusData: _userDetails.bonusData, + ), + ); } if (_currentSubscription!.productID == freeProductID) { diff --git a/lib/ui/settings_page.dart b/lib/ui/settings_page.dart index ce631822a..bf8f52259 100644 --- a/lib/ui/settings_page.dart +++ b/lib/ui/settings_page.dart @@ -28,6 +28,7 @@ import 'package:photos/ui/settings/support_section_widget.dart'; import 'package:photos/ui/settings/theme_switch_widget.dart'; import "package:photos/ui/sharing/verify_identity_dialog.dart"; import "package:photos/utils/navigation_util.dart"; +import "package:url_launcher/url_launcher_string.dart"; class SettingsPage extends StatelessWidget { final ValueNotifier emailNotifier; @@ -90,17 +91,33 @@ class SettingsPage extends StatelessWidget { ? RepaintBoundary( child: Padding( padding: const EdgeInsets.symmetric(vertical: 8.0), - child: NotificationWidget( - startIcon: Icons.auto_awesome, - actionIcon: Icons.arrow_forward_outlined, - text: S.of(context).doubleYourStorage, - subText: S.of(context).referFriendsAnd2xYourPlan, - type: NotificationType.goldenBanner, - onTap: () async { - StorageBonusService.instance.markStorageBonusAsDone(); - routeToPage(context, const ReferralScreen()); - }, - ), + child: !Platform.isIOS + ? NotificationWidget( + isBlackFriday: true, + startIcon: Icons.celebration, + actionIcon: Icons.arrow_forward_outlined, + text: "Black Friday Sale", + subText: "Upto 50% off!", + type: NotificationType.goldenBanner, + onTap: () async { + launchUrlString( + "https://ente.io/blackfriday/", + mode: LaunchMode.platformDefault, + ); + }, + ) + : NotificationWidget( + startIcon: Icons.auto_awesome, + actionIcon: Icons.arrow_forward_outlined, + text: S.of(context).doubleYourStorage, + subText: S.of(context).referFriendsAnd2xYourPlan, + type: NotificationType.goldenBanner, + onTap: () async { + StorageBonusService.instance + .markStorageBonusAsDone(); + routeToPage(context, const ReferralScreen()); + }, + ), ).animate(onPlay: (controller) => controller.repeat()).shimmer( duration: 1000.ms, delay: 3200.ms, From 46175ae9696104427eab98f8fd3f20aff7118359 Mon Sep 17 00:00:00 2001 From: ashilkn Date: Wed, 15 Nov 2023 18:19:33 +0530 Subject: [PATCH 2/7] minor change --- lib/ui/settings_page.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ui/settings_page.dart b/lib/ui/settings_page.dart index bf8f52259..5f955945e 100644 --- a/lib/ui/settings_page.dart +++ b/lib/ui/settings_page.dart @@ -91,7 +91,7 @@ class SettingsPage extends StatelessWidget { ? RepaintBoundary( child: Padding( padding: const EdgeInsets.symmetric(vertical: 8.0), - child: !Platform.isIOS + child: Platform.isAndroid ? NotificationWidget( isBlackFriday: true, startIcon: Icons.celebration, From e13061069a96d6a99ed8b72a8cc4173b7391930b Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Wed, 15 Nov 2023 18:39:13 +0530 Subject: [PATCH 3/7] Hide BF banner after 5th Dec --- lib/ui/settings_page.dart | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/lib/ui/settings_page.dart b/lib/ui/settings_page.dart index 5f955945e..7b909bb6c 100644 --- a/lib/ui/settings_page.dart +++ b/lib/ui/settings_page.dart @@ -9,6 +9,7 @@ import 'package:photos/events/opened_settings_event.dart'; import "package:photos/generated/l10n.dart"; import 'package:photos/services/feature_flag_service.dart'; import "package:photos/services/storage_bonus_service.dart"; +import "package:photos/services/user_service.dart"; import 'package:photos/theme/colors.dart'; import 'package:photos/theme/ente_theme.dart'; import "package:photos/ui/components/notification_widget.dart"; @@ -85,13 +86,16 @@ class SettingsPage extends StatelessWidget { const sectionSpacing = SizedBox(height: 8); contents.add(const SizedBox(height: 8)); if (hasLoggedIn) { + final shouldShowBFBanner = shouldShowBfBanner(); + final showStorageBonusBanner = + StorageBonusService.instance.shouldShowStorageBonus(); contents.addAll([ const StorageCardWidget(), - StorageBonusService.instance.shouldShowStorageBonus() + (shouldShowBFBanner || showStorageBonusBanner) ? RepaintBoundary( child: Padding( padding: const EdgeInsets.symmetric(vertical: 8.0), - child: Platform.isAndroid + child: shouldShowBFBanner ? NotificationWidget( isBlackFriday: true, startIcon: Icons.celebration, @@ -101,7 +105,7 @@ class SettingsPage extends StatelessWidget { type: NotificationType.goldenBanner, onTap: () async { launchUrlString( - "https://ente.io/blackfriday/", + "https://ente.io/blackfriday", mode: LaunchMode.platformDefault, ); }, @@ -183,6 +187,23 @@ class SettingsPage extends StatelessWidget { ); } + bool shouldShowBfBanner() { + if (!Platform.isAndroid) { + return false; + } + // if date is after 5th of December 2023, hide banner + if (DateTime.now().isAfter(DateTime(2023, 12, 5))) { + return false; + } + // if coupon is already applied, can hide the banner + return (UserService.instance + .getCachedUserDetails() + ?.bonusData + ?.getAddOnBonuses() + .isEmpty ?? + true); + } + Future _showVerifyIdentityDialog(BuildContext context) async { await showDialog( context: context, From 09ac36ee571bf56d58535d5a0fa853e0f6b2e211 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Wed, 15 Nov 2023 18:54:29 +0530 Subject: [PATCH 4/7] Show banner in debugMode --- lib/ui/settings_page.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ui/settings_page.dart b/lib/ui/settings_page.dart index 7b909bb6c..41cd49032 100644 --- a/lib/ui/settings_page.dart +++ b/lib/ui/settings_page.dart @@ -188,10 +188,10 @@ class SettingsPage extends StatelessWidget { } bool shouldShowBfBanner() { - if (!Platform.isAndroid) { + if (!Platform.isAndroid && !kDebugMode) { return false; } - // if date is after 5th of December 2023, hide banner + // if date is after 5th of December 2023, 00:00:00, hide banner if (DateTime.now().isAfter(DateTime(2023, 12, 5))) { return false; } From 172fc66f76e34de78cf491e30b3612e68c3d27c6 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Wed, 15 Nov 2023 18:58:53 +0530 Subject: [PATCH 5/7] Extract strings --- lib/generated/intl/messages_en.dart | 4 ++++ lib/generated/l10n.dart | 20 ++++++++++++++++++++ lib/l10n/intl_en.arb | 4 +++- lib/ui/settings_page.dart | 4 ++-- 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/lib/generated/intl/messages_en.dart b/lib/generated/intl/messages_en.dart index 4285ff57a..a734a1589 100644 --- a/lib/generated/intl/messages_en.dart +++ b/lib/generated/intl/messages_en.dart @@ -347,6 +347,8 @@ class MessageLookup extends MessageLookupByLibrary { "backupSettings": MessageLookupByLibrary.simpleMessage("Backup settings"), "backupVideos": MessageLookupByLibrary.simpleMessage("Backup videos"), + "blackFridaySale": + MessageLookupByLibrary.simpleMessage("Black Friday Sale"), "blog": MessageLookupByLibrary.simpleMessage("Blog"), "cachedData": MessageLookupByLibrary.simpleMessage("Cached data"), "calculating": MessageLookupByLibrary.simpleMessage("Calculating..."), @@ -1318,6 +1320,8 @@ class MessageLookup extends MessageLookupByLibrary { "upgrade": MessageLookupByLibrary.simpleMessage("Upgrade"), "uploadingFilesToAlbum": MessageLookupByLibrary.simpleMessage("Uploading files to album..."), + "upto50OffUntil4thDec": MessageLookupByLibrary.simpleMessage( + "Upto 50% off, until 4th Dec."), "usableReferralStorageInfo": MessageLookupByLibrary.simpleMessage( "Usable storage is limited by your current plan. Excess claimed storage will automatically become usable when you upgrade your plan."), "usePublicLinksForPeopleNotOnEnte": diff --git a/lib/generated/l10n.dart b/lib/generated/l10n.dart index 379eaa301..8ef582215 100644 --- a/lib/generated/l10n.dart +++ b/lib/generated/l10n.dart @@ -7774,6 +7774,26 @@ class S { args: [], ); } + + /// `Black Friday Sale` + String get blackFridaySale { + return Intl.message( + 'Black Friday Sale', + name: 'blackFridaySale', + desc: '', + args: [], + ); + } + + /// `Upto 50% off, until 4th Dec.` + String get upto50OffUntil4thDec { + return Intl.message( + 'Upto 50% off, until 4th Dec.', + name: 'upto50OffUntil4thDec', + desc: '', + args: [], + ); + } } class AppLocalizationDelegate extends LocalizationsDelegate { diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index c90d79c44..b623cef00 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -1108,5 +1108,7 @@ "hearUsExplanation": "We don't track app installs. It'd help if you told us where you found us!", "viewAddOnButton": "View add-ons", "addOns": "Add-ons", - "addOnPageSubtitle": "Details of add-ons" + "addOnPageSubtitle": "Details of add-ons", + "blackFridaySale": "Black Friday Sale", + "upto50OffUntil4thDec": "Upto 50% off, until 4th Dec." } diff --git a/lib/ui/settings_page.dart b/lib/ui/settings_page.dart index 41cd49032..2f314906d 100644 --- a/lib/ui/settings_page.dart +++ b/lib/ui/settings_page.dart @@ -100,8 +100,8 @@ class SettingsPage extends StatelessWidget { isBlackFriday: true, startIcon: Icons.celebration, actionIcon: Icons.arrow_forward_outlined, - text: "Black Friday Sale", - subText: "Upto 50% off!", + text: S.of(context).blackFridaySale, + subText: S.of(context).upto50OffUntil4thDec, type: NotificationType.goldenBanner, onTap: () async { launchUrlString( From bf08e938ff7d173868ca951d5bf2be6473a198ae Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Wed, 15 Nov 2023 20:14:48 +0530 Subject: [PATCH 6/7] Allow folks with add_on to activate family --- lib/models/user_details.dart | 4 ++++ lib/services/billing_service.dart | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/models/user_details.dart b/lib/models/user_details.dart index ef1fdbbd7..f107a2e6b 100644 --- a/lib/models/user_details.dart +++ b/lib/models/user_details.dart @@ -33,6 +33,10 @@ class UserDetails { return familyData?.members?.isNotEmpty ?? false; } + bool hasPaidAddon() { + return bonusData?.getAddOnBonuses().isNotEmpty ?? false; + } + bool isFamilyAdmin() { assert(isPartOfFamily(), "verify user is part of family before calling"); final FamilyMember currentUserMember = familyData!.members! diff --git a/lib/services/billing_service.dart b/lib/services/billing_service.dart index 24ec308fb..6891089e3 100644 --- a/lib/services/billing_service.dart +++ b/lib/services/billing_service.dart @@ -166,7 +166,8 @@ class BillingService { BuildContext context, UserDetails userDetails, ) async { - if (userDetails.subscription.productID == freeProductID) { + if (userDetails.subscription.productID == freeProductID && + !userDetails.hasPaidAddon()) { await showErrorDialog( context, S.of(context).familyPlans, From 68f4b287dc74abaa493b631d044f9e075220bead Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Thu, 16 Nov 2023 12:05:17 +0530 Subject: [PATCH 7/7] Bump version: 0.7.116+516 --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 7aac822c9..902beaa86 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,7 +12,7 @@ description: ente photos application # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 0.7.108+508 +version: 0.7.116+516 environment: sdk: ">=3.0.0 <4.0.0"