π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Refresh referral screens
Aman87913ac08a72
diff --git a/mobile/apps/photos/changes/referral-components-ui.md b/mobile/apps/photos/changes/referral-components-ui.mdnew file mode 100644index 0000000000..6996bdf04a--- /dev/null+++ b/mobile/apps/photos/changes/referral-components-ui.md@@ -0,0 +1 @@+- Refreshes the referral screens.diff --git a/mobile/apps/photos/lib/ui/growth/apply_code_screen.dart b/mobile/apps/photos/lib/ui/growth/apply_code_screen.dartindex 222978615b..c66b29b37f 100644--- a/mobile/apps/photos/lib/ui/growth/apply_code_screen.dart+++ b/mobile/apps/photos/lib/ui/growth/apply_code_screen.dart@@ -1,3 +1,4 @@+import "package:ente_components/ente_components.dart";import "package:ente_pure_utils/ente_pure_utils.dart";import "package:flutter/material.dart";import "package:logging/logging.dart";@@ -5,13 +6,8 @@ import "package:photos/gateways/storage_bonus/models/storage_bonus.dart";import "package:photos/generated/l10n.dart";import "package:photos/models/user_details.dart";import "package:photos/service_locator.dart";-import "package:photos/theme/ente_theme.dart";-import 'package:photos/ui/components/buttons/button_widget.dart';-import 'package:photos/ui/components/buttons/icon_button_widget.dart';-import "package:photos/ui/components/models/button_type.dart";-import "package:photos/ui/components/title_bar_title_widget.dart";-import "package:photos/ui/components/title_bar_widget.dart";import "package:photos/ui/growth/code_success_screen.dart";+import "package:photos/ui/settings/components/settings_page_scaffold.dart";import "package:photos/utils/dialog_util.dart";class ApplyCodeScreen extends StatefulWidget {@@ -29,6 +25,7 @@ class _ApplyCodeScreenState extends State<ApplyCodeScreen> {late FocusNode textFieldFocusNode;String code = "";+ bool _isApplying = false;@overridevoid initState() {@@ -46,143 +43,65 @@ class _ApplyCodeScreenState extends State<ApplyCodeScreen> {@overrideWidget build(BuildContext context) {- final colorScheme = getEnteColorScheme(context);- final textStyle = getEnteTextTheme(context);- textFieldFocusNode.requestFocus();- return Scaffold(- body: CustomScrollView(- primary: false,- slivers: <Widget>[- TitleBarWidget(- flexibleSpaceTitle: TitleBarTitleWidget(- title: AppLocalizations.of(context).applyCodeTitle,- ),- actionIcons: [- IconButtonWidget(- icon: Icons.close_outlined,- iconButtonType: IconButtonType.secondary,- onTap: () {- // Go three screen back, similar to pop thrice- Navigator.of(context)- ..pop()- ..pop()- ..pop();- },- ),- ],- ),- SliverList(- delegate: SliverChildBuilderDelegate((delegateBuildContext, index) {- return Padding(- padding: const EdgeInsets.symmetric(horizontal: 16),- child: Padding(- padding: const EdgeInsets.symmetric(vertical: 20),- child: Column(- mainAxisSize: MainAxisSize.min,- children: [- Column(- children: [- Text(- AppLocalizations.of(context).enterCodeDescription,- style: textStyle.small.copyWith(- color: colorScheme.textMuted,- ),- ),- const SizedBox(height: 24),- _getInputField(),- // Container with 8 border radius and red color- ],- ),- ],- ),- ),- );- }, childCount: 1),- ),- SliverFillRemaining(- child: SafeArea(- child: Padding(- padding: const EdgeInsets.all(12.0),- child: Column(- mainAxisAlignment: MainAxisAlignment.end,- children: [- ButtonWidget(- buttonType: ButtonType.neutral,- buttonSize: ButtonSize.large,- labelText: AppLocalizations.of(context).apply,- isDisabled: code.trim().length < 4,- onTap: () async {- try {- await storageBonusService.applyCode(code);- if (!context.mounted) return;- // ignore: unawaited_futures- Navigator.of(context).pushReplacement(- MaterialPageRoute(- builder: (context) => CodeSuccessScreen(- widget.referralView,- widget.userDetails,- ),- ),- );- } catch (e) {- Logger(- '$runtimeType',- ).severe("failed to apply referral", e);- if (!context.mounted) return;- // ignore: unawaited_futures- showErrorDialogForException(- context: context,- exception: e as Exception,- apiErrorPrefix: AppLocalizations.of(- context,- ).failedToApplyCode,- );- }- },- ),- ],- ),- ),- ),- ),- ],- ),- );- }-- Widget _getInputField() {- return TextFormField(- controller: _textController,- focusNode: textFieldFocusNode,- style: getEnteTextTheme(context).body,- inputFormatters: [UpperCaseTextFormatter()],- textCapitalization: TextCapitalization.sentences,- decoration: InputDecoration(- focusedBorder: OutlineInputBorder(- borderRadius: const BorderRadius.all(Radius.circular(4.0)),- borderSide: BorderSide(- color: getEnteColorScheme(context).strokeMuted,+ final l10n = AppLocalizations.of(context);+ return SettingsPageScaffold(+ title: l10n.applyCodeTitle,+ children: [+ Text(+ l10n.enterCodeDescription,+ style: TextStyles.body.copyWith(+ color: context.componentColors.textLight,),),- fillColor: getEnteColorScheme(context).fillFaint,- filled: true,- hintText: AppLocalizations.of(context).enterReferralCode,- contentPadding: const EdgeInsets.symmetric(- horizontal: 16,- vertical: 14,+ const SizedBox(height: Spacing.xxl),+ TextInputComponent(+ controller: _textController,+ focusNode: textFieldFocusNode,+ autofocus: true,+ inputFormatters: [UpperCaseTextFormatter()],+ textCapitalization: TextCapitalization.characters,+ hintText: l10n.enterReferralCode,+ autocorrect: false,+ keyboardType: TextInputType.text,+ textInputAction: TextInputAction.done,+ onChanged: (value) {+ setState(() => code = value.trim());+ },+ onSubmit: (_) => _applyCode(),),- border: UnderlineInputBorder(- borderSide: BorderSide.none,- borderRadius: BorderRadius.circular(8),+ const SizedBox(height: Spacing.xl),+ ButtonComponent(+ label: l10n.apply,+ isDisabled: _isApplying || code.trim().length < 4,+ shouldShowSuccessState: false,+ onTap: _applyCode,),- ),- onChanged: (value) {- code = value.trim();- setState(() {});- },- autocorrect: false,- keyboardType: TextInputType.emailAddress,- textInputAction: TextInputAction.next,+ ],);}++ Future<void> _applyCode() async {+ if (_isApplying || code.trim().length < 4) return;+ setState(() => _isApplying = true);+ try {+ await storageBonusService.applyCode(code);+ if (!mounted) return;+ await Navigator.of(context).pushReplacement(+ MaterialPageRoute(+ builder: (context) =>+ CodeSuccessScreen(widget.referralView, widget.userDetails),+ ),+ );+ } catch (e) {+ Logger('$runtimeType').severe("failed to apply referral", e);+ if (!mounted) return;+ await showErrorDialogForException(+ context: context,+ exception: e as Exception,+ apiErrorPrefix: AppLocalizations.of(context).failedToApplyCode,+ );+ } finally {+ if (mounted) setState(() => _isApplying = false);+ }+ }}diff --git a/mobile/apps/photos/lib/ui/growth/change_referral_code_sheet.dart b/mobile/apps/photos/lib/ui/growth/change_referral_code_sheet.dartindex 812f50d52a..d4b2027597 100644--- a/mobile/apps/photos/lib/ui/growth/change_referral_code_sheet.dart+++ b/mobile/apps/photos/lib/ui/growth/change_referral_code_sheet.dart@@ -1,10 +1,9 @@import "package:dio/dio.dart";+import "package:ente_components/ente_components.dart";import "package:flutter/material.dart";import "package:logging/logging.dart";import "package:photos/generated/l10n.dart";import "package:photos/service_locator.dart";-import "package:photos/theme/ente_theme.dart";-import "package:photos/ui/components/base_bottom_sheet.dart";import "package:photos/utils/dialog_util.dart";Future<bool?> showChangeReferralCodeSheet(@@ -12,13 +11,15 @@ Future<bool?> showChangeReferralCodeSheet(required String currentCode,required VoidCallback onCodeChanged,}) {- return showBaseBottomSheet<bool>(- context,- title: AppLocalizations.of(context).changeYourReferralCode,- headerSpacing: 20,- child: _ChangeReferralCodeContent(- currentCode: currentCode,- onCodeChanged: onCodeChanged,+ return showBottomSheetComponent<bool>(+ context: context,+ builder: (_) => BottomSheetComponent(+ title: AppLocalizations.of(context).changeYourReferralCode,+ isKeyboardAware: true,+ content: _ChangeReferralCodeContent(+ currentCode: currentCode,+ onCodeChanged: onCodeChanged,+ ),),);}@@ -118,84 +119,28 @@ class _ChangeReferralCodeContentState@overrideWidget build(BuildContext context) {- final colorScheme = getEnteColorScheme(context);- final textTheme = getEnteTextTheme(context);- final isDarkMode = Theme.of(context).brightness == Brightness.dark;-- final inputBackgroundColor = isDarkMode- ? const Color(0xFF1C1C1C)- : const Color(0xFFFAFAFA);-- const greenColor = Color(0xFF08C225);- const warningRedColor = Color(0xFFF63A3A);- final helperTextColor = _errorMessage != null- ? warningRedColor- : colorScheme.textMuted;+ final l10n = AppLocalizations.of(context);return Column(mainAxisSize: MainAxisSize.min,crossAxisAlignment: CrossAxisAlignment.start,children: [- // Text input field- Container(- decoration: BoxDecoration(- color: inputBackgroundColor,- borderRadius: BorderRadius.circular(16),- ),- child: TextField(- controller: _controller,- textCapitalization: TextCapitalization.characters,- style: textTheme.body,- decoration: InputDecoration(- border: InputBorder.none,- contentPadding: const EdgeInsets.symmetric(- horizontal: 16,- vertical: 20,- ),- hintText: AppLocalizations.of(context).enterCode,- hintStyle: textTheme.body.copyWith(color: colorScheme.textMuted),- ),- ),- ),- const SizedBox(height: 9),- // Warning/helper text- Text(- _errorMessage ?? AppLocalizations.of(context).referralCodeHint,- style: textTheme.mini.copyWith(color: helperTextColor),+ TextInputComponent(+ controller: _controller,+ textCapitalization: TextCapitalization.characters,+ hintText: l10n.enterCode,+ message: _errorMessage ?? l10n.referralCodeHint,+ messageType: _errorMessage == null+ ? TextInputComponentMessageType.helper+ : TextInputComponentMessageType.error,+ autocorrect: false,),- const SizedBox(height: 20),- // Save button- SizedBox(- width: double.infinity,- height: 56,- child: ElevatedButton(- onPressed: _isLoading || !_hasChanges ? null : _saveCode,- style: ElevatedButton.styleFrom(- backgroundColor: _hasChanges ? greenColor : colorScheme.fillMuted,- foregroundColor: Colors.white,- disabledBackgroundColor: colorScheme.fillMuted,- disabledForegroundColor: colorScheme.textMuted,- shape: RoundedRectangleBorder(- borderRadius: BorderRadius.circular(20),- ),- elevation: 0,- ),- child: _isLoading- ? SizedBox(- width: 24,- height: 24,- child: CircularProgressIndicator(- strokeWidth: 2,- color: colorScheme.textMuted,- ),- )- : Text(- AppLocalizations.of(context).saveCode,- style: textTheme.bodyBold.copyWith(- color: _hasChanges ? Colors.white : colorScheme.textMuted,- ),- ),- ),+ const SizedBox(height: Spacing.lg),+ ButtonComponent(+ label: l10n.saveCode,+ isDisabled: _isLoading || !_hasChanges,+ shouldShowSuccessState: false,+ onTap: _saveCode,),],);diff --git a/mobile/apps/photos/lib/ui/growth/code_success_screen.dart b/mobile/apps/photos/lib/ui/growth/code_success_screen.dartindex 66e803eddb..bcc1c3b1d0 100644--- a/mobile/apps/photos/lib/ui/growth/code_success_screen.dart+++ b/mobile/apps/photos/lib/ui/growth/code_success_screen.dart@@ -1,12 +1,13 @@import "package:dotted_border/dotted_border.dart";+import "package:ente_components/ente_components.dart";import "package:ente_pure_utils/ente_pure_utils.dart";import "package:flutter/material.dart";import "package:hugeicons/hugeicons.dart";import "package:photos/gateways/storage_bonus/models/storage_bonus.dart";import "package:photos/generated/l10n.dart";import "package:photos/models/user_details.dart";-import "package:photos/theme/ente_theme.dart";import "package:photos/ui/growth/storage_details_screen.dart";+import "package:photos/ui/settings/components/settings_page_scaffold.dart";import "package:photos/utils/share_util.dart";class CodeSuccessScreen extends StatelessWidget {@@ -17,193 +18,126 @@ class CodeSuccessScreen extends StatelessWidget {@overrideWidget build(BuildContext context) {- final colorScheme = getEnteColorScheme(context);- final textTheme = getEnteTextTheme(context);- final isDarkMode = Theme.of(context).brightness == Brightness.dark;- final cardColor = isDarkMode- ? const Color(0xFF212121)- : const Color(0xFFFFFFFF);- const greenColor = Color(0xFF08C225);+ final colors = context.componentColors;+ final l10n = AppLocalizations.of(context);- return Scaffold(- backgroundColor: colorScheme.backgroundColour,- body: SafeArea(- child: SingleChildScrollView(- child: Padding(- padding: const EdgeInsets.symmetric(horizontal: 24),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- const SizedBox(height: 24),- // Back arrow- GestureDetector(- onTap: () => Navigator.of(context).pop(),- child: Icon(- Icons.arrow_back,- color: colorScheme.strokeBase,- size: 24,- ),- ),- const SizedBox(height: 24),- // Title- Text(- AppLocalizations.of(context).codeAppliedPageTitle,- style: textTheme.largeBold,- ),- const SizedBox(height: 42),- // Success icon and claimed text- Center(- child: Column(+ return SettingsPageScaffold(+ title: l10n.codeAppliedPageTitle,+ children: [+ Column(+ children: [+ const SizedBox(height: Spacing.xl),+ Container(+ width: 69,+ height: 69,+ decoration: BoxDecoration(+ color: colors.primary,+ shape: BoxShape.circle,+ ),+ child: Icon(Icons.check, color: colors.specialWhite, size: 40),+ ),+ const SizedBox(height: Spacing.md),+ Text(+ l10n.storageClaimed(+ storageAmountInGB: referralView.planInfo.storageInGB,+ ),+ style: TextStyles.h1.copyWith(color: colors.textBase),+ ),+ const SizedBox(height: 40),+ MenuComponent(+ title: l10n.details,+ trailing: Icon(+ Icons.chevron_right_outlined,+ color: colors.textLight,+ size: IconSizes.medium,+ ),+ onTap: () async {+ await routeToPage(+ context,+ StorageDetailsScreen(referralView, userDetails),+ );+ },+ ),+ const SizedBox(height: Spacing.sm),+ Container(+ width: double.infinity,+ padding: const EdgeInsets.all(Spacing.xxl),+ decoration: BoxDecoration(+ color: colors.fillLight,+ borderRadius: BorderRadius.circular(Radii.lg),+ ),+ child: Stack(+ children: [+ Column(children: [- // Green circle with checkmark- Container(- width: 69,- height: 69,- decoration: const BoxDecoration(- color: greenColor,- shape: BoxShape.circle,- ),- child: const Icon(- Icons.check,- color: Colors.white,- size: 40,+ Text(+ l10n.earnMoreSpace,+ style: TextStyles.bodyBold.copyWith(+ color: colors.textBase,),),- const SizedBox(height: 12),- // "10 GB claimed!" text+ const SizedBox(height: Spacing.md),Text(- AppLocalizations.of(context).storageClaimed(+ l10n.referralStorageForBoth(storageAmountInGB: referralView.planInfo.storageInGB,),- style: textTheme.h3Bold,- ),- ],- ),- ),- const SizedBox(height: 42),- // Details button- GestureDetector(- onTap: () {- routeToPage(- context,- StorageDetailsScreen(referralView, userDetails),- );- },- child: Container(- width: double.infinity,- padding: const EdgeInsets.all(16),- decoration: BoxDecoration(- color: cardColor,- borderRadius: BorderRadius.circular(20),- ),- child: Row(- mainAxisAlignment: MainAxisAlignment.spaceBetween,- children: [- Text(- AppLocalizations.of(context).details,- style: textTheme.body,- ),- Icon(- Icons.chevron_right,- color: colorScheme.strokeMuted,- size: 31,+ style: TextStyles.body.copyWith(+ color: colors.textLight,),- ],- ),- ),- ),- const SizedBox(height: 8),- // Earn more space card- Stack(- children: [- Container(- width: double.infinity,- padding: const EdgeInsets.symmetric(- horizontal: 16,- vertical: 24,- ),- decoration: BoxDecoration(- color: cardColor,- borderRadius: BorderRadius.circular(20),+ textAlign: TextAlign.center,),- child: Column(- children: [- Text(- AppLocalizations.of(context).earnMoreSpace,- style: textTheme.bodyBold,- ),- const SizedBox(height: 12),- Text(- AppLocalizations.of(context).referralStorageForBoth(- storageAmountInGB:- referralView.planInfo.storageInGB,- ),- style: textTheme.small.copyWith(- color: colorScheme.textMuted,- ),- textAlign: TextAlign.center,- ),- const SizedBox(height: 12),- // Referral code with dotted border- DottedBorder(- options: const RoundedRectDottedBorderOptions(- color: greenColor,- strokeWidth: 1,- dashPattern: [6, 6],- radius: Radius.circular(16),- ),- child: Container(- decoration: BoxDecoration(- color: cardColor,- borderRadius: BorderRadius.circular(16),- ),- padding: const EdgeInsets.symmetric(- horizontal: 36,- vertical: 20,- ),- child: Text(- referralView.code,- style: textTheme.small.copyWith(- color: greenColor,- ),- ),- ),+ const SizedBox(height: Spacing.md),+ DottedBorder(+ options: RoundedRectDottedBorderOptions(+ color: colors.primary,+ strokeWidth: 1,+ dashPattern: const [6, 6],+ radius: const Radius.circular(Radii.lg),+ ),+ child: Container(+ padding: const EdgeInsets.symmetric(+ horizontal: 36,+ vertical: Spacing.xl,),- ],- ),- ),- // Share button positioned at top right- Positioned(- top: 0,- right: 0,- child: GestureDetector(- behavior: HitTestBehavior.opaque,- onTap: () {- shareText(- AppLocalizations.of(context).shareTextReferralCode(- referralCode: referralView.code,- referralStorageInGB:- referralView.planInfo.storageInGB,+ child: Text(+ referralView.code,+ style: TextStyles.body.copyWith(+ color: colors.primary,),- );- },- child: Padding(- padding: const EdgeInsets.all(12),- child: HugeIcon(- icon: HugeIcons.strokeRoundedShare08,- color: colorScheme.strokeMuted,- size: 18,),),),+ ],+ ),+ Positioned(+ top: 0,+ right: 0,+ child: IconButtonComponent(+ variant: .unfilled,+ shouldSurfaceExecutionStates: false,+ tooltip: l10n.share,+ icon: HugeIcon(+ icon: HugeIcons.strokeRoundedShare08,+ color: colors.textLight,+ ),+ onTap: () {+ shareText(+ l10n.shareTextReferralCode(+ referralCode: referralView.code,+ referralStorageInGB:+ referralView.planInfo.storageInGB,+ ),+ );+ },),- ],- ),- ],+ ),+ ],+ ),),- ),+ const SizedBox(height: Spacing.xxl),+ ],),- ),+ ],);}}diff --git a/mobile/apps/photos/lib/ui/growth/referral_code_widget.dart b/mobile/apps/photos/lib/ui/growth/referral_code_widget.dartindex dd9c0f1e46..0a2169f0f6 100644--- a/mobile/apps/photos/lib/ui/growth/referral_code_widget.dart+++ b/mobile/apps/photos/lib/ui/growth/referral_code_widget.dart@@ -1,9 +1,9 @@import "package:dotted_border/dotted_border.dart";+import "package:ente_components/ente_components.dart";import "package:flutter/material.dart";import "package:hugeicons/hugeicons.dart";import "package:photos/generated/l10n.dart";import "package:photos/models/user_details.dart";-import "package:photos/theme/ente_theme.dart";import "package:photos/ui/growth/change_referral_code_sheet.dart";import "package:photos/utils/dialog_util.dart";@@ -23,13 +23,7 @@ class ReferralCodeWidget extends StatelessWidget {@overrideWidget build(BuildContext context) {- final textTheme = getEnteTextTheme(context);- final isDarkMode = Theme.of(context).brightness == Brightness.dark;-- const greenColor = Color(0xFF08C225);- final cardColor = isDarkMode- ? const Color(0xFF212121)- : const Color(0xFFFFFFFF);+ final colors = context.componentColors;// The edit button is 24px (6px padding + 12px icon + 6px padding)// Plus 12px tap padding on each side = 48px total tap area@@ -48,21 +42,24 @@ class ReferralCodeWidget extends StatelessWidget {right: shouldShowEdit ? overlapAmount + tapPadding : 0,),child: DottedBorder(- options: const RoundedRectDottedBorderOptions(- color: greenColor,+ options: RoundedRectDottedBorderOptions(+ color: colors.primary,strokeWidth: 1,- dashPattern: [6, 6],- radius: Radius.circular(16),+ dashPattern: const [6, 6],+ radius: const Radius.circular(Radii.lg),),child: Container(decoration: BoxDecoration(- color: cardColor,- borderRadius: BorderRadius.circular(16),+ color: colors.fillLight,+ borderRadius: BorderRadius.circular(Radii.lg),+ ),+ padding: const EdgeInsets.symmetric(+ horizontal: 36,+ vertical: Spacing.xl,),- padding: const EdgeInsets.symmetric(horizontal: 36, vertical: 20),child: Text(codeValue,- style: textTheme.small.copyWith(color: greenColor),+ style: TextStyles.body.copyWith(color: colors.primary),),),),@@ -99,14 +96,14 @@ class ReferralCodeWidget extends StatelessWidget {child: Padding(padding: const EdgeInsets.all(tapPadding),child: Container(- decoration: const BoxDecoration(- color: greenColor,+ decoration: BoxDecoration(+ color: colors.primary,shape: BoxShape.circle,),padding: const EdgeInsets.all(6),- child: const HugeIcon(+ child: HugeIcon(icon: HugeIcons.strokeRoundedEdit03,- color: Colors.white,+ color: colors.specialWhite,size: 12,),),diff --git a/mobile/apps/photos/lib/ui/growth/referral_screen.dart b/mobile/apps/photos/lib/ui/growth/referral_screen.dartindex fd7f715fad..75677e3db7 100644--- a/mobile/apps/photos/lib/ui/growth/referral_screen.dart+++ b/mobile/apps/photos/lib/ui/growth/referral_screen.dart@@ -1,3 +1,4 @@+import "package:ente_components/ente_components.dart";import "package:ente_pure_utils/ente_pure_utils.dart";import "package:flutter/material.dart";import "package:hugeicons/hugeicons.dart";@@ -6,14 +7,12 @@ import "package:photos/generated/l10n.dart";import "package:photos/models/user_details.dart";import "package:photos/service_locator.dart";import "package:photos/services/account/user_service.dart";-import "package:photos/theme/ente_theme.dart";-import "package:photos/theme/text_style.dart";import "package:photos/ui/common/loading_widget.dart";import "package:photos/ui/common/web_page.dart";-import "package:photos/ui/components/menu_item_widget/menu_item_widget_new.dart";import "package:photos/ui/growth/apply_code_sheet.dart";import "package:photos/ui/growth/referral_code_widget.dart";import "package:photos/ui/growth/storage_details_screen.dart";+import "package:photos/ui/settings/components/settings_page_scaffold.dart";import "package:photos/utils/share_util.dart";import "package:tuple/tuple.dart";@@ -45,52 +44,61 @@ class _ReferralScreenState extends State<ReferralScreen> {@overrideWidget build(BuildContext context) {- final colorScheme = getEnteColorScheme(context);-- return Scaffold(- backgroundColor: colorScheme.backgroundColour,- body: SafeArea(- child: FutureBuilder<Tuple2<ReferralView, UserDetails>>(- future: _fetchData(),- builder: (context, snapshot) {- if (snapshot.hasData) {- return ReferralWidget(- referralView: snapshot.data!.item1,+ final l10n = AppLocalizations.of(context);+ return FutureBuilder<Tuple2<ReferralView, UserDetails>>(+ future: _fetchData(),+ builder: (context, snapshot) {+ final referralView = snapshot.data?.item1;+ return SettingsPageScaffold(+ title: l10n.earnFreeStorage,+ subtitle: l10n.shareCodeEarnStorage,+ actions: [+ if (referralView?.planInfo.isEnabled ?? false)+ IconButtonComponent(+ icon: HugeIcon(+ icon: HugeIcons.strokeRoundedShare08,+ color: context.componentColors.iconColor,+ ),+ tooltip: l10n.share,+ shouldSurfaceExecutionStates: false,+ onTap: () {+ shareText(+ l10n.shareTextReferralCode(+ referralCode: referralView!.code,+ referralStorageInGB: referralView.planInfo.storageInGB,+ ),+ );+ },+ ),+ ],+ children: [+ if (snapshot.hasData)+ ReferralWidget(+ referralView: referralView!,userDetails: snapshot.data!.item2,notifyParent: _safeUIUpdate,- );- } else if (snapshot.hasError) {- return Padding(- padding: const EdgeInsets.symmetric(horizontal: 16),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- const SizedBox(height: 24),- GestureDetector(- onTap: () => Navigator.of(context).pop(),- child: Icon(- Icons.arrow_back,- color: colorScheme.strokeBase,- size: 24,- ),- ),- Expanded(- child: Center(- child: Text(- AppLocalizations.of(- context,- ).failedToFetchReferralDetails,- ),- ),+ )+ else if (snapshot.hasError)+ Padding(+ padding: const EdgeInsets.symmetric(vertical: 80),+ child: Center(+ child: Text(+ l10n.failedToFetchReferralDetails,+ style: TextStyles.body.copyWith(+ color: context.componentColors.textLight,),- ],+ textAlign: TextAlign.center,+ ),),- );- }- return const Center(child: EnteLoadingWidget());- },- ),- ),+ )+ else+ const Padding(+ padding: EdgeInsets.symmetric(vertical: 80),+ child: Center(child: EnteLoadingWidget()),+ ),+ ],+ );+ },);}}@@ -109,153 +117,74 @@ class ReferralWidget extends StatelessWidget {@overrideWidget build(BuildContext context) {- final colorScheme = getEnteColorScheme(context);- final textTheme = getEnteTextTheme(context);- final isDarkMode = Theme.of(context).brightness == Brightness.dark;+ final colors = context.componentColors;+ final l10n = AppLocalizations.of(context);final bool isReferralEnabled = referralView.planInfo.isEnabled;- final cardColor = isDarkMode- ? const Color(0xFF212121)- : const Color(0xFFFFFFFF);-- return SingleChildScrollView(- child: Padding(- padding: const EdgeInsets.symmetric(horizontal: 16),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- const SizedBox(height: 24),- // Back arrow- GestureDetector(- onTap: () => Navigator.of(context).pop(),- child: Icon(- Icons.arrow_back,- color: colorScheme.strokeBase,- size: 24,- ),- ),- const SizedBox(height: 24),- // Header section with title and share button- Row(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Expanded(- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Text(- AppLocalizations.of(context).earnFreeStorage,- style: textTheme.largeBold,- ),- const SizedBox(height: 8),- Text(- AppLocalizations.of(context).shareCodeEarnStorage,- style: textTheme.miniMuted,- ),- ],- ),- ),- if (isReferralEnabled)- GestureDetector(- onTap: () {- shareText(- AppLocalizations.of(context).shareTextReferralCode(- referralCode: referralView.code,- referralStorageInGB:- referralView.planInfo.storageInGB,- ),- );- },- child: Container(- decoration: BoxDecoration(- color: cardColor,- borderRadius: BorderRadius.circular(8),- ),- padding: const EdgeInsets.all(8),- child: HugeIcon(- icon: HugeIcons.strokeRoundedShare08,- color: colorScheme.strokeBase,- size: 20,- ),- ),- ),- ],+ return Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ if (isReferralEnabled) ...[+ const SizedBox(height: Spacing.xxl),+ Center(+ child: ReferralCodeWidget(+ referralView.code,+ shouldShowEdit: true,+ userDetails: userDetails,+ notifyParent: notifyParent,),- const SizedBox(height: 42),- // Referral code section- if (isReferralEnabled) ...[- Center(- child: ReferralCodeWidget(- referralView.code,- shouldShowEdit: true,- userDetails: userDetails,- notifyParent: notifyParent,- ),- ),- const SizedBox(height: 16),- // Instructions- _buildInstructions(context, textTheme),- const SizedBox(height: 16),- ] else ...[- Padding(- padding: const EdgeInsets.symmetric(vertical: 48),- child: Center(- child: Column(- crossAxisAlignment: CrossAxisAlignment.center,- children: [- Icon(Icons.error_outline, color: colorScheme.strokeMuted),- const SizedBox(height: 12),- Text(- AppLocalizations.of(- context,- ).referralsAreCurrentlyPaused,- style: textTheme.small.copyWith(- color: colorScheme.textFaint,- ),- ),- ],+ ),+ const SizedBox(height: Spacing.xl),+ _buildInstructions(context),+ const SizedBox(height: Spacing.xxl),+ ] else ...[+ Padding(+ padding: const EdgeInsets.symmetric(vertical: 48),+ child: Center(+ child: Column(+ children: [+ Icon(Icons.error_outline, color: colors.textLight),+ const SizedBox(height: Spacing.md),+ Text(+ l10n.referralsAreCurrentlyPaused,+ style: TextStyles.body.copyWith(color: colors.textLight),),- ),+ ],),- ],- // Menu items- if (referralView.enableApplyCode) ...[- MenuItemWidgetNew(- title: AppLocalizations.of(context).applyCodeTitle,- trailingIcon: Icons.chevron_right_outlined,- trailingIconIsMuted: true,+ ),+ ),+ ],+ MenuGroupComponent(+ items: [+ if (referralView.enableApplyCode)+ MenuComponent(+ title: l10n.applyCodeTitle,+ trailing: _chevron(colors),onTap: () async {final result = await showApplyCodeSheet(context,referralView: referralView,userDetails: userDetails,);- if (result == true) {- notifyParent();- }+ if (result == true) notifyParent();},),- const SizedBox(height: 8),- ],- MenuItemWidgetNew(- title: AppLocalizations.of(context).faq,- trailingIcon: Icons.chevron_right_outlined,- trailingIconIsMuted: true,+ MenuComponent(+ title: l10n.faq,+ trailing: _chevron(colors),onTap: () async {await routeToPage(context,WebPage(- AppLocalizations.of(context).faq,+ l10n.faq,"https://ente.com/help/photos/features/account/referral-program/",),);},),- const SizedBox(height: 8),- MenuItemWidgetNew(- title: AppLocalizations.of(context).details,- trailingIcon: Icons.chevron_right_outlined,- trailingIconIsMuted: true,+ MenuComponent(+ title: l10n.details,+ trailing: _chevron(colors),onTap: () async {await routeToPage(context,@@ -263,17 +192,26 @@ class ReferralWidget extends StatelessWidget {);},),- const SizedBox(height: 60),],),- ),+ const SizedBox(height: Spacing.xxl),+ ],);}- Widget _buildInstructions(BuildContext context, EnteTextTheme textTheme) {- const greenColor = Color(0xFF08C225);+ Widget _chevron(ColorTokens colors) => Icon(+ Icons.chevron_right_outlined,+ color: colors.textLight,+ size: IconSizes.medium,+ );++ Widget _buildInstructions(BuildContext context) {+ final colors = context.componentColors;final storageInGB = referralView.planInfo.storageInGB;- final mutedStyle = textTheme.miniMuted.copyWith(height: 2);+ final mutedStyle = TextStyles.mini.copyWith(+ color: colors.textLight,+ height: 2,+ );final step3Text = AppLocalizations.of(context,).referralStep3(storageInGB: storageInGB);@@ -289,7 +227,7 @@ class ReferralWidget extends StatelessWidget {children: _buildHighlightedSpans(step3Text,mutedStyle,- greenColor,+ colors.primary,["${storageInGB}GB free", "$storageInGB GB free"],["${storageInGB}GB", "$storageInGB GB"],),diff --git a/mobile/apps/photos/lib/ui/growth/storage_details_screen.dart b/mobile/apps/photos/lib/ui/growth/storage_details_screen.dartindex f1f69c9fa0..e7a0742597 100644--- a/mobile/apps/photos/lib/ui/growth/storage_details_screen.dart+++ b/mobile/apps/photos/lib/ui/growth/storage_details_screen.dart@@ -1,13 +1,14 @@import "dart:math";+import "package:ente_components/ente_components.dart";import "package:ente_pure_utils/ente_pure_utils.dart";import "package:flutter/material.dart";import "package:photos/gateways/storage_bonus/models/storage_bonus.dart";import "package:photos/generated/l10n.dart";import "package:photos/models/user_details.dart";import "package:photos/service_locator.dart";-import "package:photos/theme/ente_theme.dart";import "package:photos/ui/common/loading_widget.dart";+import "package:photos/ui/settings/components/settings_page_scaffold.dart";class StorageDetailsScreen extends StatefulWidget {final ReferralView referralView;@@ -22,176 +23,94 @@ class StorageDetailsScreen extends StatefulWidget {class _StorageDetailsScreenState extends State<StorageDetailsScreen> {@overrideWidget build(BuildContext context) {- final colorScheme = getEnteColorScheme(context);- final textTheme = getEnteTextTheme(context);- final isDarkMode = Theme.of(context).brightness == Brightness.dark;- final cardColor = isDarkMode- ? const Color(0xFF212121)- : const Color(0xFFFFFFFF);+ final l10n = AppLocalizations.of(context);- return Scaffold(- backgroundColor: colorScheme.backgroundColour,- body: SafeArea(- child: FutureBuilder<BonusDetails>(+ return SettingsPageScaffold(+ title: l10n.referralStats,+ children: [+ FutureBuilder<BonusDetails>(future: storageBonusService.getBonusDetails(),builder: (context, snapshot) {if (snapshot.connectionState == ConnectionState.waiting) {+ return const Padding(+ padding: EdgeInsets.symmetric(vertical: 80),+ child: Center(child: EnteLoadingWidget()),+ );+ }++ if (snapshot.hasError) {return Padding(- padding: const EdgeInsets.symmetric(horizontal: 16),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- const SizedBox(height: 24),- GestureDetector(- onTap: () => Navigator.of(context).pop(),- child: Icon(- Icons.arrow_back,- color: colorScheme.strokeBase,- size: 24,- ),+ padding: const EdgeInsets.symmetric(vertical: 80),+ child: Center(+ child: Text(+ l10n.oopsSomethingWentWrong,+ style: TextStyles.body.copyWith(+ color: context.componentColors.textLight,),- const Expanded(child: Center(child: EnteLoadingWidget())),- ],+ ),),);}- if (snapshot.hasError) {- return Padding(- padding: const EdgeInsets.symmetric(horizontal: 16),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,+ final BonusDetails data = snapshot.data!;+ return Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Row(children: [- const SizedBox(height: 24),- GestureDetector(- onTap: () => Navigator.of(context).pop(),- child: Icon(- Icons.arrow_back,- color: colorScheme.strokeBase,- size: 24,+ Expanded(+ child: _StatCard(+ value: data.refCount.toString(),+ label: l10n.usedYourCode,),),+ const SizedBox(width: Spacing.lg),Expanded(- child: Center(- child: Text(- AppLocalizations.of(context).oopsSomethingWentWrong,- ),+ child: _StatCard(+ value: data.refUpgradeCount.toString(),+ label: l10n.eligible,),),],),- );- }-- final BonusDetails data = snapshot.data!;-- return SingleChildScrollView(- child: Padding(- padding: const EdgeInsets.symmetric(horizontal: 16),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,+ const SizedBox(height: Spacing.lg),+ if (data.hasAppliedCode) ...[+ _StatCard(value: "1", label: l10n.claimedByYou),+ const SizedBox(height: Spacing.lg),+ ],+ Row(children: [- const SizedBox(height: 24),- // Back arrow- GestureDetector(- onTap: () => Navigator.of(context).pop(),- child: Icon(- Icons.arrow_back,- color: colorScheme.strokeBase,- size: 24,+ Expanded(+ child: _StatCard(+ value:+ "${convertBytesToAbsoluteGBs(widget.referralView.claimedStorage)} GB",+ label: l10n.earned,),),- const SizedBox(height: 24),- // Title- Text(- AppLocalizations.of(context).referralStats,- style: textTheme.largeBold,- ),- const SizedBox(height: 24),- // Stats cards- Column(- children: [- // Row 1: Used your code + Eligible- Row(- children: [- Expanded(- child: _StatCard(- value: data.refCount.toString(),- label: AppLocalizations.of(- context,- ).usedYourCode,- cardColor: cardColor,- ),- ),- const SizedBox(width: 16),- Expanded(- child: _StatCard(- value: data.refUpgradeCount.toString(),- label: AppLocalizations.of(context).eligible,- cardColor: cardColor,- ),- ),- ],- ),- const SizedBox(height: 16),- // Row 2: Claimed by you (only if has applied code)- if (data.hasAppliedCode) ...[- Row(- children: [- Expanded(- child: _StatCard(- value: "1",- label: AppLocalizations.of(- context,- ).claimedByYou,- cardColor: cardColor,- ),- ),- ],- ),- const SizedBox(height: 16),- ],- // Row 3: Earned + Usable- Row(- children: [- Expanded(- child: _StatCard(- value:- "${convertBytesToAbsoluteGBs(widget.referralView.claimedStorage)} GB",- label: AppLocalizations.of(context).earned,- cardColor: cardColor,- ),- ),- const SizedBox(width: 16),- Expanded(- child: _StatCard(- value:- "${convertBytesToAbsoluteGBs(min(widget.referralView.claimedStorage, widget.userDetails.getPlanPlusAddonStorage()))} GB",- label: AppLocalizations.of(context).usable,- cardColor: cardColor,- ),- ),- ],- ),- ],- ),- const SizedBox(height: 24),- // Info text- Text(- AppLocalizations.of(context).referralStorageInfo,- style: textTheme.small.copyWith(- color: colorScheme.textMuted,- height: 1.5,+ const SizedBox(width: Spacing.lg),+ Expanded(+ child: _StatCard(+ value:+ "${convertBytesToAbsoluteGBs(min(widget.referralView.claimedStorage, widget.userDetails.getPlanPlusAddonStorage()))} GB",+ label: l10n.usable,),),- const SizedBox(height: 60),],),- ),+ const SizedBox(height: Spacing.xxl),+ Text(+ l10n.referralStorageInfo,+ style: TextStyles.body.copyWith(+ color: context.componentColors.textLight,+ height: 1.5,+ ),+ ),+ const SizedBox(height: Spacing.xxl),+ ],);},),- ),+ ],);}}@@ -199,31 +118,26 @@ class _StorageDetailsScreenState extends State<StorageDetailsScreen> {class _StatCard extends StatelessWidget {final String value;final String label;- final Color cardColor;- const _StatCard({- required this.value,- required this.label,- required this.cardColor,- });+ const _StatCard({required this.value, required this.label});@overrideWidget build(BuildContext context) {- final textTheme = getEnteTextTheme(context);- const greenColor = Color(0xFF08C225);+ final colors = context.componentColors;return Container(+ width: double.infinity,decoration: BoxDecoration(- color: cardColor,- borderRadius: BorderRadius.circular(20),+ color: colors.fillLight,+ borderRadius: BorderRadius.circular(Radii.lg),),- padding: const EdgeInsets.all(16),+ padding: const EdgeInsets.all(Spacing.lg),child: Column(crossAxisAlignment: CrossAxisAlignment.start,children: [- Text(value, style: textTheme.h3Bold.copyWith(color: greenColor)),- const SizedBox(height: 4),- Text(label, style: textTheme.smallMuted),+ Text(value, style: TextStyles.h1.copyWith(color: colors.primary)),+ const SizedBox(height: Spacing.xs),+ Text(label, style: TextStyles.body.copyWith(color: colors.textLight)),],),);