Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] Restore referral navigation behavior

Aman4a4e178ac7c5
diff --git a/mobile/apps/photos/lib/ui/growth/apply_code_screen.dart b/mobile/apps/photos/lib/ui/growth/apply_code_screen.dart
index 87ad48db06..8df28963d0 100644
--- a/mobile/apps/photos/lib/ui/growth/apply_code_screen.dart
+++ b/mobile/apps/photos/lib/ui/growth/apply_code_screen.dart
@@ -25,7 +25,6 @@ class _ApplyCodeScreenState extends State<ApplyCodeScreen> {
late FocusNode textFieldFocusNode;
String code = "";
- bool _isApplying = false;
@override
void initState() {
@@ -59,21 +58,20 @@ class _ApplyCodeScreenState extends State<ApplyCodeScreen> {
focusNode: textFieldFocusNode,
autofocus: true,
inputFormatters: [UpperCaseTextFormatter()],
- textCapitalization: TextCapitalization.characters,
+ textCapitalization: TextCapitalization.sentences,
hintText: l10n.enterReferralCode,
autocorrect: false,
- keyboardType: TextInputType.text,
- textInputAction: TextInputAction.done,
+ keyboardType: TextInputType.emailAddress,
+ textInputAction: TextInputAction.next,
onChanged: (value) {
setState(() => code = value.trim());
},
- onSubmit: (_) => _applyCode(),
),
const SizedBox(height: Spacing.xl),
ButtonComponent(
label: l10n.apply,
variant: ButtonComponentVariant.primary,
- isDisabled: _isApplying || code.trim().length < 4,
+ isDisabled: code.trim().length < 4,
shouldShowSuccessState: false,
onTap: _applyCode,
),
@@ -82,8 +80,6 @@ class _ApplyCodeScreenState extends State<ApplyCodeScreen> {
}
Future<void> _applyCode() async {
- if (_isApplying || code.trim().length < 4) return;
- setState(() => _isApplying = true);
try {
await storageBonusService.applyCode(code);
if (!mounted) return;
@@ -101,8 +97,6 @@ class _ApplyCodeScreenState extends State<ApplyCodeScreen> {
exception: e as Exception,
apiErrorPrefix: AppLocalizations.of(context).failedToApplyCode,
);
- } finally {
- if (mounted) setState(() => _isApplying = false);
}
}
}
diff --git a/mobile/apps/photos/lib/ui/growth/referral_screen.dart b/mobile/apps/photos/lib/ui/growth/referral_screen.dart
index c6e626dbc9..c3c285a702 100644
--- a/mobile/apps/photos/lib/ui/growth/referral_screen.dart
+++ b/mobile/apps/photos/lib/ui/growth/referral_screen.dart
@@ -48,56 +48,75 @@ class _ReferralScreenState extends State<ReferralScreen> {
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(
- variant: IconButtonComponentVariant.primary,
- icon: HugeIcon(
- icon: HugeIcons.strokeRoundedShare08,
- color: context.componentColors.iconColor,
+ 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,
+ ),
+ );
+ },
),
- tooltip: l10n.share,
- shouldSurfaceExecutionStates: false,
- onTap: () {
- shareText(
- l10n.shareTextReferralCode(
- referralCode: referralView!.code,
- referralStorageInGB: referralView.planInfo.storageInGB,
- ),
- );
- },
- ),
- ],
- children: [
- if (snapshot.hasData)
+ ],
+ children: [
ReferralWidget(
- referralView: referralView!,
+ referralView: referralView,
userDetails: snapshot.data!.item2,
notifyParent: _safeUIUpdate,
- )
- 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,
+ ),
+ ],
+ );
+ } else if (snapshot.hasError) {
+ return Scaffold(
+ body: SafeArea(
+ child: 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: context.componentColors.iconColor,
+ size: 24,
+ ),
),
- textAlign: TextAlign.center,
- ),
+ Expanded(
+ child: Center(
+ child: Text(
+ l10n.failedToFetchReferralDetails,
+ style: TextStyles.body.copyWith(
+ color: context.componentColors.textLight,
+ ),
+ textAlign: TextAlign.center,
+ ),
+ ),
+ ),
+ ],
),
- )
- else
- const Padding(
- padding: EdgeInsets.symmetric(vertical: 80),
- child: Center(child: EnteLoadingWidget()),
),
- ],
+ ),
+ );
+ }
+ return const Scaffold(
+ body: SafeArea(child: Center(child: EnteLoadingWidget())),
);
},
);