Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] Move password and recovery pages onto the onboarding scaffold

r4khul0aa26f36e608
diff --git a/mobile/apps/photos/lib/ui/account/login_pwd_verification_page.dart b/mobile/apps/photos/lib/ui/account/login_pwd_verification_page.dart
index 705ff239d6..aae19fa5d2 100644
--- a/mobile/apps/photos/lib/ui/account/login_pwd_verification_page.dart
+++ b/mobile/apps/photos/lib/ui/account/login_pwd_verification_page.dart
@@ -8,6 +8,7 @@ import "package:logging/logging.dart";
import 'package:photos/core/configuration.dart';
import "package:photos/gateways/users/models/srp.dart";
import "package:photos/services/account/user_service.dart";
+import "package:photos/ui/account/onboarding_page_scaffold.dart";
import "package:photos/ui/components/buttons/button_widget.dart"
show ButtonAction;
import "package:photos/utils/dialog_util.dart";
@@ -28,6 +29,7 @@ class _LoginPasswordVerificationPageState
final _passwordController = TextEditingController();
String? email;
bool _hasPassword = false;
+ bool _isPasswordIncorrect = false;
final Logger _logger = Logger("LoginPasswordVerificationPage");
@override
@@ -48,39 +50,19 @@ class _LoginPasswordVerificationPageState
@override
Widget build(BuildContext context) {
- final colors = context.componentColors;
-
- return Scaffold(
- resizeToAvoidBottomInset: true,
- backgroundColor: colors.backgroundBase,
- appBar: AppBar(
- elevation: 0,
- scrolledUnderElevation: 0,
- backgroundColor: colors.backgroundBase,
- leading: IconButton(
- icon: const Icon(Icons.arrow_back),
- color: colors.iconColor,
- onPressed: () {
- Navigator.of(context).pop();
- },
- ),
- title: Text(
- context.strings.enterPassword,
- style: TextStyles.large.copyWith(color: colors.textBase),
- ),
- centerTitle: true,
- ),
+ return OnboardingPageScaffold(
+ title: context.strings.enterPassword,
+ illustration: OnboardingIllustration.password,
body: _getBody(),
- floatingActionButton: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: ButtonComponent(
+ actions: [
+ ButtonComponent(
key: const ValueKey("verifyPasswordButton"),
label: context.strings.logInLabel,
+ shouldShowSuccessState: false,
isDisabled: !_hasPassword,
onTap: _verifyEnteredPassword,
),
- ),
- floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
+ ],
);
}
@@ -94,10 +76,10 @@ class _LoginPasswordVerificationPageState
Widget _getBody() {
return AutofillGroup(
- child: ListView(
- padding: const EdgeInsets.symmetric(horizontal: 16),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
children: [
- const SizedBox(height: 24),
Visibility(
visible: false,
child: TextFormField(
@@ -119,21 +101,28 @@ class _LoginPasswordVerificationPageState
autofocus: true,
shouldUnfocusOnClearOrSubmit: true,
onSubmit: (_) => _verifyEnteredPassword(),
+ message: _isPasswordIncorrect
+ ? context.strings.incorrectPasswordTitle
+ : null,
+ messageType: _isPasswordIncorrect
+ ? TextInputComponentMessageType.alert
+ : TextInputComponentMessageType.helper,
onChanged: (value) {
final hasPassword = value.isNotEmpty;
- if (_hasPassword != hasPassword) {
+ if (_hasPassword != hasPassword || _isPasswordIncorrect) {
setState(() {
_hasPassword = hasPassword;
+ _isPasswordIncorrect = false;
});
}
},
),
- const SizedBox(height: 12),
+ const SizedBox(height: Spacing.md),
Align(
alignment: Alignment.centerRight,
child: ButtonComponent(
variant: ButtonComponentVariant.link,
- label: context.strings.forgotPassword,
+ label: context.strings.forgotPasswordPrompt,
size: ButtonComponentSize.small,
onTap: () async {
await UserService.instance.sendOtt(
@@ -176,12 +165,10 @@ class _LoginPasswordVerificationPageState
await dialog.hide();
if (e.response != null && e.response!.statusCode == 401) {
_logger.severe('server reject, failed verify SRP login', e, s);
- if (!context.mounted) return;
- await _showContactSupportDialog(
- context,
- context.strings.incorrectPasswordTitle,
- context.strings.pleaseTryAgain,
- );
+ if (!mounted) return;
+ setState(() {
+ _isPasswordIncorrect = true;
+ });
} else {
_logger.severe('API failure during SRP login ${e.type}', e, s);
if (e.type == DioExceptionType.connectionTimeout ||
diff --git a/mobile/apps/photos/lib/ui/account/password_entry_page.dart b/mobile/apps/photos/lib/ui/account/password_entry_page.dart
index 3d067c400c..16a4d17497 100644
--- a/mobile/apps/photos/lib/ui/account/password_entry_page.dart
+++ b/mobile/apps/photos/lib/ui/account/password_entry_page.dart
@@ -12,6 +12,7 @@ import 'package:photos/events/account_configured_event.dart';
import 'package:photos/events/subscription_purchased_event.dart';
import "package:photos/gateways/users/models/key_gen_result.dart";
import 'package:photos/services/account/user_service.dart';
+import "package:photos/ui/account/onboarding_page_scaffold.dart";
import 'package:photos/ui/account/recovery_key_page.dart';
import 'package:photos/ui/common/web_page.dart';
import "package:photos/ui/components/alert_bottom_sheet.dart";
@@ -87,6 +88,14 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
final isFormValid = _passwordsMatch && _isPasswordValid;
+ if (_volatilePassword != null) {
+ return OnboardingPageScaffold(
+ title: title,
+ illustration: OnboardingIllustration.recoveryKey,
+ body: const SizedBox.shrink(),
+ );
+ }
+
return Scaffold(
resizeToAvoidBottomInset: true,
backgroundColor: colors.backgroundBase,
@@ -109,9 +118,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
),
centerTitle: true,
),
- body: _volatilePassword != null
- ? const SizedBox.shrink()
- : _getBody(title: title, isFormValid: isFormValid),
+ body: _getBody(title: title, isFormValid: isFormValid),
);
}
diff --git a/mobile/apps/photos/lib/ui/account/password_reentry_page.dart b/mobile/apps/photos/lib/ui/account/password_reentry_page.dart
index 73bf414ade..799de553df 100644
--- a/mobile/apps/photos/lib/ui/account/password_reentry_page.dart
+++ b/mobile/apps/photos/lib/ui/account/password_reentry_page.dart
@@ -12,12 +12,12 @@ import 'package:photos/core/event_bus.dart';
import 'package:photos/events/subscription_purchased_event.dart';
import "package:photos/service_locator.dart";
import "package:photos/services/account/user_service.dart";
+import "package:photos/ui/account/onboarding_page_scaffold.dart";
import 'package:photos/ui/account/recovery_page.dart';
import 'package:photos/ui/components/buttons/button_widget.dart'
show ButtonAction;
import 'package:photos/ui/tabs/home_widget.dart';
import 'package:photos/utils/dialog_util.dart';
-import 'package:photos/utils/email_util.dart';
class PasswordReentryPage extends StatefulWidget {
const PasswordReentryPage({super.key});
@@ -31,6 +31,7 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
final _passwordController = TextEditingController();
String? email;
String? _volatilePassword;
+ bool _isPasswordIncorrect = false;
@override
void initState() {
@@ -51,40 +52,21 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
@override
Widget build(BuildContext context) {
- final colors = context.componentColors;
final isFormValid = _passwordController.text.isNotEmpty;
- return Scaffold(
- resizeToAvoidBottomInset: true,
- backgroundColor: colors.backgroundBase,
- appBar: AppBar(
- elevation: 0,
- scrolledUnderElevation: 0,
- backgroundColor: colors.backgroundBase,
- leading: IconButton(
- icon: const Icon(Icons.arrow_back),
- color: colors.iconColor,
- onPressed: () {
- Navigator.of(context).pop();
- },
- ),
- title: Text(
- context.strings.enterPassword,
- style: TextStyles.large.copyWith(color: colors.textBase),
- ),
- centerTitle: true,
- ),
+ return OnboardingPageScaffold(
+ title: context.strings.enterPassword,
+ illustration: OnboardingIllustration.password,
body: _getBody(),
- floatingActionButton: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: ButtonComponent(
+ actions: [
+ ButtonComponent(
key: const ValueKey("verifyPasswordButton"),
label: context.strings.logInLabel,
+ shouldShowSuccessState: false,
isDisabled: !isFormValid,
onTap: isFormValid ? _onVerifyPasswordPressed : null,
),
- ),
- floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
+ ],
);
}
@@ -133,22 +115,9 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
_logger.warning("Password verification failed: $e");
await dialog.hide();
if (!mounted) return;
- final dialogChoice = await showChoiceDialog(
- context,
- title: context.strings.incorrectPasswordTitle,
- body: context.strings.pleaseTryAgain,
- firstButtonLabel: context.strings.contactSupport,
- secondButtonLabel: context.strings.ok,
- );
- if (dialogChoice?.action == ButtonAction.first) {
- if (!mounted) return;
- await sendLogs(
- context,
- context.strings.contactSupport,
- postShare: () {},
- );
- }
+ setState(() {
+ _isPasswordIncorrect = true;
+ });
return;
}
await dialog.hide();
@@ -189,81 +158,84 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
}
Widget _getBody() {
- return SafeArea(
- child: AutofillGroup(
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
+ return AutofillGroup(
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Visibility(
+ // Give autofill the account email to pair with the password.
+ visible: false,
+ child: TextFormField(
+ autofillHints: const [AutofillHints.email],
+ autocorrect: false,
+ keyboardType: TextInputType.emailAddress,
+ initialValue: email,
+ textInputAction: TextInputAction.next,
+ ),
+ ),
+ TextInputComponent(
+ key: const ValueKey("passwordInputField"),
+ label: context.strings.password,
+ isRequired: true,
+ hintText: context.strings.enterYourPassword,
+ controller: _passwordController,
+ isPasswordInput: true,
+ autocorrect: false,
+ shouldUnfocusOnClearOrSubmit: true,
+ onSubmit: _passwordController.text.isNotEmpty
+ ? (_) => _onVerifyPasswordPressed()
+ : null,
+ message: _isPasswordIncorrect
+ ? context.strings.incorrectPasswordTitle
+ : null,
+ messageType: _isPasswordIncorrect
+ ? TextInputComponentMessageType.alert
+ : TextInputComponentMessageType.helper,
+ onChanged: (value) {
+ setState(() {
+ _isPasswordIncorrect = false;
+ });
+ },
+ ),
+ const SizedBox(height: Spacing.md),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
- const SizedBox(height: 12),
- Visibility(
- // Give autofill the account email to pair with the password.
- visible: false,
- child: TextFormField(
- autofillHints: const [AutofillHints.email],
- autocorrect: false,
- keyboardType: TextInputType.emailAddress,
- initialValue: email,
- textInputAction: TextInputAction.next,
- ),
- ),
- TextInputComponent(
- key: const ValueKey("passwordInputField"),
- label: context.strings.password,
- isRequired: true,
- hintText: context.strings.enterYourPassword,
- controller: _passwordController,
- isPasswordInput: true,
- autocorrect: false,
- shouldUnfocusOnClearOrSubmit: true,
- onSubmit: _passwordController.text.isNotEmpty
- ? (_) => _onVerifyPasswordPressed()
- : null,
- onChanged: (value) {
- setState(() {});
+ ButtonComponent(
+ variant: ButtonComponentVariant.link,
+ label: context.strings.changeEmail,
+ size: ButtonComponentSize.small,
+ onTap: () async {
+ final dialog = createProgressDialog(
+ context,
+ context.strings.pleaseWait,
+ );
+ await dialog.show();
+ await Configuration.instance.logout();
+ await dialog.hide();
+ if (!mounted) return;
+ Navigator.of(context).popUntil((route) => route.isFirst);
},
),
- const SizedBox(height: 16),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- ButtonComponent(
- variant: ButtonComponentVariant.link,
- label: context.strings.changeEmail,
- size: ButtonComponentSize.small,
- onTap: () async {
- final dialog = createProgressDialog(
- context,
- context.strings.pleaseWait,
- );
- await dialog.show();
- await Configuration.instance.logout();
- await dialog.hide();
- if (!mounted) return;
- Navigator.of(context).popUntil((route) => route.isFirst);
- },
- ),
- ButtonComponent(
- variant: ButtonComponentVariant.link,
- label: context.strings.forgotPassword,
- size: ButtonComponentSize.small,
- onTap: () async {
- // ignore: unawaited_futures
- Navigator.of(context).push(
- MaterialPageRoute(
- builder: (BuildContext context) {
- return const RecoveryPage(isForgotPassword: true);
- },
- ),
- );
- },
- ),
- ],
+ ButtonComponent(
+ variant: ButtonComponentVariant.link,
+ label: context.strings.forgotPasswordPrompt,
+ size: ButtonComponentSize.small,
+ onTap: () async {
+ // ignore: unawaited_futures
+ Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return const RecoveryPage(isForgotPassword: true);
+ },
+ ),
+ );
+ },
),
],
),
- ),
+ ],
),
);
}
diff --git a/mobile/apps/photos/lib/ui/account/recovery_key_page.dart b/mobile/apps/photos/lib/ui/account/recovery_key_page.dart
index 1969d7d128..d6773ca2e3 100644
--- a/mobile/apps/photos/lib/ui/account/recovery_key_page.dart
+++ b/mobile/apps/photos/lib/ui/account/recovery_key_page.dart
@@ -9,6 +9,7 @@ import 'package:flutter/services.dart';
import 'package:hugeicons/hugeicons.dart';
import 'package:photos/core/configuration.dart';
import 'package:photos/core/constants.dart';
+import "package:photos/ui/account/onboarding_page_scaffold.dart";
import 'package:photos/ui/notification/toast.dart';
import 'package:photos/utils/share_util.dart';
import 'package:share_plus/share_plus.dart';
@@ -53,6 +54,24 @@ class _RecoveryKeyPageState extends State<RecoveryKeyPage> {
);
}
+ if (widget.isOnboarding) {
+ return OnboardingPageScaffold(
+ title: widget.title ?? context.strings.recoveryKey,
+ illustration: OnboardingIllustration.recoveryKey,
+ showBackButton: false,
+ isBodyCentered: true,
+ body: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ _buildDescription(recoveryKey, spacing: Spacing.sm),
+ const SizedBox(height: Spacing.lg),
+ _buildKeyCard(recoveryKey),
+ ],
+ ),
+ actions: [ButtonComponent(label: widget.doneText, onTap: _saveKeys)],
+ );
+ }
+
return Scaffold(
backgroundColor: colors.backgroundBase,
appBar: AppBar(
@@ -64,120 +83,109 @@ class _RecoveryKeyPageState extends State<RecoveryKeyPage> {
),
centerTitle: true,
backgroundColor: colors.backgroundBase,
- leading: widget.isOnboarding
- ? const SizedBox.shrink()
- : IconButton(
- icon: const Icon(Icons.arrow_back),
- color: colors.iconColor,
- onPressed: () {
- Navigator.of(context).pop();
- },
- ),
+ leading: IconButton(
+ icon: const Icon(Icons.arrow_back),
+ color: colors.iconColor,
+ onPressed: () {
+ Navigator.of(context).pop();
+ },
+ ),
+ ),
+ body: SafeArea(
+ child: SingleChildScrollView(
+ padding: const EdgeInsets.symmetric(horizontal: 16),
+ child: Column(
+ children: [
+ const SizedBox(height: 16),
+ Image.asset('assets/recovery_key.png', width: 100, height: 100),
+ const SizedBox(height: 24),
+ _buildDescription(recoveryKey, spacing: Spacing.xl),
+ const SizedBox(height: Spacing.xl),
+ _buildKeyCard(recoveryKey),
+ ],
+ ),
+ ),
),
- body: SafeArea(child: _getBody(recoveryKey)),
);
}
- Widget _getBody(String recoveryKey) {
+ Widget _buildDescription(String recoveryKey, {required double spacing}) {
+ final colors = context.componentColors;
+ return Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Text(
+ widget.text ?? context.strings.recoveryKeyOnForgotPassword,
+ textAlign: TextAlign.center,
+ style: TextStyles.body.copyWith(color: colors.textBase),
+ ),
+ SizedBox(height: spacing),
+ Text(
+ widget.subText ?? context.strings.recoveryKeySaveShortDescription,
+ textAlign: TextAlign.center,
+ style: TextStyles.body.copyWith(color: colors.textLight),
+ ),
+ ],
+ );
+ }
+
+ // Figma: https://www.figma.com/design/BuBNPPytxlVnqfmCUW0mgz/Ente-Visual-Design?node-id=25356-307349&m=dev
+ Widget _buildKeyCard(String recoveryKey) {
final colors = context.componentColors;
final lightComponentTheme = ComponentTheme.lightTheme(
app: ComponentApp.photos,
);
- return Column(
- children: [
- Expanded(
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: Column(
- children: [
- const SizedBox(height: 16),
- Center(
- child: Image.asset(
- 'assets/recovery_key.png',
- width: 100,
- height: 100,
- ),
- ),
- const SizedBox(height: 24),
- Text(
- widget.text ?? context.strings.recoveryKeyOnForgotPassword,
- textAlign: TextAlign.center,
- style: TextStyles.body.copyWith(color: colors.textBase),
- ),
- const SizedBox(height: 20),
- Text(
- widget.subText ??
- context.strings.recoveryKeySaveShortDescription,
- textAlign: TextAlign.center,
- style: TextStyles.body.copyWith(color: colors.textLight),
+ return Container(
+ decoration: BoxDecoration(
+ color: colors.primary,
+ borderRadius: BorderRadius.circular(Radii.button),
+ ),
+ padding: const EdgeInsets.all(Spacing.xl),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Expanded(
+ child: Text(
+ recoveryKey,
+ style: TextStyles.body.copyWith(color: colors.specialWhite),
),
- const SizedBox(height: 20),
- Container(
- decoration: BoxDecoration(
- color: colors.primary,
- borderRadius: BorderRadius.circular(20),
- ),
- padding: const EdgeInsets.all(20),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
- Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Expanded(
- child: Text(
- recoveryKey,
- style: TextStyles.body.copyWith(
- color: colors.specialWhite,
- height: 24 / 14,
- ),
- ),
- ),
- const SizedBox(width: 4),
- GestureDetector(
- onTap: () async {
- await Clipboard.setData(
- ClipboardData(text: recoveryKey),
- );
- if (!mounted) return;
- showShortToast(
- context,
- context.strings.recoveryKeyCopiedToClipboard,
- );
- },
- child: HugeIcon(
- icon: HugeIcons.strokeRoundedCopy01,
- color: colors.specialWhite,
- size: 24,
- ),
- ),
- ],
- ),
- const SizedBox(height: 12),
- Theme(
- data: lightComponentTheme,
- child: ButtonComponent(
- variant: ButtonComponentVariant.secondary,
- shouldSurfaceExecutionStates: false,
- label: context.strings.shareKey,
- onTap: () async {
- unawaited(_shareRecoveryKey(recoveryKey));
- },
- ),
- ),
- ],
- ),
+ ),
+ const SizedBox(width: Spacing.xs),
+ IconButtonComponent(
+ variant: IconButtonComponentVariant.unfilled,
+ iconSize: IconSizes.small,
+ icon: HugeIcon(
+ icon: HugeIcons.strokeRoundedCopy01,
+ color: colors.specialWhite,
),
- ],
- ),
+ onTap: () async {
+ await Clipboard.setData(ClipboardData(text: recoveryKey));
+ if (!mounted) return;
+ showShortToast(
+ context,
+ context.strings.recoveryKeyCopiedToClipboard,
+ );
+ },
+ ),
+ ],
),
- ),
- if (widget.isOnboarding)
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 18),
- child: ButtonComponent(label: widget.doneText, onTap: _saveKeys),
+ const SizedBox(height: Spacing.md),
+ Theme(
+ data: lightComponentTheme,
+ child: ButtonComponent(
+ variant: ButtonComponentVariant.secondary,
+ shouldSurfaceExecutionStates: false,
+ label: context.strings.shareKey,
+ onTap: () async {
+ unawaited(_shareRecoveryKey(recoveryKey));
+ },
+ ),
),
- ],
+ ],
+ ),
);
}
diff --git a/mobile/apps/photos/lib/ui/account/recovery_page.dart b/mobile/apps/photos/lib/ui/account/recovery_page.dart
index a58cf0532f..2fe9d42dc6 100644
--- a/mobile/apps/photos/lib/ui/account/recovery_page.dart
+++ b/mobile/apps/photos/lib/ui/account/recovery_page.dart
@@ -2,6 +2,7 @@ import "package:ente_components/ente_components.dart";
import "package:ente_strings/ente_strings.dart";
import 'package:flutter/material.dart';
import 'package:photos/core/configuration.dart';
+import "package:photos/ui/account/onboarding_page_scaffold.dart";
import 'package:photos/ui/account/password_entry_page.dart';
import "package:photos/ui/components/alert_bottom_sheet.dart";
import 'package:photos/ui/notification/toast.dart';
@@ -27,81 +28,71 @@ class _RecoveryPageState extends State<RecoveryPage> {
@override
Widget build(BuildContext context) {
- final colors = context.componentColors;
final isFormValid = _recoveryKeyController.text.isNotEmpty;
- return Scaffold(
- resizeToAvoidBottomInset: true,
- backgroundColor: colors.backgroundBase,
- appBar: AppBar(
- elevation: 0,
- scrolledUnderElevation: 0,
- backgroundColor: colors.backgroundBase,
- leading: IconButton(
- icon: const Icon(Icons.arrow_back),
- color: colors.iconColor,
- onPressed: () {
- Navigator.of(context).pop();
- },
- ),
- title: Text(
- widget.isForgotPassword
- ? context.strings.forgotPassword
- : context.strings.recoverAccount,
- style: TextStyles.large.copyWith(color: colors.textBase),
- ),
- centerTitle: true,
- ),
+ return OnboardingPageScaffold(
+ title: widget.isForgotPassword
+ ? context.strings.forgotPassword
+ : context.strings.recoverAccount,
+ illustration: OnboardingIllustration.forgotPassword,
body: _getBody(),
- floatingActionButton: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: ButtonComponent(
+ actions: [
+ ButtonComponent(
key: const ValueKey("recoveryButton"),
label: context.strings.logInLabel,
+ shouldShowSuccessState: false,
isDisabled: !isFormValid,
onTap: isFormValid ? _onRecoverPressed : null,
),
- ),
- floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
+ ],
);
}
Widget _getBody() {
- return SafeArea(
- child: ListView(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- children: [
- const SizedBox(height: 12),
- TextInputComponent(
- label: context.strings.recoveryKey,
- hintText: context.strings.enterYourRecoveryKey,
- controller: _recoveryKeyController,
- keyboardType: TextInputType.multiline,
- maxLines: null,
- minLines: 5,
- autocorrect: false,
- onChanged: (value) {
- setState(() {});
- },
+ return Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ TextInputComponent(
+ label: context.strings.recoveryKey,
+ hintText: context.strings.enterYourRecoveryKey,
+ controller: _recoveryKeyController,
+ keyboardType: TextInputType.multiline,
+ maxLines: null,
+ minLines: 5,
+ autocorrect: false,
+ onChanged: (value) {
+ setState(() {});
+ },
+ ),
+ const SizedBox(height: Spacing.md),
+ Align(
+ alignment: Alignment.centerRight,
+ child: ButtonComponent(
+ label: context.strings.forgotRecoveryKey,
+ variant: ButtonComponentVariant.link,
+ size: ButtonComponentSize.small,
+ shouldSurfaceExecutionStates: false,
+ onTap: _showNoRecoveryKeySheet,
),
- const SizedBox(height: 16),
- Align(
- alignment: Alignment.centerRight,
- child: ButtonComponent(
- label: context.strings.forgotRecoveryKey,
- variant: ButtonComponentVariant.link,
- size: ButtonComponentSize.small,
- shouldSurfaceExecutionStates: false,
- onTap: () async {
- // ignore: unawaited_futures
- showAlertBottomSheet(
- context,
- title: context.strings.sorry,
- message: context.strings.noRecoveryKeyNoDecryption,
- assetPath: 'assets/warning-grey.png',
- );
- },
- ),
+ ),
+ ],
+ );
+ }
+
+ Future<void> _showNoRecoveryKeySheet() {
+ return showBottomSheetComponent<void>(
+ context: context,
+ builder: (_) => BottomSheetComponent(
+ title: context.strings.sorry,
+ message: context.strings.noRecoveryKeyNoDecryption,
+ illustration: Image.asset("assets/warning-red.png"),
+ actions: [
+ ButtonComponent(
+ label: context.strings.ok,
+ shouldSurfaceExecutionStates: false,
+ dismissModalOnSuccess: true,
+ onTap: () {},
),
],
),