Skip to content

armgit / ente

Public Imported from GitHub
0

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

referal screen update

AmanRajSinghMourya94accd0aacf2
diff --git a/mobile/apps/photos/assets/2.0x/referral_card_lines.png b/mobile/apps/photos/assets/2.0x/referral_card_lines.png
new file mode 100644
index 0000000000..6d1d80832d
Binary files /dev/null and b/mobile/apps/photos/assets/2.0x/referral_card_lines.png differ
diff --git a/mobile/apps/photos/assets/3.0x/referral_card_lines.png b/mobile/apps/photos/assets/3.0x/referral_card_lines.png
new file mode 100644
index 0000000000..c7c7922e89
Binary files /dev/null and b/mobile/apps/photos/assets/3.0x/referral_card_lines.png differ
diff --git a/mobile/apps/photos/assets/referral_card.riv b/mobile/apps/photos/assets/referral_card.riv
new file mode 100644
index 0000000000..ffc105c2b5
Binary files /dev/null and b/mobile/apps/photos/assets/referral_card.riv differ
diff --git a/mobile/apps/photos/assets/referral_card_lines.png b/mobile/apps/photos/assets/referral_card_lines.png
new file mode 100644
index 0000000000..a50c1e321e
Binary files /dev/null and b/mobile/apps/photos/assets/referral_card_lines.png differ
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.dart
deleted file mode 100644
index fbb7cb4beb..0000000000
--- a/mobile/apps/photos/lib/ui/growth/change_referral_code_sheet.dart
+++ /dev/null
@@ -1,146 +0,0 @@
-import "package:dio/dio.dart";
-import "package:ente_components/ente_components.dart";
-import "package:ente_strings/ente_strings.dart";
-import "package:flutter/material.dart";
-import "package:logging/logging.dart";
-import "package:photos/service_locator.dart";
-import "package:photos/utils/dialog_util.dart";
-
-Future<bool?> showChangeReferralCodeSheet(
- BuildContext context, {
- required String currentCode,
- required VoidCallback onCodeChanged,
-}) {
- return showBottomSheetComponent<bool>(
- context: context,
- builder: (_) => BottomSheetComponent(
- title: context.strings.changeYourReferralCode,
- isKeyboardAware: true,
- content: _ChangeReferralCodeContent(
- currentCode: currentCode,
- onCodeChanged: onCodeChanged,
- ),
- ),
- );
-}
-
-class _ChangeReferralCodeContent extends StatefulWidget {
- final String currentCode;
- final VoidCallback onCodeChanged;
-
- const _ChangeReferralCodeContent({
- required this.currentCode,
- required this.onCodeChanged,
- });
-
- @override
- State<_ChangeReferralCodeContent> createState() =>
- _ChangeReferralCodeContentState();
-}
-
-class _ChangeReferralCodeContentState
- extends State<_ChangeReferralCodeContent> {
- late TextEditingController _controller;
- bool _isLoading = false;
- String? _errorMessage;
-
- @override
- void initState() {
- super.initState();
- _controller = TextEditingController(text: widget.currentCode);
- _controller.addListener(_onTextChanged);
- }
-
- @override
- void dispose() {
- _controller.removeListener(_onTextChanged);
- _controller.dispose();
- super.dispose();
- }
-
- void _onTextChanged() {
- setState(() {
- _errorMessage = null;
- });
- }
-
- bool get _hasChanges =>
- _controller.text.trim().length >= 4 &&
- _controller.text.trim() != widget.currentCode;
-
- Future<void> _saveCode() async {
- final newCode = _controller.text.trim();
- if (newCode.isEmpty || newCode == widget.currentCode) {
- return;
- }
-
- setState(() {
- _isLoading = true;
- _errorMessage = null;
- });
-
- try {
- await storageBonusService.updateCode(newCode);
- widget.onCodeChanged();
- if (mounted) {
- Navigator.of(context).pop(true);
- }
- } catch (e, s) {
- Logger("ChangeReferralCodeSheet").severe("Failed to update code", e, s);
- if (e is DioException) {
- if (e.response?.statusCode == 400) {
- setState(() {
- _errorMessage = context.strings.unavailableReferralCode;
- });
- } else if (e.response?.statusCode == 429) {
- setState(() {
- _errorMessage = context.strings.codeChangeLimitReached;
- });
- } else {
- if (mounted) {
- await showGenericErrorDialog(context: context, error: e);
- }
- }
- } else {
- if (mounted) {
- await showGenericErrorDialog(context: context, error: e);
- }
- }
- } finally {
- if (mounted) {
- setState(() {
- _isLoading = false;
- });
- }
- }
- }
-
- @override
- Widget build(BuildContext context) {
- final l10n = context.strings;
-
- return Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- 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: Spacing.lg),
- ButtonComponent(
- label: l10n.saveCode,
- isDisabled: _isLoading || !_hasChanges,
- shouldShowSuccessState: false,
- onTap: _saveCode,
- ),
- ],
- );
- }
-}
diff --git a/mobile/apps/photos/lib/ui/growth/referral_code_widget.dart b/mobile/apps/photos/lib/ui/growth/referral_code_widget.dart
index f0a370bfb1..702f34d7f8 100644
--- a/mobile/apps/photos/lib/ui/growth/referral_code_widget.dart
+++ b/mobile/apps/photos/lib/ui/growth/referral_code_widget.dart
@@ -1,111 +1,382 @@
-import "package:dotted_border/dotted_border.dart";
+import "package:dio/dio.dart";
import "package:ente_components/ente_components.dart";
import "package:ente_strings/ente_strings.dart";
+import "package:ente_ui/components/loading_widget.dart";
import "package:flutter/material.dart";
+import "package:flutter/services.dart";
import "package:hugeicons/hugeicons.dart";
+import "package:logging/logging.dart";
import "package:photos/models/user_details.dart";
-import "package:photos/ui/growth/change_referral_code_sheet.dart";
+import "package:photos/service_locator.dart";
import "package:photos/utils/dialog_util.dart";
+import "package:rive/rive.dart" as rive;
-class ReferralCodeWidget extends StatelessWidget {
- final String codeValue;
- final bool shouldShowEdit;
- final UserDetails? userDetails;
- final Function? notifyParent;
-
- const ReferralCodeWidget(
- this.codeValue, {
- this.shouldShowEdit = false,
- this.userDetails,
- this.notifyParent,
+class ReferralCodeWidget extends StatefulWidget {
+ final String code;
+ final UserDetails userDetails;
+ final ValueChanged<String> onCodeChanged;
+
+ const ReferralCodeWidget({
+ required this.code,
+ required this.userDetails,
+ required this.onCodeChanged,
super.key,
});
@override
- Widget build(BuildContext context) {
- final colors = context.componentColors;
+ State<ReferralCodeWidget> createState() => _ReferralCodeWidgetState();
+}
- const editButtonSize = 24.0;
- const tapPadding = 12.0;
- const overlapAmount = editButtonSize / 2;
-
- return Stack(
- clipBehavior: Clip.none,
- children: [
- Padding(
- padding: EdgeInsets.only(
- bottom: shouldShowEdit ? overlapAmount + tapPadding : 0,
- right: shouldShowEdit ? overlapAmount + tapPadding : 0,
- ),
- child: DottedBorder(
- options: RoundedRectDottedBorderOptions(
- color: colors.primary,
- strokeWidth: 1,
- dashPattern: const [6, 6],
- radius: const Radius.circular(Radii.lg),
- ),
+class _ReferralCodeWidgetState extends State<ReferralCodeWidget> {
+ final Logger _logger = Logger("ReferralCodeWidget");
+ late final TextEditingController _controller;
+ late final FocusNode _focusNode;
+ late final rive.FileLoader _artworkLoader;
+ bool _isEditing = false;
+ bool _isSaving = false;
+ String? _errorText;
+
+ @override
+ void initState() {
+ super.initState();
+ _controller = TextEditingController(text: widget.code);
+ _focusNode = FocusNode()..addListener(_handleFocusChange);
+ _artworkLoader = rive.FileLoader.fromAsset(
+ "assets/referral_card.riv",
+ riveFactory: rive.Factory.flutter,
+ );
+ }
+
+ @override
+ void didUpdateWidget(covariant ReferralCodeWidget oldWidget) {
+ super.didUpdateWidget(oldWidget);
+ if (oldWidget.code != widget.code && !_isEditing) {
+ _controller.text = widget.code;
+ }
+ }
+
+ @override
+ void dispose() {
+ _focusNode.removeListener(_handleFocusChange);
+ _controller.dispose();
+ _focusNode.dispose();
+ _artworkLoader.dispose();
+ super.dispose();
+ }
+
+ void _handleTextChanged(String _) {
+ setState(() {
+ _errorText = null;
+ });
+ }
+
+ void _handleFocusChange() {
+ if (!_focusNode.hasFocus && _isEditing && !_isSaving) {
+ _cancelEditing();
+ }
+ }
+
+ void _cancelEditing() {
+ setState(() {
+ _isEditing = false;
+ _errorText = null;
+ _controller.text = widget.code;
+ });
+ }
+
+ String get _trimmedInput => _controller.text.trim();
+
+ bool get _canSave {
+ final input = _trimmedInput;
+ return !_isSaving &&
+ _errorText == null &&
+ input.length >= 4 &&
+ input != widget.code;
+ }
+
+ void _handleEditTap() {
+ final userDetails = widget.userDetails;
+ if (userDetails.isPartOfFamily() && !userDetails.isFamilyAdmin()) {
+ showInfoDialog(
+ context,
+ title: context.strings.error,
+ body: context.strings.onlyFamilyAdminCanChangeCode(
+ familyAdminEmail: userDetails.familyData!.members!
+ .firstWhere((element) => element.isAdmin)
+ .email,
+ ),
+ icon: Icons.error,
+ );
+ return;
+ }
+ setState(() {
+ _isEditing = true;
+ _errorText = null;
+ _controller
+ ..text = widget.code
+ ..selection = TextSelection.collapsed(offset: widget.code.length);
+ });
+ }
+
+ Future<void> _saveCode() async {
+ if (!_canSave) {
+ return;
+ }
+ final newCode = _trimmedInput.toUpperCase();
+ setState(() {
+ _isSaving = true;
+ });
+ try {
+ await storageBonusService.updateCode(newCode);
+ if (!mounted) {
+ return;
+ }
+ setState(() {
+ _isEditing = false;
+ _isSaving = false;
+ });
+ _focusNode.unfocus();
+ widget.onCodeChanged(newCode);
+ } catch (e, s) {
+ _logger.severe("Failed to update code", e, s);
+ if (!mounted) {
+ return;
+ }
+ final statusCode = e is DioException ? e.response?.statusCode : null;
+ if (statusCode == 400 || statusCode == 429) {
+ setState(() {
+ _isSaving = false;
+ _errorText = statusCode == 400
+ ? context.strings.unavailableReferralCode
+ : context.strings.codeChangeLimitReached;
+ });
+ _focusNode.requestFocus();
+ return;
+ }
+ await showGenericErrorDialog(context: context, error: e);
+ if (mounted) {
+ setState(() {
+ _isSaving = false;
+ });
+ _focusNode.requestFocus();
+ }
+ }
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return CenteredConstrainedComponent(
+ child: LayoutBuilder(
+ builder: (context, constraints) {
+ final width = constraints.maxWidth;
+ return ClipRRect(
+ borderRadius: BorderRadius.circular(22),
child: Container(
- decoration: BoxDecoration(
- color: colors.fillLight,
- borderRadius: BorderRadius.circular(Radii.lg),
+ width: width,
+ color: context.componentColors.primary,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [_artwork(width, width / 341), _codePanel(width)],
),
- padding: const EdgeInsets.symmetric(
- horizontal: 36,
- vertical: Spacing.xl,
+ ),
+ );
+ },
+ ),
+ );
+ }
+
+ Widget _artwork(double width, double scale) {
+ return SizedBox(
+ width: width,
+ height: 124 * scale,
+ child: Stack(
+ clipBehavior: Clip.hardEdge,
+ children: [
+ Positioned(
+ top: 0,
+ left: 0,
+ right: 0,
+ height: 213 * scale,
+ child: Image.asset(
+ "assets/referral_card_lines.png",
+ fit: BoxFit.fill,
+ excludeFromSemantics: true,
+ ),
+ ),
+ Positioned.fill(
+ child: ExcludeSemantics(
+ child: rive.RiveWidgetBuilder(
+ fileLoader: _artworkLoader,
+ builder: (BuildContext context, rive.RiveState state) {
+ if (state is rive.RiveLoaded) {
+ return Transform.translate(
+ offset: Offset(0, 32 * scale),
+ child: Transform.scale(
+ scale: 1.27,
+ alignment: Alignment.bottomRight,
+ child: rive.RiveWidget(
+ controller: state.controller,
+ fit: rive.Fit.cover,
+ ),
+ ),
+ );
+ }
+ return const SizedBox.shrink();
+ },
),
- child: Text(
- codeValue,
- style: TextStyles.body.copyWith(color: colors.primary),
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+
+ Widget _codePanel(double width) {
+ final colors = context.componentColors;
+ return Container(
+ width: width,
+ color: const Color(0xFF0F0F0F),
+ child: Stack(
+ children: [
+ ConstrainedBox(
+ constraints: const BoxConstraints(minHeight: 89),
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 48, vertical: 14),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ mainAxisAlignment: MainAxisAlignment.center,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ _label(colors),
+ const SizedBox(height: Spacing.sm),
+ _codeArea(colors),
+ ],
),
),
),
+ Positioned(right: 0, bottom: 0, child: _action(colors)),
+ ],
+ ),
+ );
+ }
+
+ Widget _label(ColorTokens colors) {
+ final labelText = _errorText ?? context.strings.yourReferralCode;
+ return FittedBox(
+ fit: BoxFit.scaleDown,
+ child: Text(
+ labelText.toUpperCase(),
+ maxLines: 1,
+ semanticsLabel: labelText,
+ style: TextStyles.mini.copyWith(
+ fontSize: 8,
+ letterSpacing: 1.8,
+ color: _errorText != null
+ ? colors.warning
+ : colors.specialWhite.withValues(alpha: 0.55),
),
- if (shouldShowEdit)
- Positioned(
- right: 0,
- bottom: 0,
- child: GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: () {
- if (userDetails!.isPartOfFamily() &&
- !userDetails!.isFamilyAdmin()) {
- final String familyAdmin = userDetails!.familyData!.members!
- .firstWhere((element) => element.isAdmin)
- .email;
- showInfoDialog(
- context,
- title: context.strings.error,
- body: context.strings.onlyFamilyAdminCanChangeCode(
- familyAdminEmail: familyAdmin,
- ),
- icon: Icons.error,
- );
- } else {
- showChangeReferralCodeSheet(
- context,
- currentCode: codeValue,
- onCodeChanged: () => notifyParent?.call(),
- );
- }
- },
- child: Padding(
- padding: const EdgeInsets.all(tapPadding),
+ ),
+ );
+ }
+
+ Widget _codeArea(ColorTokens colors) {
+ final codeStyle = TextStyles.display2.copyWith(color: colors.specialWhite);
+ if (!_isEditing) {
+ return FittedBox(
+ fit: BoxFit.scaleDown,
+ child: Text(widget.code, maxLines: 1, style: codeStyle),
+ );
+ }
+ return TextField(
+ controller: _controller,
+ focusNode: _focusNode,
+ autofocus: true,
+ readOnly: _isSaving,
+ maxLines: 1,
+ textAlign: TextAlign.center,
+ textInputAction: TextInputAction.done,
+ textCapitalization: TextCapitalization.characters,
+ autocorrect: false,
+ enableSuggestions: false,
+ inputFormatters: [
+ FilteringTextInputFormatter.allow(RegExp("[a-zA-Z0-9]")),
+ LengthLimitingTextInputFormatter(20),
+ ],
+ style: codeStyle,
+ cursorColor: colors.primary,
+ cursorWidth: 2,
+ onChanged: _handleTextChanged,
+ onEditingComplete: _saveCode,
+ onTapOutside: (_) => _focusNode.unfocus(),
+ decoration: const InputDecoration(
+ isDense: true,
+ isCollapsed: true,
+ contentPadding: EdgeInsets.zero,
+ border: InputBorder.none,
+ enabledBorder: InputBorder.none,
+ focusedBorder: InputBorder.none,
+ disabledBorder: InputBorder.none,
+ errorBorder: InputBorder.none,
+ focusedErrorBorder: InputBorder.none,
+ ),
+ );
+ }
+
+ Widget _action(ColorTokens colors) {
+ final l10n = context.strings;
+ final enabled = _isEditing ? _canSave : true;
+ final actionLabel = _isSaving
+ ? l10n.saving
+ : _isEditing
+ ? l10n.saveCode
+ : l10n.edit;
+ return TextFieldTapRegion(
+ child: Semantics(
+ button: true,
+ enabled: enabled,
+ label: actionLabel,
+ child: Tooltip(
+ message: actionLabel,
+ child: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: _isEditing ? (_canSave ? _saveCode : null) : _handleEditTap,
+ child: SizedBox.square(
+ dimension: 48,
+ child: Align(
+ alignment: Alignment.bottomRight,
child: Container(
+ width: 41,
+ height: 41,
+ alignment: Alignment.center,
decoration: BoxDecoration(
- color: colors.primary,
- shape: BoxShape.circle,
- ),
- padding: const EdgeInsets.all(6),
- child: HugeIcon(
- icon: HugeIcons.strokeRoundedEdit03,
- color: colors.specialWhite,
- size: 12,
+ color: colors.specialWhiteOverlay,
+ borderRadius: const BorderRadius.only(
+ topLeft: Radius.circular(21),
+ bottomRight: Radius.circular(21),
+ ),
),
+ child: _isSaving
+ ? EnteLoadingWidget(
+ color: colors.specialWhite,
+ size: 16,
+ padding: 0,
+ )
+ : HugeIcon(
+ icon: _isEditing
+ ? HugeIcons.strokeRoundedTick02
+ : HugeIcons.strokeRoundedEdit03,
+ color: enabled
+ ? colors.specialWhite
+ : colors.specialWhite.withValues(alpha: 0.4),
+ size: 22,
+ strokeWidth: 1.7,
+ ),
),
),
),
),
- ],
+ ),
+ ),
);
}
}
diff --git a/mobile/apps/photos/lib/ui/growth/referral_screen.dart b/mobile/apps/photos/lib/ui/growth/referral_screen.dart
index c4b752139d..a112f3fda0 100644
--- a/mobile/apps/photos/lib/ui/growth/referral_screen.dart
+++ b/mobile/apps/photos/lib/ui/growth/referral_screen.dart
@@ -3,7 +3,6 @@ import "package:ente_pure_utils/ente_pure_utils.dart";
import "package:ente_strings/ente_strings.dart";
import "package:ente_ui/components/loading_widget.dart";
import "package:flutter/material.dart";
-import "package:hugeicons/hugeicons.dart";
import "package:photos/gateways/storage_bonus/models/storage_bonus.dart";
import "package:photos/models/user_details.dart";
import "package:photos/service_locator.dart";
@@ -23,11 +22,9 @@ class ReferralScreen extends StatefulWidget {
}
class _ReferralScreenState extends State<ReferralScreen> {
- bool canApplyCode = true;
-
void _safeUIUpdate() {
if (mounted) {
- setState(() => {});
+ setState(() {});
}
}
@@ -48,33 +45,12 @@ class _ReferralScreenState extends State<ReferralScreen> {
future: _fetchData(),
builder: (context, snapshot) {
if (snapshot.hasData) {
- final referralView = snapshot.data!.item1;
return SettingsPageScaffold(
title: l10n.earnFreeStorage,
subtitle: l10n.shareCodeEarnStorage,
- actions: [
- if (referralView.planInfo.isEnabled)
- IconButtonComponent(
- variant: IconButtonComponentVariant.primary,
- 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: [
ReferralWidget(
- referralView: referralView,
+ referralView: snapshot.data!.item1,
userDetails: snapshot.data!.item2,
notifyParent: _safeUIUpdate,
),
@@ -125,7 +101,7 @@ class _ReferralScreenState extends State<ReferralScreen> {
class ReferralWidget extends StatelessWidget {
final ReferralView referralView;
final UserDetails userDetails;
- final Function notifyParent;
+ final VoidCallback notifyParent;
const ReferralWidget({
required this.referralView,
@@ -145,17 +121,31 @@ class ReferralWidget extends StatelessWidget {
children: [
if (isReferralEnabled) ...[
const SizedBox(height: Spacing.xxl),
- Center(
- child: ReferralCodeWidget(
- referralView.code,
- shouldShowEdit: true,
- userDetails: userDetails,
- notifyParent: notifyParent,
- ),
+ ReferralCodeWidget(
+ code: referralView.code,
+ userDetails: userDetails,
+ onCodeChanged: (code) {
+ referralView.code = code;
+ notifyParent();
+ },
),
- const SizedBox(height: Spacing.xl),
+ const SizedBox(height: Spacing.md),
_buildInstructions(context),
- const SizedBox(height: Spacing.xxl),
+ const SizedBox(height: Spacing.md),
+ ButtonComponent(
+ label: l10n.share,
+ density: ButtonComponentDensity.compact,
+ shouldSurfaceExecutionStates: false,
+ onTap: () {
+ shareText(
+ l10n.shareTextReferralCode(
+ referralCode: referralView.code,
+ referralStorageInGB: referralView.planInfo.storageInGB,
+ ),
+ );
+ },
+ ),
+ const SizedBox(height: 40),
] else ...[
Padding(
padding: const EdgeInsets.symmetric(vertical: 48),
@@ -189,26 +179,26 @@ class ReferralWidget extends StatelessWidget {
const SizedBox(height: Spacing.sm),
],
MenuComponent(
- title: l10n.faq,
+ title: l10n.details,
trailing: _chevron(colors),
onTap: () async {
await routeToPage(
context,
- WebPage(
- l10n.faq,
- "https://ente.com/help/photos/features/account/referral-program/",
- ),
+ StorageDetailsScreen(referralView, userDetails),
);
},
),
const SizedBox(height: Spacing.sm),
MenuComponent(
- title: l10n.details,
+ title: l10n.faqs,
trailing: _chevron(colors),
onTap: () async {
await routeToPage(
context,
- StorageDetailsScreen(referralView, userDetails),
+ WebPage(
+ l10n.faqs,
+ "https://ente.com/help/photos/features/account/referral-program/",
+ ),
);
},
),
@@ -230,25 +220,32 @@ class ReferralWidget extends StatelessWidget {
color: colors.textLight,
height: 2,
);
- final step3Text = context.strings.referralStep3(storageInGB: storageInGB);
+
+ final highlightTokens = [
+ "$storageInGB GB free",
+ "${storageInGB}GB free",
+ "$storageInGB GB",
+ "${storageInGB}GB",
+ ];
+
+ Widget step(String text) => Text.rich(
+ TextSpan(
+ style: mutedStyle,
+ children: _buildHighlightedSpans(
+ text,
+ mutedStyle,
+ colors.textBase,
+ highlightTokens,
+ ),
+ ),
+ );
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(context.strings.referralStep1, style: mutedStyle),
- Text(context.strings.referralStep2, style: mutedStyle),
- RichText(
- text: TextSpan(
- style: mutedStyle,
- children: _buildHighlightedSpans(
- step3Text,
- mutedStyle,
- colors.primary,
- ["${storageInGB}GB free", "$storageInGB GB free"],
- ["${storageInGB}GB", "$storageInGB GB"],
- ),
- ),
- ),
+ step(context.strings.referralStep2(storageInGB: storageInGB)),
+ step(context.strings.referralStep3(storageInGB: storageInGB)),
],
);
}
@@ -257,19 +254,16 @@ class ReferralWidget extends StatelessWidget {
String text,
TextStyle baseStyle,
Color highlightColor,
- List<String> preferredTokens,
- List<String> fallbackTokens,
+ List<String> tokens,
) {
- final tokens = preferredTokens.any(text.contains)
- ? preferredTokens
- : fallbackTokens.any(text.contains)
- ? fallbackTokens
- : const <String>[];
-
- if (tokens.isEmpty) {
+ if (!tokens.any(text.contains)) {
return [TextSpan(text: text)];
}
+ final highlightStyle = baseStyle.copyWith(
+ color: highlightColor,
+ fontWeight: FontWeight.w600,
+ );
final spans = <TextSpan>[];
var index = 0;
@@ -295,12 +289,7 @@ class ReferralWidget extends StatelessWidget {
spans.add(TextSpan(text: text.substring(index, nextIndex)));
}
- spans.add(
- TextSpan(
- text: nextToken,
- style: baseStyle.copyWith(color: highlightColor),
- ),
- );
+ spans.add(TextSpan(text: nextToken, style: highlightStyle));
index = nextIndex + nextToken.length;
}
diff --git a/mobile/packages/strings/lib/l10n/arb/strings_en.arb b/mobile/packages/strings/lib/l10n/arb/strings_en.arb
index 0188ec711b..8b0b2a0251 100644
--- a/mobile/packages/strings/lib/l10n/arb/strings_en.arb
+++ b/mobile/packages/strings/lib/l10n/arb/strings_en.arb
@@ -1263,7 +1263,7 @@
}
},
"earned": "earned",
- "earnFreeStorage": "Earn free storage",
+ "earnFreeStorage": "Get free storage",
"earnMoreSpace": "Earn more space!",
"edit": "Edit",
"editAutoAddPeople": "Edit auto-add people",
@@ -3281,9 +3281,14 @@
"referrals": "Referrals",
"referralsAreCurrentlyPaused": "Referrals are currently paused",
"referralStats": "Referral stats",
- "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.",
+ "referralStep1": "1. Share your code with friends",
+ "referralStep2": "2. They get {storageInGB} GB free on sign up",
+ "@referralStep2": {
+ "placeholders": {
+ "storageInGB": {}
+ }
+ },
+ "referralStep3": "3. You get {storageInGB} GB free when they upgrade",
"@referralStep3": {
"placeholders": {
"storageInGB": {}
@@ -3888,7 +3893,7 @@
"share": "Share",
"shareALink": "Share a link",
"shareAnAlbum": "Share an album",
- "shareCodeEarnStorage": "Share your code, earn storage.",
+ "shareCodeEarnStorage": "Double your storage on Ente",
"shareCodes": "Share codes",
"shareCodesDuration": "Select the duration for which you want to share codes.",
"shareCollection": "Share collection",
@@ -3941,7 +3946,7 @@
"shareTextRecommendUsingEnte": "Download Ente so we can easily share original quality files\n\nhttps://ente.com",
"shareTextRecommendUsingEnteForFamily": "Download Ente so I can add you to my family plan\n\nhttps://ente.com",
"shareTextRecommendUsingEnteForPhotos": "Download Ente so we can easily share original quality photos and videos\n\nhttps://ente.com",
- "shareTextReferralCode": "Ente Photos is a private and safe home for your photos\n* Download Ente Photos from https://ente.com/app\n* Create an account\n* Apply the referral code {referralCode} in Settings->Referral\n* Get extra {referralStorageInGB} GB free!",
+ "shareTextReferralCode": "Get {referralStorageInGB} GB free!\nDownload Ente Photos from https://ente.com/app and apply code {referralCode}.",
"@shareTextReferralCode": {
"placeholders": {
"referralCode": {},
@@ -4405,7 +4410,7 @@
},
"unarchiveAlbum": "Unarchive album",
"unarchiving": "Unarchiving...",
- "unavailableReferralCode": "Sorry, this code is unavailable.",
+ "unavailableReferralCode": "This code is already taken",
"uncategorized": "Uncategorized",
"uncategorizedItemsWillShowUpHere": "Uncategorized items will show up here",
"undo": "Undo",
@@ -4766,6 +4771,7 @@
"yourPlanWasSuccessfullyDowngraded": "Your plan was successfully downgraded",
"yourPlanWasSuccessfullyUpgraded": "Your plan was successfully upgraded",
"yourPurchaseWasSuccessful": "Your purchase was successful",
+ "yourReferralCode": "Your referral code",
"yourSubscriptionHasExpired": "Your subscription has expired",
"yourSubscriptionWasUpdatedSuccessfully": "Your subscription was updated successfully",
"yourTrashIsEmpty": "Your trash is empty",