Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Add breakup of add-on-storage

Neeraj Guptab921416f4d2e
diff --git a/lib/generated/intl/messages_en.dart b/lib/generated/intl/messages_en.dart
index 89db75e2e7..754f3d124c 100644
--- a/lib/generated/intl/messages_en.dart
+++ b/lib/generated/intl/messages_en.dart
@@ -187,6 +187,8 @@ class MessageLookup extends MessageLookupByLibrary {
static String m59(count) =>
"${Intl.plural(count, zero: '', one: '1 day', other: '${count} days')}";
+ static String m64(endDate) => "Valid till ${endDate}";
+
static String m60(email) => "Verify ${email}";
static String m61(email) => "We have sent a mail to <green>${email}</green>";
@@ -218,6 +220,9 @@ class MessageLookup extends MessageLookupByLibrary {
"addLocation": MessageLookupByLibrary.simpleMessage("Add location"),
"addLocationButton": MessageLookupByLibrary.simpleMessage("Add"),
"addMore": MessageLookupByLibrary.simpleMessage("Add more"),
+ "addOnPageSubtitle":
+ MessageLookupByLibrary.simpleMessage("Break up of add on storage"),
+ "addOns": MessageLookupByLibrary.simpleMessage("Add ons"),
"addPhotos": MessageLookupByLibrary.simpleMessage("Add photos"),
"addSelected": MessageLookupByLibrary.simpleMessage("Add selected"),
"addToAlbum": MessageLookupByLibrary.simpleMessage("Add to album"),
@@ -1323,6 +1328,7 @@ class MessageLookup extends MessageLookupByLibrary {
"useSelectedPhoto":
MessageLookupByLibrary.simpleMessage("Use selected photo"),
"usedSpace": MessageLookupByLibrary.simpleMessage("Used space"),
+ "validTill": m64,
"verificationFailedPleaseTryAgain":
MessageLookupByLibrary.simpleMessage(
"Verification failed, please try again"),
diff --git a/lib/generated/l10n.dart b/lib/generated/l10n.dart
index 246073fd25..00f64bf1f4 100644
--- a/lib/generated/l10n.dart
+++ b/lib/generated/l10n.dart
@@ -3914,6 +3914,16 @@ class S {
);
}
+ /// `Valid till {endDate}`
+ String validTill(Object endDate) {
+ return Intl.message(
+ 'Valid till $endDate',
+ name: 'validTill',
+ desc: '',
+ args: [endDate],
+ );
+ }
+
/// `Free trial valid till {endDate}.\nYou can choose a paid plan afterwards.`
String playStoreFreeTrialValidTill(Object endDate) {
return Intl.message(
@@ -7744,6 +7754,26 @@ class S {
args: [],
);
}
+
+ /// `Add ons`
+ String get addOns {
+ return Intl.message(
+ 'Add ons',
+ name: 'addOns',
+ desc: '',
+ args: [],
+ );
+ }
+
+ /// `Break up of add on storage`
+ String get addOnPageSubtitle {
+ return Intl.message(
+ 'Break up of add on storage',
+ name: 'addOnPageSubtitle',
+ desc: '',
+ args: [],
+ );
+ }
}
class AppLocalizationDelegate extends LocalizationsDelegate<S> {
diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb
index 534725dad7..67ed6b1f23 100644
--- a/lib/l10n/intl_en.arb
+++ b/lib/l10n/intl_en.arb
@@ -557,6 +557,7 @@
"faqs": "FAQs",
"renewsOn": "Renews on {endDate}",
"freeTrialValidTill": "Free trial valid till {endDate}",
+ "validTill": "Valid till {endDate}",
"playStoreFreeTrialValidTill": "Free trial valid till {endDate}.\nYou can choose a paid plan afterwards.",
"subWillBeCancelledOn": "Your subscription will be cancelled on {endDate}",
"subscription": "Subscription",
@@ -1105,5 +1106,7 @@
"deleteConfirmDialogBody": "This account is linked to other ente apps, if you use any.\\n\\nYour uploaded data, across all ente apps, will be scheduled for deletion, and your account will be permanently deleted.",
"hearUsWhereTitle": "How did you hear about Ente? (optional)",
"hearUsExplanation": "We don't track app installs. It'd help if you told us where you found us!",
- "viewAddOnButton": "View Add-ons"
+ "viewAddOnButton": "View Add-ons",
+ "addOns": "Add ons",
+ "addOnPageSubtitle": "Break up of add on storage"
}
\ No newline at end of file
diff --git a/lib/ui/payment/add_on_page.dart b/lib/ui/payment/add_on_page.dart
index 3dca1bf324..6b97f319ed 100644
--- a/lib/ui/payment/add_on_page.dart
+++ b/lib/ui/payment/add_on_page.dart
@@ -1,37 +1,134 @@
import "package:flutter/material.dart";
+import "package:intl/intl.dart";
import "package:photos/generated/l10n.dart";
import "package:photos/models/api/storage_bonus/bonus.dart";
-import "package:photos/theme/colors.dart";
import "package:photos/theme/ente_theme.dart";
-import "package:photos/ui/components/captioned_text_widget.dart";
-import "package:photos/ui/components/menu_item_widget/menu_item_widget.dart";
+import 'package:photos/ui/components/buttons/icon_button_widget.dart';
+import "package:photos/ui/components/title_bar_title_widget.dart";
+import "package:photos/ui/components/title_bar_widget.dart";
+import "package:photos/utils/data_util.dart";
-class ViewAddOnButton extends StatelessWidget {
- final BonusData? bonusData;
+class AddOnPage extends StatefulWidget {
+ final BonusData bonusData;
- const ViewAddOnButton(this.bonusData, {super.key});
+ const AddOnPage(this.bonusData, {super.key});
+
+ @override
+ State<AddOnPage> createState() => _StorageDetailsScreenState();
+}
+
+class _StorageDetailsScreenState extends State<AddOnPage> {
+ bool canApplyCode = true;
+
+ @override
+ void initState() {
+ super.initState();
+ }
@override
Widget build(BuildContext context) {
- if (bonusData?.getAddOnBonuses().isEmpty ?? true) {
- return const SizedBox.shrink();
- }
- final EnteColorScheme colorScheme = getEnteColorScheme(context);
- return Padding(
- padding: const EdgeInsets.fromLTRB(16, 4, 16, 0),
- child: MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: S.of(context).viewAddOnButton,
+ return Scaffold(
+ body: CustomScrollView(
+ primary: false,
+ slivers: <Widget>[
+ TitleBarWidget(
+ flexibleSpaceTitle: TitleBarTitleWidget(
+ title: S.of(context).addOns,
+ ),
+ flexibleSpaceCaption: S.of(context).addOnPageSubtitle,
+ actionIcons: [
+ IconButtonWidget(
+ icon: Icons.close_outlined,
+ iconButtonType: IconButtonType.secondary,
+ onTap: () {
+ Navigator.of(context)..pop();
+ },
+ ),
+ ],
+ ),
+ SliverPadding(
+ padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 16),
+ sliver: SliverList(
+ delegate: SliverChildBuilderDelegate(
+ (delegateBuildContext, index) {
+ Bonus bonus = widget.bonusData!.getAddOnBonuses()[index];
+ return Padding(
+ padding: const EdgeInsets.symmetric(vertical: 4),
+ child: AddOnViewSection(
+ sectionName: bonus.type == 'ADD_ON_BF_2023'
+ ? "Black friday 2023"
+ : bonus.type.replaceAll('_', ' '),
+ bonus: bonus,
+ ),
+ );
+ },
+ childCount: widget.bonusData?.getAddOnBonuses().length ?? 0,
+ ),
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+}
+
+class AddOnViewSection extends StatelessWidget {
+ final String sectionName;
+ final Bonus bonus;
+
+ const AddOnViewSection({
+ super.key,
+ required this.sectionName,
+ required this.bonus,
+ });
+
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = getEnteColorScheme(context);
+ final textStyle = getEnteTextTheme(context);
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Text(
+ sectionName,
+ style: textStyle.body.copyWith(
+ color: colorScheme.textMuted,
+ ),
+ ),
+ if (bonus.validTill != 0)
+ Text(
+ S.of(context).validTill(
+ DateFormat.yMMMd(
+ Localizations.localeOf(context).languageCode,
+ )
+ .format(
+ DateTime.fromMicrosecondsSinceEpoch(
+ bonus.validTill),
+ )
+ .toString(),
+ ),
+ style: textStyle.body.copyWith(
+ color: colorScheme.textMuted,
+ ),
+ ),
+ ],
),
- menuItemColor: colorScheme.fillFaint,
- trailingWidget: Icon(
- Icons.chevron_right_outlined,
- color: colorScheme.strokeBase,
+ const SizedBox(height: 2),
+ RichText(
+ text: TextSpan(
+ children: [
+ TextSpan(
+ text: convertBytesToReadableFormat(bonus.storage).toString(),
+ style: textStyle.h3,
+ ),
+ ],
+ ),
),
- singleBorderRadius: 4,
- alignCaptionedTextToLeft: true,
- onTap: () async {},
- ),
+ const SizedBox(height: 24),
+ ],
);
}
}
diff --git a/lib/ui/payment/store_subscription_page.dart b/lib/ui/payment/store_subscription_page.dart
index 01343959af..628e06f968 100644
--- a/lib/ui/payment/store_subscription_page.dart
+++ b/lib/ui/payment/store_subscription_page.dart
@@ -21,11 +21,11 @@ import 'package:photos/ui/common/loading_widget.dart';
import 'package:photos/ui/common/progress_dialog.dart';
import "package:photos/ui/components/captioned_text_widget.dart";
import "package:photos/ui/components/menu_item_widget/menu_item_widget.dart";
-import "package:photos/ui/payment/add_on_page.dart";
import 'package:photos/ui/payment/child_subscription_widget.dart';
import 'package:photos/ui/payment/skip_subscription_widget.dart';
import 'package:photos/ui/payment/subscription_common_widgets.dart';
import 'package:photos/ui/payment/subscription_plan_widget.dart';
+import "package:photos/ui/payment/view_add_on_widget.dart";
import 'package:photos/utils/dialog_util.dart';
import 'package:photos/utils/toast_util.dart';
import 'package:url_launcher/url_launcher_string.dart';
diff --git a/lib/ui/payment/stripe_subscription_page.dart b/lib/ui/payment/stripe_subscription_page.dart
index 62911f40ab..b0de23d5eb 100644
--- a/lib/ui/payment/stripe_subscription_page.dart
+++ b/lib/ui/payment/stripe_subscription_page.dart
@@ -20,12 +20,12 @@ import 'package:photos/ui/common/web_page.dart';
import 'package:photos/ui/components/buttons/button_widget.dart';
import "package:photos/ui/components/captioned_text_widget.dart";
import "package:photos/ui/components/menu_item_widget/menu_item_widget.dart";
-import "package:photos/ui/payment/add_on_page.dart";
import 'package:photos/ui/payment/child_subscription_widget.dart';
import 'package:photos/ui/payment/payment_web_page.dart';
import 'package:photos/ui/payment/skip_subscription_widget.dart';
import 'package:photos/ui/payment/subscription_common_widgets.dart';
import 'package:photos/ui/payment/subscription_plan_widget.dart';
+import "package:photos/ui/payment/view_add_on_widget.dart";
import 'package:photos/utils/dialog_util.dart';
import 'package:photos/utils/toast_util.dart';
import 'package:step_progress_indicator/step_progress_indicator.dart';
diff --git a/lib/ui/payment/view_add_on_widget.dart b/lib/ui/payment/view_add_on_widget.dart
new file mode 100644
index 0000000000..5da9e71077
--- /dev/null
+++ b/lib/ui/payment/view_add_on_widget.dart
@@ -0,0 +1,41 @@
+import "package:flutter/material.dart";
+import "package:photos/generated/l10n.dart";
+import "package:photos/models/api/storage_bonus/bonus.dart";
+import "package:photos/theme/colors.dart";
+import "package:photos/theme/ente_theme.dart";
+import "package:photos/ui/components/captioned_text_widget.dart";
+import "package:photos/ui/components/menu_item_widget/menu_item_widget.dart";
+import "package:photos/ui/payment/add_on_page.dart";
+import "package:photos/utils/navigation_util.dart";
+
+class ViewAddOnButton extends StatelessWidget {
+ final BonusData? bonusData;
+
+ const ViewAddOnButton(this.bonusData, {super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ if (bonusData?.getAddOnBonuses().isEmpty ?? true) {
+ return const SizedBox.shrink();
+ }
+ final EnteColorScheme colorScheme = getEnteColorScheme(context);
+ return Padding(
+ padding: const EdgeInsets.fromLTRB(16, 4, 16, 0),
+ child: MenuItemWidget(
+ captionedTextWidget: CaptionedTextWidget(
+ title: S.of(context).viewAddOnButton,
+ ),
+ menuItemColor: colorScheme.fillFaint,
+ trailingWidget: Icon(
+ Icons.chevron_right_outlined,
+ color: colorScheme.strokeBase,
+ ),
+ singleBorderRadius: 4,
+ alignCaptionedTextToLeft: true,
+ onTap: () async {
+ routeToPage(context, AddOnPage(bonusData!));
+ },
+ ),
+ );
+ }
+}