|
@@ -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";
|
|
@@ -28,6 +29,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<String?> emailNotifier;
|
|
@@ -84,23 +86,42 @@ 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: 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: shouldShowBFBanner
|
|
|
+ ? NotificationWidget(
|
|
|
+ isBlackFriday: true,
|
|
|
+ startIcon: Icons.celebration,
|
|
|
+ actionIcon: Icons.arrow_forward_outlined,
|
|
|
+ text: S.of(context).blackFridaySale,
|
|
|
+ subText: S.of(context).upto50OffUntil4thDec,
|
|
|
+ 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,
|
|
@@ -167,6 +188,23 @@ class SettingsPage extends StatelessWidget {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+ bool shouldShowBfBanner() {
|
|
|
+ if (!Platform.isAndroid && !kDebugMode) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ // if date is after 5th of December 2023, 00:00:00, 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,
|