Skip to content

armgit / ente

Public Imported from GitHub
0

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

Update referral steps copy

Neeraj Guptae21f66da8145
diff --git a/mobile/apps/photos/lib/l10n/intl_en.arb b/mobile/apps/photos/lib/l10n/intl_en.arb
index 1591a04372..b77a51d867 100644
--- a/mobile/apps/photos/lib/l10n/intl_en.arb
+++ b/mobile/apps/photos/lib/l10n/intl_en.arb
@@ -336,9 +336,9 @@
"youBothGet": "You both get",
"free": "free",
"failedToFetchReferralDetails": "Unable to fetch referral details. Please try again later.",
- "referralStep1": "1. Customise and share your code with your friends.",
- "referralStep2": "2. They sign up for a paid plan",
- "referralStep3": "3. Both of you get {storageInGB} GB* free",
+ "referralStep1": "1. Customise and share your code.",
+ "referralStep2": "2. They sign up to Ente using your code.",
+ "referralStep3": "3. {storageInGB}GB free for them + {storageInGB}GB free for you when they upgrade.",
"referralsAreCurrentlyPaused": "Referrals are currently paused",
"youCanAtMaxDoubleYourStorage": "You can max double your storage",
"claimedStorageSoFar": "{isFamilyMember, select, true {Your family has claimed {storageAmountInGb} GB so far} false {You have claimed {storageAmountInGb} GB so far} other {You have claimed {storageAmountInGb} GB so far!}}",
diff --git a/mobile/apps/photos/lib/ui/growth/referral_screen.dart b/mobile/apps/photos/lib/ui/growth/referral_screen.dart
index 93f5de214d..56c107de58 100644
--- a/mobile/apps/photos/lib/ui/growth/referral_screen.dart
+++ b/mobile/apps/photos/lib/ui/growth/referral_screen.dart
@@ -276,6 +276,9 @@ class ReferralWidget extends StatelessWidget {
const greenColor = Color(0xFF08C225);
final storageInGB = referralView.planInfo.storageInGB;
final mutedStyle = textTheme.miniMuted.copyWith(height: 2);
+ final step3Text = AppLocalizations.of(context).referralStep3(
+ storageInGB: storageInGB,
+ );
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -291,22 +294,81 @@ class ReferralWidget extends StatelessWidget {
RichText(
text: TextSpan(
style: mutedStyle,
- children: [
- TextSpan(
- text: "3. ${AppLocalizations.of(context).youBothGet} ",
- ),
- TextSpan(
- text: "${storageInGB}GB ${AppLocalizations.of(context).free}",
- style: const TextStyle(color: greenColor),
- ),
- TextSpan(
- text:
- ". (${AppLocalizations.of(context).youCanAtMaxDoubleYourStorage})",
- ),
- ],
+ children: _buildHighlightedSpans(
+ step3Text,
+ mutedStyle,
+ greenColor,
+ [
+ "${storageInGB}GB free",
+ "$storageInGB GB free",
+ ],
+ [
+ "${storageInGB}GB",
+ "$storageInGB GB",
+ ],
+ ),
),
),
],
);
}
+
+ List<TextSpan> _buildHighlightedSpans(
+ String text,
+ TextStyle baseStyle,
+ Color highlightColor,
+ List<String> preferredTokens,
+ List<String> fallbackTokens,
+ ) {
+ final tokens = preferredTokens.any(text.contains)
+ ? preferredTokens
+ : fallbackTokens.any(text.contains)
+ ? fallbackTokens
+ : const <String>[];
+
+ if (tokens.isEmpty) {
+ return [TextSpan(text: text)];
+ }
+
+ final spans = <TextSpan>[];
+ var index = 0;
+
+ while (index < text.length) {
+ int? nextIndex;
+ String? nextToken;
+ for (final token in tokens) {
+ final tokenIndex = text.indexOf(token, index);
+ if (tokenIndex == -1) {
+ continue;
+ }
+ if (nextIndex == null || tokenIndex < nextIndex) {
+ nextIndex = tokenIndex;
+ nextToken = token;
+ }
+ }
+
+ if (nextIndex == null || nextToken == null) {
+ break;
+ }
+
+ if (nextIndex > index) {
+ spans.add(TextSpan(text: text.substring(index, nextIndex)));
+ }
+
+ spans.add(
+ TextSpan(
+ text: nextToken,
+ style: baseStyle.copyWith(color: highlightColor),
+ ),
+ );
+
+ index = nextIndex + nextToken.length;
+ }
+
+ if (index < text.length) {
+ spans.add(TextSpan(text: text.substring(index)));
+ }
+
+ return spans;
+ }
}