diff --git a/mobile/lib/generated/intl/messages_en.dart b/mobile/lib/generated/intl/messages_en.dart index c0dda0ce55..0cc81cb39b 100644 --- a/mobile/lib/generated/intl/messages_en.dart +++ b/mobile/lib/generated/intl/messages_en.dart @@ -127,6 +127,9 @@ class MessageLookup extends MessageLookupByLibrary { static String m37(name) => "Not ${name}?"; + static String m71(familyAdminEmail) => + "Please contact ${familyAdminEmail} to change your code."; + static String m38(passwordStrengthValue) => "Password strength: ${passwordStrengthValue}"; @@ -1067,6 +1070,7 @@ class MessageLookup extends MessageLookupByLibrary { "onDevice": MessageLookupByLibrary.simpleMessage("On device"), "onEnte": MessageLookupByLibrary.simpleMessage( "On ente"), + "onlyFamilyAdminCanChangeCode": m71, "oops": MessageLookupByLibrary.simpleMessage("Oops"), "oopsCouldNotSaveEdits": MessageLookupByLibrary.simpleMessage("Oops, could not save edits"), diff --git a/mobile/lib/generated/l10n.dart b/mobile/lib/generated/l10n.dart index a1ad4fe581..94729093a1 100644 --- a/mobile/lib/generated/l10n.dart +++ b/mobile/lib/generated/l10n.dart @@ -2096,6 +2096,16 @@ class S { ); } + /// `Please contact {familyAdminEmail} to change your code.` + String onlyFamilyAdminCanChangeCode(Object familyAdminEmail) { + return Intl.message( + 'Please contact $familyAdminEmail to change your code.', + name: 'onlyFamilyAdminCanChangeCode', + desc: '', + args: [familyAdminEmail], + ); + } + /// `{storageAmountInGB} GB` String storageInGB(Object storageAmountInGB) { return Intl.message( diff --git a/mobile/lib/l10n/intl_en.arb b/mobile/lib/l10n/intl_en.arb index 6c6deb74d9..18f3ab1068 100644 --- a/mobile/lib/l10n/intl_en.arb +++ b/mobile/lib/l10n/intl_en.arb @@ -277,6 +277,7 @@ "change": "Change", "unavailableReferralCode": "Sorry, this code is unavailable.", "codeChangeLimitReached": "Sorry, you've reached the limit of code changes.", + "onlyFamilyAdminCanChangeCode": "Please contact {familyAdminEmail} to change your code.", "storageInGB": "{storageAmountInGB} GB", "claimed": "Claimed", "@claimed": { diff --git a/mobile/lib/ui/growth/referral_code_widget.dart b/mobile/lib/ui/growth/referral_code_widget.dart index d22e591c4d..a314360be8 100644 --- a/mobile/lib/ui/growth/referral_code_widget.dart +++ b/mobile/lib/ui/growth/referral_code_widget.dart @@ -3,6 +3,7 @@ import "package:dotted_border/dotted_border.dart"; import "package:flutter/material.dart"; import "package:logging/logging.dart"; import "package:photos/generated/l10n.dart"; +import "package:photos/models/user_details.dart"; import "package:photos/services/storage_bonus_service.dart"; import "package:photos/theme/ente_theme.dart"; import "package:photos/utils/dialog_util.dart"; @@ -10,12 +11,14 @@ import "package:photos/utils/dialog_util.dart"; // Figma: https://www.figma.com/file/SYtMyLBs5SAOkTbfMMzhqt/ente-Visual-Design?node-id=11219%3A62974&t=BRCLJhxXP11Q3Wyw-0 class ReferralCodeWidget extends StatelessWidget { final String codeValue; - final bool shouldAllowEdit; + final bool shouldShowEdit; + final UserDetails? userDetails; final Function? notifyParent; const ReferralCodeWidget( this.codeValue, { - this.shouldAllowEdit = false, + this.shouldShowEdit = false, + this.userDetails, this.notifyParent, super.key, }); @@ -49,10 +52,26 @@ class ReferralCodeWidget extends StatelessWidget { ), ), const SizedBox(width: 12), - shouldAllowEdit + shouldShowEdit ? GestureDetector( onTap: () { - showUpdateReferralCodeDialog(context); + if (userDetails!.isPartOfFamily() && + !userDetails!.isFamilyAdmin()) { + final String familyAdmin = userDetails! + .familyData!.members! + .firstWhere((element) => element.isAdmin) + .email; + showInfoDialog( + context, + title: S.of(context).error, + body: S + .of(context) + .onlyFamilyAdminCanChangeCode(familyAdmin), + icon: Icons.error, + ); + } else { + showUpdateReferralCodeDialog(context); + } }, child: Icon( Icons.edit, diff --git a/mobile/lib/ui/growth/referral_screen.dart b/mobile/lib/ui/growth/referral_screen.dart index 521f9bccf6..d2897dd381 100644 --- a/mobile/lib/ui/growth/referral_screen.dart +++ b/mobile/lib/ui/growth/referral_screen.dart @@ -166,7 +166,8 @@ class ReferralWidget extends StatelessWidget { const SizedBox(height: 12), ReferralCodeWidget( referralView.code, - shouldAllowEdit: true, + shouldShowEdit: true, + userDetails: userDetails, notifyParent: notifyParent, ), const SizedBox(height: 12),