Browse Source

Hide BF banner after 5th Dec

Neeraj Gupta 1 year ago
parent
commit
e13061069a
1 changed files with 24 additions and 3 deletions
  1. 24 3
      lib/ui/settings_page.dart

+ 24 - 3
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<void> _showVerifyIdentityDialog(BuildContext context) async {
     await showDialog(
       context: context,