Minor fixes for BF banner (#1499)

This commit is contained in:
Neeraj Gupta 2023-11-15 19:11:07 +05:30 committed by GitHub
commit 292dc0f4e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 53 additions and 6 deletions

View file

@ -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":

View file

@ -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<S> {

View file

@ -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."
}

View file

@ -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,23 +86,26 @@ 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,
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(
"https://ente.io/blackfriday/",
"https://ente.io/blackfriday",
mode: LaunchMode.platformDefault,
);
},
@ -183,6 +187,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,