Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] Move code verification, 2FA and passkey onto the onboarding scaffold

r4khul112c2667ad22
diff --git a/mobile/apps/photos/assets/ott.png b/mobile/apps/photos/assets/ott.png
deleted file mode 100644
index 20790dfbb4..0000000000
Binary files a/mobile/apps/photos/assets/ott.png and /dev/null differ
diff --git a/mobile/apps/photos/lib/services/account/user_service.dart b/mobile/apps/photos/lib/services/account/user_service.dart
index ec23f3d40c..b5ed4567ca 100644
--- a/mobile/apps/photos/lib/services/account/user_service.dart
+++ b/mobile/apps/photos/lib/services/account/user_service.dart
@@ -492,8 +492,7 @@ class UserService {
Navigator.of(context).pop();
} else {
if (!context.mounted) return;
- // ignore: unawaited_futures
- showAlertBottomSheet(
+ await showAlertBottomSheet(
context,
title: context.strings.incorrectCode,
message: context.strings.sorryTheCodeYouveEnteredIsIncorrect,
@@ -504,8 +503,7 @@ class UserService {
await dialog.hide();
_logger.warning(e);
if (!context.mounted) return;
- // ignore: unawaited_futures
- showAlertBottomSheet(
+ await showAlertBottomSheet(
context,
title: context.strings.oops,
message: context.strings.verificationFailedPleaseTryAgain,
@@ -550,8 +548,7 @@ class UserService {
await dialog.hide();
if (e.response != null && e.response!.statusCode == 403) {
if (!context.mounted) return;
- // ignore: unawaited_futures
- showAlertBottomSheet(
+ await showAlertBottomSheet(
context,
title: context.strings.oops,
message: context.strings.thisEmailIsAlreadyInUse,
@@ -559,8 +556,7 @@ class UserService {
);
} else {
if (!context.mounted) return;
- // ignore: unawaited_futures
- showAlertBottomSheet(
+ await showAlertBottomSheet(
context,
title: context.strings.incorrectCode,
message: context.strings.authenticationFailedPleaseTryAgain,
@@ -571,8 +567,7 @@ class UserService {
await dialog.hide();
_logger.warning(e);
if (!context.mounted) return;
- // ignore: unawaited_futures
- showAlertBottomSheet(
+ await showAlertBottomSheet(
context,
title: context.strings.oops,
message: context.strings.verificationFailedPleaseTryAgain,
@@ -859,8 +854,7 @@ class UserService {
);
} else {
if (!context.mounted) return;
- // ignore: unawaited_futures
- showAlertBottomSheet(
+ await showAlertBottomSheet(
context,
title: context.strings.incorrectCode,
message: context.strings.authenticationFailedPleaseTryAgain,
@@ -871,8 +865,7 @@ class UserService {
await dialog.hide();
_logger.severe(e);
if (!context.mounted) return;
- // ignore: unawaited_futures
- showAlertBottomSheet(
+ await showAlertBottomSheet(
context,
title: context.strings.oops,
message: context.strings.authenticationFailedPleaseTryAgain,
diff --git a/mobile/apps/photos/lib/ui/account/ott_verification_page.dart b/mobile/apps/photos/lib/ui/account/ott_verification_page.dart
index 02b2cb8143..6a285eea55 100644
--- a/mobile/apps/photos/lib/ui/account/ott_verification_page.dart
+++ b/mobile/apps/photos/lib/ui/account/ott_verification_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/services/account/user_service.dart';
+import "package:photos/ui/account/onboarding_page_scaffold.dart";
class OTTVerificationPage extends StatefulWidget {
final String email;
@@ -29,6 +30,7 @@ class OTTVerificationPage extends StatefulWidget {
class _OTTVerificationPageState extends State<OTTVerificationPage> {
final _pinController = TextEditingController();
+ final _pinFocusNode = FocusNode();
String _code = "";
bool _isSubmitting = false;
bool _isResendingCode = false;
@@ -65,125 +67,114 @@ class _OTTVerificationPageState extends State<OTTVerificationPage> {
if (!mounted) {
return;
}
- FocusScope.of(context).unfocus();
+ if (ModalRoute.of(context)?.isCurrent ?? false) {
+ _resetCode();
+ } else {
+ FocusScope.of(context).unfocus();
+ }
+ }
+
+ void _resetCode() {
+ _pinController.clear();
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ if (mounted) _pinFocusNode.requestFocus();
+ });
}
@override
void dispose() {
_pinController.dispose();
+ _pinFocusNode.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
- final colors = context.componentColors;
final isFormValid =
_code.length == 6 && !_isSubmitting && !_isResendingCode;
- 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.verifyEmail,
- style: TextStyles.large.copyWith(color: colors.textBase),
- ),
- centerTitle: true,
- ),
+ return OnboardingPageScaffold(
+ title: context.strings.verifyEmail,
+ illustration: OnboardingIllustration.email,
+ isBodyCentered: true,
body: _getBody(),
- floatingActionButton: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: ButtonComponent(
+ actions: [
+ ButtonComponent(
key: const ValueKey("verifyOttButton"),
label: context.strings.verify,
+ shouldShowSuccessState: false,
isDisabled: !isFormValid,
onTap: isFormValid ? _onVerifyPressed : null,
),
- ),
- floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
+ ],
);
}
Widget _getBody() {
final colors = context.componentColors;
- return SafeArea(
- child: ListView(
- padding: const EdgeInsets.fromLTRB(16, 0, 16, 96),
- children: [
- Center(child: Image.asset('assets/ott.png', height: 96)),
- const SizedBox(height: 24),
- Text(
- context.strings.weHaveSentCodeTo(email: widget.email),
- style: TextStyles.body.copyWith(color: colors.textBase),
- textAlign: TextAlign.center,
- ),
- const SizedBox(height: 8),
- Text(
- widget.isResetPasswordScreen
- ? context.strings.toResetVerifyEmail
- : context.strings.checkInboxAndSpamFolder,
- style: TextStyles.body.copyWith(color: colors.textLight),
- textAlign: TextAlign.center,
- ),
- const SizedBox(height: 32),
- Center(
- child: PinInputComponent(
- length: 6,
- controller: _pinController,
- autofocus: true,
- isDisabled: _isSubmitting || _isResendingCode,
- autofillHints: const [AutofillHints.oneTimeCode],
- onChanged: (String pin) {
- setState(() {
- _code = pin;
- });
- },
- onCompleted: (value) {
- if (value.length == 6) {
- _onVerifyPressed();
- }
- },
- ),
- ),
- const SizedBox(height: 24),
- if (widget.isResetPasswordScreen)
- Center(child: _buildResendCodeButton())
- else
- Wrap(
- alignment: WrapAlignment.spaceBetween,
- crossAxisAlignment: WrapCrossAlignment.center,
- spacing: Spacing.lg,
- children: [
- TextButton(
- style: TextButton.styleFrom(
- foregroundColor: colors.textLight,
- padding: const EdgeInsets.symmetric(vertical: 14),
- textStyle: TextStyles.bodyLink,
- ),
- onPressed: _isSubmitting || _isResendingCode
- ? null
- : () {
- Navigator.of(context).pop();
- widget.onChangeEmail?.call();
- },
- child: Text(context.strings.changeEmail),
+ return Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Text(
+ context.strings.weHaveSentCodeTo(email: widget.email),
+ style: TextStyles.body.copyWith(color: colors.textBase),
+ textAlign: TextAlign.center,
+ ),
+ const SizedBox(height: Spacing.xs),
+ Text(
+ widget.isResetPasswordScreen
+ ? context.strings.toResetVerifyEmail
+ : context.strings.checkInboxAndSpamFolder,
+ style: TextStyles.body.copyWith(color: colors.textLight),
+ textAlign: TextAlign.center,
+ ),
+ const SizedBox(height: Spacing.xxl),
+ PinInputComponent(
+ length: 6,
+ controller: _pinController,
+ focusNode: _pinFocusNode,
+ autofocus: true,
+ isDisabled: _isSubmitting || _isResendingCode,
+ autofillHints: const [AutofillHints.oneTimeCode],
+ onChanged: (String pin) {
+ setState(() {
+ _code = pin;
+ });
+ },
+ onCompleted: (value) {
+ if (value.length == 6) {
+ _onVerifyPressed();
+ }
+ },
+ ),
+ const SizedBox(height: Spacing.md),
+ if (widget.isResetPasswordScreen)
+ Center(child: _buildResendCodeButton())
+ else
+ Wrap(
+ alignment: WrapAlignment.spaceBetween,
+ crossAxisAlignment: WrapCrossAlignment.center,
+ spacing: Spacing.lg,
+ children: [
+ TextButton(
+ style: TextButton.styleFrom(
+ foregroundColor: colors.textLighter,
+ padding: const EdgeInsets.symmetric(vertical: 14),
+ textStyle: TextStyles.bodyLink,
),
- _buildResendCodeButton(),
- ],
- ),
- ],
- ),
+ onPressed: _isSubmitting || _isResendingCode
+ ? null
+ : () {
+ Navigator.of(context).pop();
+ widget.onChangeEmail?.call();
+ },
+ child: Text(context.strings.changeEmail),
+ ),
+ _buildResendCodeButton(),
+ ],
+ ),
+ ],
);
}
@@ -192,10 +183,8 @@ class _OTTVerificationPageState extends State<OTTVerificationPage> {
return TextButton(
style: TextButton.styleFrom(
foregroundColor: colors.primary,
- padding: const EdgeInsets.symmetric(vertical: Spacing.xs),
- textStyle: TextStyles.bodyBold.copyWith(
- decoration: TextDecoration.underline,
- ),
+ padding: const EdgeInsets.symmetric(vertical: 14),
+ textStyle: TextStyles.bodyLink,
),
onPressed: _isSubmitting || _isResendingCode ? null : _resendCode,
child: Text(context.strings.resendCode),
diff --git a/mobile/apps/photos/lib/ui/account/passkey_page.dart b/mobile/apps/photos/lib/ui/account/passkey_page.dart
index 11eb9f694d..f0a63f9592 100644
--- a/mobile/apps/photos/lib/ui/account/passkey_page.dart
+++ b/mobile/apps/photos/lib/ui/account/passkey_page.dart
@@ -11,6 +11,7 @@ import 'package:photos/core/configuration.dart';
import "package:photos/core/errors.dart";
import "package:photos/models/account/two_factor.dart";
import 'package:photos/services/account/user_service.dart';
+import "package:photos/ui/account/onboarding_page_scaffold.dart";
import "package:photos/ui/account/two_factor_authentication_page.dart";
import "package:photos/ui/components/alert_bottom_sheet.dart";
import "package:photos/ui/notification/toast.dart";
@@ -148,96 +149,67 @@ class _PasskeyPageState extends State<PasskeyPage> {
Widget build(BuildContext context) {
final colors = context.componentColors;
- return Scaffold(
- 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.passkeyAuthTitle,
- style: TextStyles.large.copyWith(color: colors.textBase),
- ),
- centerTitle: true,
- ),
- body: _getBody(),
- );
- }
-
- Widget _getBody() {
- final colors = context.componentColors;
- return SafeArea(
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: Column(
- children: [
- const Spacer(),
- Text(
- context.strings.waitingForVerification,
- style: TextStyles.body.copyWith(color: colors.textBase),
- textAlign: TextAlign.center,
- ),
- if (widget.totp2FASessionID.isNotEmpty)
- ButtonComponent(
- label: context.strings.useTwoFactorInstead,
- variant: ButtonComponentVariant.link,
- size: ButtonComponentSize.small,
- onTap: () async {
- // ignore: unawaited_futures
- routeToPage(
- context,
- TwoFactorAuthenticationPage(widget.totp2FASessionID),
- );
- },
- ),
- const Spacer(),
- ButtonComponent(
- label: context.strings.tryAgain,
- onTap: () => launchPasskey(),
- ),
- const SizedBox(height: 16),
+ return OnboardingPageScaffold(
+ title: context.strings.passkeyAuthTitle,
+ illustration: OnboardingIllustration.key,
+ isBodyCentered: true,
+ body: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Text(
+ context.strings.waitingForVerification,
+ style: TextStyles.body.copyWith(color: colors.textBase),
+ textAlign: TextAlign.center,
+ ),
+ if (widget.totp2FASessionID.isNotEmpty) ...[
+ const SizedBox(height: Spacing.sm),
ButtonComponent(
- label: context.strings.checkStatus,
- variant: ButtonComponentVariant.secondary,
- shouldSurfaceExecutionStates: true,
- onTap: () async {
- try {
- await checkStatus();
- } catch (e) {
- debugPrint('failed to check status $e');
- if (!mounted) return;
- showGenericErrorBottomSheet(
- context: context,
- error: e,
- ).ignore();
- }
- },
- ),
- const SizedBox(height: 12),
- ButtonComponent(
- label: context.strings.recoverAccount,
+ label: context.strings.useTwoFactorInstead,
variant: ButtonComponentVariant.link,
size: ButtonComponentSize.small,
onTap: () async {
// ignore: unawaited_futures
- UserService.instance.recoverTwoFactor(
+ routeToPage(
context,
- widget.sessionID,
- TwoFactorType.passkey,
+ TwoFactorAuthenticationPage(widget.totp2FASessionID),
);
},
),
- const SizedBox(height: 24),
],
- ),
+ ],
),
+ actions: [
+ ButtonComponent(
+ label: context.strings.tryAgain,
+ onTap: () => launchPasskey(),
+ ),
+ ButtonComponent(
+ label: context.strings.checkStatus,
+ variant: ButtonComponentVariant.secondary,
+ shouldSurfaceExecutionStates: true,
+ onTap: () async {
+ try {
+ await checkStatus();
+ } catch (e) {
+ debugPrint('failed to check status $e');
+ if (!context.mounted) return;
+ showGenericErrorBottomSheet(context: context, error: e).ignore();
+ }
+ },
+ ),
+ ButtonComponent(
+ label: context.strings.recoverAccount,
+ variant: ButtonComponentVariant.link,
+ onTap: () async {
+ // ignore: unawaited_futures
+ UserService.instance.recoverTwoFactor(
+ context,
+ widget.sessionID,
+ TwoFactorType.passkey,
+ );
+ },
+ ),
+ ],
);
}
}
diff --git a/mobile/apps/photos/lib/ui/account/two_factor_authentication_page.dart b/mobile/apps/photos/lib/ui/account/two_factor_authentication_page.dart
index bd34debd8d..9bd88394cd 100644
--- a/mobile/apps/photos/lib/ui/account/two_factor_authentication_page.dart
+++ b/mobile/apps/photos/lib/ui/account/two_factor_authentication_page.dart
@@ -4,8 +4,8 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import "package:photos/models/account/two_factor.dart";
import 'package:photos/services/account/user_service.dart';
+import "package:photos/ui/account/onboarding_page_scaffold.dart";
import 'package:photos/ui/lifecycle_event_handler.dart';
-import "package:pinput/pinput.dart";
class TwoFactorAuthenticationPage extends StatefulWidget {
final String sessionID;
@@ -20,6 +20,7 @@ class TwoFactorAuthenticationPage extends StatefulWidget {
class _TwoFactorAuthenticationPageState
extends State<TwoFactorAuthenticationPage> {
final _pinController = TextEditingController();
+ final _pinFocusNode = FocusNode();
String _code = "";
late LifecycleEventHandler _lifecycleEventHandler;
@@ -43,6 +44,7 @@ class _TwoFactorAuthenticationPageState
void dispose() {
WidgetsBinding.instance.removeObserver(_lifecycleEventHandler);
_pinController.dispose();
+ _pinFocusNode.dispose();
super.dispose();
}
@@ -50,120 +52,65 @@ class _TwoFactorAuthenticationPageState
Widget build(BuildContext context) {
final colors = context.componentColors;
- return Scaffold(
- 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.twoFAVerification,
- style: TextStyles.large.copyWith(color: colors.textBase),
- ),
- centerTitle: true,
- ),
- body: _getBody(),
- );
- }
-
- Widget _getBody() {
- final colors = context.componentColors;
- final defaultPinTheme = PinTheme(
- height: 52,
- width: 48,
- textStyle: TextStyles.body.copyWith(color: colors.textBase),
- decoration: BoxDecoration(
- border: Border.all(color: colors.strokeFaint),
- borderRadius: BorderRadius.circular(20),
+ return OnboardingPageScaffold(
+ title: context.strings.twoFAVerification,
+ illustration: OnboardingIllustration.key,
+ isBodyCentered: true,
+ body: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Text(
+ context.strings.enterThe6digitCodeFromnyourAuthenticatorApp,
+ style: TextStyles.body.copyWith(color: colors.textLight),
+ textAlign: TextAlign.center,
+ ),
+ const SizedBox(height: Spacing.xxl),
+ PinInputComponent(
+ length: 6,
+ controller: _pinController,
+ focusNode: _pinFocusNode,
+ autofocus: true,
+ autofillHints: const [AutofillHints.oneTimeCode],
+ onChanged: (String pin) {
+ setState(() {
+ _code = pin;
+ });
+ },
+ onCompleted: _verifyTwoFactorCode,
+ ),
+ ],
),
- );
-
- final focusedPinTheme = defaultPinTheme.copyWith(
- decoration: BoxDecoration(
- border: Border.all(color: colors.primary, width: 2),
- borderRadius: BorderRadius.circular(20),
- ),
- );
-
- final submittedPinTheme = defaultPinTheme.copyWith(
- textStyle: TextStyles.h1.copyWith(color: colors.primary),
- decoration: BoxDecoration(
- color: colors.primaryLight,
- border: Border.all(color: colors.primary, width: 2),
- borderRadius: BorderRadius.circular(20),
- ),
- );
-
- return SafeArea(
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: Column(
- children: [
- const SizedBox(height: 24),
- Text(
- context.strings.enterThe6digitCodeFromnyourAuthenticatorApp,
- style: TextStyles.body.copyWith(color: colors.textLight),
- textAlign: TextAlign.center,
- ),
- const SizedBox(height: 24),
- Center(
- child: Pinput(
- length: 6,
- onCompleted: (String code) {
- _verifyTwoFactorCode(code);
- },
- onChanged: (String pin) {
- setState(() {
- _code = pin;
- });
- },
- autofocus: true,
- controller: _pinController,
- defaultPinTheme: defaultPinTheme,
- focusedPinTheme: focusedPinTheme,
- submittedPinTheme: submittedPinTheme,
- followingPinTheme: defaultPinTheme,
- ),
- ),
- const Spacer(),
- ButtonComponent(
- label: context.strings.verify,
- isDisabled: _code.length != 6,
- onTap: _code.length == 6
- ? () => _verifyTwoFactorCode(_code)
- : null,
- ),
- const SizedBox(height: 16),
- Center(
- child: ButtonComponent(
- label: context.strings.lostDevice,
- variant: ButtonComponentVariant.link,
- size: ButtonComponentSize.small,
- onTap: () async {
- // ignore: unawaited_futures
- UserService.instance.recoverTwoFactor(
- context,
- widget.sessionID,
- TwoFactorType.totp,
- );
- },
- ),
- ),
- const SizedBox(height: 24),
- ],
+ actions: [
+ ButtonComponent(
+ label: context.strings.verify,
+ shouldShowSuccessState: false,
+ isDisabled: _code.length != 6,
+ onTap: _code.length == 6 ? () => _verifyTwoFactorCode(_code) : null,
),
- ),
+ ButtonComponent(
+ label: context.strings.lostDevice,
+ variant: ButtonComponentVariant.link,
+ onTap: () async {
+ // ignore: unawaited_futures
+ UserService.instance.recoverTwoFactor(
+ context,
+ widget.sessionID,
+ TwoFactorType.totp,
+ );
+ },
+ ),
+ ],
);
}
Future<void> _verifyTwoFactorCode(String code) async {
await UserService.instance.verifyTwoFactor(context, widget.sessionID, code);
+ if (!mounted) return;
+ if (ModalRoute.of(context)?.isCurrent ?? false) {
+ _pinController.clear();
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ if (mounted) _pinFocusNode.requestFocus();
+ });
+ }
}
}
diff --git a/mobile/apps/photos/test/ui/account/auth_verification_test.dart b/mobile/apps/photos/test/ui/account/auth_verification_test.dart
index 309a6262fb..88dd4b8d53 100644
--- a/mobile/apps/photos/test/ui/account/auth_verification_test.dart
+++ b/mobile/apps/photos/test/ui/account/auth_verification_test.dart
@@ -66,6 +66,14 @@ void main() {
failure = null;
});
+ // The onboarding illustrations animate continuously, so the tree never
+ // settles; pump a bounded stretch of frames instead.
+ Future<void> settle(WidgetTester tester) async {
+ for (var i = 0; i < 12; i++) {
+ await tester.pump(const Duration(milliseconds: 100));
+ }
+ }
+
Widget app(
Widget home, {
Locale? locale,
@@ -113,7 +121,7 @@ void main() {
),
);
await tester.tap(find.text("Enter email"));
- await tester.pumpAndSettle();
+ await settle(tester);
final page = tester.widget<OTTVerificationPage>(
find.byType(OTTVerificationPage),
);
@@ -132,7 +140,7 @@ void main() {
for (var resend = 0; resend < 2; resend++) {
await tester.tap(find.text("Resend code"));
- await tester.pumpAndSettle();
+ await settle(tester);
expect(
find.byType(OTTVerificationPage, skipOffstage: false),
findsOneWidget,
@@ -154,7 +162,7 @@ void main() {
} else {
await tester.tap(find.text("Change email"));
}
- await tester.pumpAndSettle();
+ await settle(tester);
expect(find.text("Enter email"), findsOneWidget);
expect(
find.byType(OTTVerificationPage, skipOffstage: false),
@@ -195,13 +203,13 @@ void main() {
),
);
await tester.tap(find.text("Enter email"));
- await tester.pumpAndSettle();
+ await settle(tester);
await tester.tap(find.text("Password fallback"));
- await tester.pumpAndSettle();
+ await settle(tester);
await tester.tap(find.text("Resend code"));
- await tester.pumpAndSettle();
+ await settle(tester);
await tester.tap(find.text("Change email"));
- await tester.pumpAndSettle();
+ await settle(tester);
expect(find.text("Enter email"), findsOneWidget);
expect(find.text("Password fallback"), findsNothing);
expect(find.byType(OTTVerificationPage, skipOffstage: false), findsNothing);
@@ -228,7 +236,7 @@ void main() {
final actions = tester.widgetList<TextButton>(find.byType(TextButton));
expect(actions.every((button) => button.onPressed == null), isTrue);
pendingRequest!.complete();
- await tester.pumpAndSettle();
+ await settle(tester);
expect(find.byType(OTTVerificationPage), findsOneWidget);
expect(
tester
@@ -247,14 +255,14 @@ void main() {
);
failure = {"code": "USER_NOT_REGISTERED"};
await tester.tap(find.text("Resend code"));
- await tester.pumpAndSettle();
+ await settle(tester);
expect(find.byType(OTTVerificationPage), findsOneWidget);
expect(find.text("Resend code"), findsOneWidget);
Navigator.of(tester.element(find.byType(OTTVerificationPage))).pop();
- await tester.pumpAndSettle();
+ await settle(tester);
failure = null;
await tester.tap(find.text("Resend code"));
- await tester.pumpAndSettle();
+ await settle(tester);
expect(requests, hasLength(2));
expect(find.byType(OTTVerificationPage), findsOneWidget);
expect(tester.takeException(), isNull);
@@ -271,7 +279,7 @@ void main() {
await tester.pump(const Duration(milliseconds: 300));
await tester.pumpWidget(const SizedBox());
pendingRequest!.complete();
- await tester.pumpAndSettle();
+ await settle(tester);
expect(requests, hasLength(1));
expect(tester.takeException(), isNull);
});
@@ -292,15 +300,19 @@ void main() {
scale: 2,
),
);
- await tester.pumpAndSettle();
+ await settle(tester);
final context = tester.element(find.byType(OTTVerificationPage));
for (final label in [
context.strings.changeEmail,
context.strings.resendCode,
]) {
final action = find.text(label);
- await tester.scrollUntilVisible(action, 150);
- await tester.pumpAndSettle();
+ await tester.scrollUntilVisible(
+ action,
+ 150,
+ scrollable: find.byType(Scrollable).first,
+ );
+ await settle(tester);
final rect = tester.getRect(action);
expect(rect.left, greaterThanOrEqualTo(16));
expect(rect.right, lessThanOrEqualTo(304));
@@ -321,10 +333,7 @@ void main() {
final title = forgotPassword
? context.strings.forgotPassword
: context.strings.recoverAccount;
- expect(
- find.descendant(of: find.byType(AppBar), matching: find.text(title)),
- findsOneWidget,
- );
+ expect(find.text(title), findsOneWidget);
expect(tester.takeException(), isNull);
},
);