Prompt family members to contact admin to change referral code

This commit is contained in:
vishnukvmd
2024-08-22 13:10:30 +05:30
parent a43b97026a
commit 4ee815e530
5 changed files with 40 additions and 5 deletions

View File

@@ -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 <branding>ente</branding>"),
"onlyFamilyAdminCanChangeCode": m71,
"oops": MessageLookupByLibrary.simpleMessage("Oops"),
"oopsCouldNotSaveEdits":
MessageLookupByLibrary.simpleMessage("Oops, could not save edits"),

View File

@@ -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(

View File

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

View File

@@ -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,

View File

@@ -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),