Explorar o código

Show banner for referral

Neeraj Gupta %!s(int64=2) %!d(string=hai) anos
pai
achega
df009ff9cc
Modificáronse 2 ficheiros con 31 adicións e 0 borrados
  1. 10 0
      lib/services/storage_bonus_service.dart
  2. 21 0
      lib/ui/settings_page.dart

+ 10 - 0
lib/services/storage_bonus_service.dart

@@ -6,6 +6,8 @@ class StorageBonusService {
   late StorageBonusGateway gateway;
   late SharedPreferences prefs;
 
+  final String _showStorageBonus = "showStorageBonus.showBanner";
+
   void init(SharedPreferences preferences) {
     prefs = preferences;
     gateway = StorageBonusGateway(NetworkClient.instance.enteDio);
@@ -16,6 +18,14 @@ class StorageBonusService {
   static StorageBonusService instance =
       StorageBonusService._privateConstructor();
 
+  bool shouldShowStorageBonus() {
+    return prefs.getBool(_showStorageBonus) ?? true;
+  }
+
+  void markStorageBonusAsDone() {
+    prefs.setBool(_showStorageBonus, false).ignore();
+  }
+
   // getter for gateway
   StorageBonusGateway getGateway() {
     return gateway;

+ 21 - 0
lib/ui/settings_page.dart

@@ -6,8 +6,11 @@ import 'package:photos/core/configuration.dart';
 import 'package:photos/core/event_bus.dart';
 import 'package:photos/events/opened_settings_event.dart';
 import 'package:photos/services/feature_flag_service.dart';
+import "package:photos/services/storage_bonus_service.dart";
 import 'package:photos/theme/colors.dart';
 import 'package:photos/theme/ente_theme.dart';
+import "package:photos/ui/components/notification_warning_widget.dart";
+import "package:photos/ui/growth/referral_screen.dart";
 import 'package:photos/ui/settings/about_section_widget.dart';
 import 'package:photos/ui/settings/account_section_widget.dart';
 import 'package:photos/ui/settings/app_version_widget.dart';
@@ -21,9 +24,11 @@ import 'package:photos/ui/settings/social_section_widget.dart';
 import 'package:photos/ui/settings/storage_card_widget.dart';
 import 'package:photos/ui/settings/support_section_widget.dart';
 import 'package:photos/ui/settings/theme_switch_widget.dart';
+import "package:photos/utils/navigation_util.dart";
 
 class SettingsPage extends StatelessWidget {
   final ValueNotifier<String?> emailNotifier;
+
   const SettingsPage({Key? key, required this.emailNotifier}) : super(key: key);
 
   @override
@@ -71,6 +76,22 @@ class SettingsPage extends StatelessWidget {
     if (hasLoggedIn) {
       contents.addAll([
         const StorageCardWidget(),
+        StorageBonusService.instance.shouldShowStorageBonus()
+            ? Padding(
+                padding: const EdgeInsets.only(top: 4.0),
+                child: NotificationWidget(
+                  startIcon: Icons.auto_awesome,
+                  actionIcon: Icons.arrow_forward_outlined,
+                  text: "Double your storage",
+                  subText: "Refer friends and 2x your plan",
+                  type: NotificationType.banner,
+                  onTap: () async {
+                    StorageBonusService.instance.markStorageBonusAsDone();
+                    routeToPage(context, const ReferralScreen());
+                  },
+                ),
+              )
+            : const SizedBox.shrink(),
         const SizedBox(height: 12),
         const BackupSectionWidget(),
         sectionSpacing,