Skip to content

armgit / ente

Public Imported from GitHub
0

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

refactor: Enhance EmailEntryPage and TwoFactorAuthenticationPage UI with improved theming and layout adjustments

AmanRajSinghMourya77c8fde34458
diff --git a/mobile/packages/accounts/lib/pages/email_entry_page.dart b/mobile/packages/accounts/lib/pages/email_entry_page.dart
index 62c49e2922..012fd6be57 100644
--- a/mobile/packages/accounts/lib/pages/email_entry_page.dart
+++ b/mobile/packages/accounts/lib/pages/email_entry_page.dart
@@ -1,3 +1,4 @@
+import 'package:dots_indicator/dots_indicator.dart';
import 'package:email_validator/email_validator.dart';
import 'package:ente_accounts/ente_accounts.dart';
import 'package:ente_configuration/base_configuration.dart';
@@ -8,7 +9,6 @@ import 'package:ente_utils/platform_util.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:password_strength/password_strength.dart';
-import "package:step_progress_indicator/step_progress_indicator.dart";
import "package:styled_text/styled_text.dart";
class EmailEntryPage extends StatefulWidget {
@@ -68,7 +68,7 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
// Initialize theme-aware color
final colorScheme = getEnteColorScheme(context);
- _validFieldValueColor = colorScheme.primary300.withOpacity(0.2);
+ _validFieldValueColor = const Color.fromRGBO(45, 194, 98, 0.2);
FloatingActionButtonLocation? fabLocation() {
if (isKeypadOpen) {
@@ -78,30 +78,25 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
}
}
- final appBar = AppBar(
- elevation: 0,
- leading: IconButton(
- icon: const Icon(Icons.arrow_back),
- color: Theme.of(context).iconTheme.color,
- onPressed: () {
- Navigator.of(context).pop();
- },
- ),
- title: Material(
- type: MaterialType.transparency,
- child: StepProgressIndicator(
- totalSteps: 4,
- currentStep: 1,
- selectedColor: getEnteColorScheme(context).alternativeColor,
- roundedEdges: const Radius.circular(10),
- unselectedColor:
- getEnteColorScheme(context).stepProgressUnselectedColor,
- ),
- ),
- );
return Scaffold(
resizeToAvoidBottomInset: isKeypadOpen,
- appBar: appBar,
+ backgroundColor: colorScheme.backgroundBase,
+ appBar: AppBar(
+ elevation: 0,
+ backgroundColor: colorScheme.backgroundBase,
+ centerTitle: true,
+ title: Image.asset(
+ 'assets/locker-logo-blue.png',
+ height: 24,
+ ),
+ leading: IconButton(
+ icon: const Icon(Icons.arrow_back),
+ color: colorScheme.primary700,
+ onPressed: () {
+ Navigator.of(context).pop();
+ },
+ ),
+ ),
body: _getBody(),
floatingActionButton: DynamicFAB(
isKeypadOpen: isKeypadOpen,
@@ -126,6 +121,9 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
}
Widget _getBody() {
+ final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+
var passwordStrengthText = context.strings.weakStrength;
var passwordStrengthColor = Colors.redAccent;
if (_passwordStrength > kStrongPasswordStrengthThreshold) {
@@ -142,237 +140,292 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
child: ListView(
children: [
Padding(
- padding:
- const EdgeInsets.symmetric(vertical: 30, horizontal: 20),
- child: Text(
- context.strings.createNewAccount,
- style: Theme.of(context).textTheme.headlineMedium,
- ),
- ),
- Padding(
- padding: const EdgeInsets.fromLTRB(20, 0, 20, 0),
- child: TextFormField(
- style: Theme.of(context).textTheme.titleMedium,
- autofillHints: const [AutofillHints.email],
- decoration: InputDecoration(
- fillColor: _emailIsValid ? _validFieldValueColor : null,
- filled: true,
- hintText: context.strings.email,
- contentPadding: const EdgeInsets.symmetric(
- horizontal: 16,
- vertical: 14,
- ),
- border: UnderlineInputBorder(
- borderSide: BorderSide.none,
- borderRadius: BorderRadius.circular(6),
- ),
- suffixIcon: _emailIsValid
- ? Icon(
- Icons.check,
- size: 20,
- color: getEnteColorScheme(context).primary300,
- )
- : null,
- ),
- onChanged: (value) {
- _email = value.trim();
- if (_emailIsValid != EmailValidator.validate(_email!)) {
- setState(() {
- _emailIsValid = EmailValidator.validate(_email!);
- });
- }
- },
- autocorrect: false,
- keyboardType: TextInputType.emailAddress,
- //initialValue: _email,
- textInputAction: TextInputAction.next,
- ),
- ),
- const Padding(padding: EdgeInsets.all(4)),
- Padding(
- padding: const EdgeInsets.fromLTRB(20, 0, 20, 0),
- child: TextFormField(
- keyboardType: TextInputType.text,
- textInputAction: TextInputAction.next,
- controller: _passwordController1,
- obscureText: !_password1Visible,
- enableSuggestions: true,
- autofillHints: const [AutofillHints.newPassword],
- decoration: InputDecoration(
- fillColor:
- _passwordIsValid ? _validFieldValueColor : null,
- filled: true,
- hintText: context.strings.password,
- contentPadding: const EdgeInsets.symmetric(
- horizontal: 16,
- vertical: 14,
+ padding: const EdgeInsets.symmetric(horizontal: 16),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ const SizedBox(height: 24),
+ // Email field
+ Text(
+ context.strings.email,
+ style: textTheme.bodyBold.copyWith(
+ color: colorScheme.textBase,
+ ),
),
- suffixIcon: _password1InFocus
- ? IconButton(
- icon: Icon(
- _password1Visible
- ? Icons.visibility
- : Icons.visibility_off,
- color: Theme.of(context).iconTheme.color,
- size: 20,
- ),
- onPressed: () {
- setState(() {
- _password1Visible = !_password1Visible;
- });
- },
- )
- : _passwordIsValid
+ const SizedBox(height: 8),
+ TextFormField(
+ style: textTheme.body.copyWith(
+ color: colorScheme.textBase,
+ ),
+ autofillHints: const [AutofillHints.email],
+ decoration: InputDecoration(
+ fillColor: _emailIsValid
+ ? _validFieldValueColor
+ : colorScheme.backdropBase,
+ filled: true,
+ hintText: context.strings.emailHint,
+ hintStyle: TextStyle(color: colorScheme.textMuted),
+ contentPadding: const EdgeInsets.symmetric(
+ horizontal: 16,
+ vertical: 14,
+ ),
+ border: OutlineInputBorder(
+ borderSide: BorderSide.none,
+ borderRadius: BorderRadius.circular(8),
+ ),
+ enabledBorder: OutlineInputBorder(
+ borderSide: BorderSide.none,
+ borderRadius: BorderRadius.circular(8),
+ ),
+ suffixIcon: _emailIsValid
? Icon(
Icons.check,
- color: getEnteColorScheme(context).primary300,
+ size: 20,
+ color: colorScheme.primary700,
)
: null,
- border: UnderlineInputBorder(
- borderSide: BorderSide.none,
- borderRadius: BorderRadius.circular(6),
+ ),
+ onChanged: (value) {
+ _email = value.trim();
+ if (_emailIsValid !=
+ EmailValidator.validate(_email!)) {
+ setState(() {
+ _emailIsValid = EmailValidator.validate(_email!);
+ });
+ }
+ },
+ autocorrect: false,
+ keyboardType: TextInputType.emailAddress,
+ textInputAction: TextInputAction.next,
),
- ),
- focusNode: _password1FocusNode,
- onChanged: (password) {
- if (password != _password) {
- setState(() {
- _password = password;
- _passwordStrength =
- estimatePasswordStrength(password);
- _passwordIsValid = _passwordStrength >=
- kMildPasswordStrengthThreshold;
- _passwordsMatch = _password == _cnfPassword;
- });
- }
- },
- onEditingComplete: () {
- _password1FocusNode.unfocus();
- _password2FocusNode.requestFocus();
- TextInput.finishAutofillContext();
- },
- ),
- ),
- const SizedBox(height: 8),
- Padding(
- padding: const EdgeInsets.fromLTRB(20, 0, 20, 0),
- child: TextFormField(
- keyboardType: TextInputType.visiblePassword,
- controller: _passwordController2,
- obscureText: !_password2Visible,
- autofillHints: const [AutofillHints.newPassword],
- onEditingComplete: () => TextInput.finishAutofillContext(),
- decoration: InputDecoration(
- fillColor: _passwordsMatch && _passwordIsValid
- ? _validFieldValueColor
- : null,
- filled: true,
- hintText: context.strings.confirmPassword,
- contentPadding: const EdgeInsets.symmetric(
- horizontal: 16,
- vertical: 14,
+ const SizedBox(height: 16),
+ // Password field
+ Text(
+ context.strings.password,
+ style: textTheme.bodyBold.copyWith(
+ color: colorScheme.textBase,
+ ),
),
- suffixIcon: _password2InFocus
- ? IconButton(
- icon: Icon(
- _password2Visible
- ? Icons.visibility
- : Icons.visibility_off,
- color: Theme.of(context).iconTheme.color,
- size: 20,
- ),
- onPressed: () {
- setState(() {
- _password2Visible = !_password2Visible;
- });
- },
- )
- : _passwordsMatch
- ? Icon(
- Icons.check,
- color: getEnteColorScheme(context).primary300,
+ const SizedBox(height: 8),
+ TextFormField(
+ keyboardType: TextInputType.text,
+ textInputAction: TextInputAction.next,
+ controller: _passwordController1,
+ obscureText: !_password1Visible,
+ enableSuggestions: true,
+ autofillHints: const [AutofillHints.newPassword],
+ style: textTheme.body.copyWith(
+ color: colorScheme.textBase,
+ ),
+ decoration: InputDecoration(
+ fillColor: _passwordIsValid
+ ? _validFieldValueColor
+ : colorScheme.backdropBase,
+ filled: true,
+ hintText: context.strings.enterYourPasswordHint,
+ hintStyle: TextStyle(color: colorScheme.textMuted),
+ contentPadding: const EdgeInsets.symmetric(
+ horizontal: 16,
+ vertical: 14,
+ ),
+ border: OutlineInputBorder(
+ borderSide: BorderSide.none,
+ borderRadius: BorderRadius.circular(8),
+ ),
+ enabledBorder: OutlineInputBorder(
+ borderSide: BorderSide.none,
+ borderRadius: BorderRadius.circular(8),
+ ),
+ suffixIcon: _password1InFocus
+ ? IconButton(
+ icon: Icon(
+ _password1Visible
+ ? Icons.visibility
+ : Icons.visibility_off,
+ color: colorScheme.textMuted,
+ size: 20,
+ ),
+ onPressed: () {
+ setState(() {
+ _password1Visible = !_password1Visible;
+ });
+ },
)
- : null,
- border: UnderlineInputBorder(
- borderSide: BorderSide.none,
- borderRadius: BorderRadius.circular(6),
+ : _passwordIsValid
+ ? Icon(
+ Icons.check,
+ color: colorScheme.primary700,
+ )
+ : null,
+ ),
+ focusNode: _password1FocusNode,
+ onChanged: (password) {
+ if (password != _password) {
+ setState(() {
+ _password = password;
+ _passwordStrength =
+ estimatePasswordStrength(password);
+ _passwordIsValid = _passwordStrength >=
+ kMildPasswordStrengthThreshold;
+ _passwordsMatch = _password == _cnfPassword;
+ });
+ }
+ },
+ onEditingComplete: () {
+ _password1FocusNode.unfocus();
+ _password2FocusNode.requestFocus();
+ TextInput.finishAutofillContext();
+ },
),
- ),
- focusNode: _password2FocusNode,
- onChanged: (cnfPassword) {
- setState(() {
- _cnfPassword = cnfPassword;
- if (_password != null || _password != '') {
- _passwordsMatch = _password == _cnfPassword;
- }
- });
- },
- ),
- ),
- Opacity(
- opacity: (_password != '') && _password1InFocus ? 1 : 0,
- child: Padding(
- padding:
- const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
- child: Text(
- context.strings.passwordStrength(passwordStrengthText),
- style: TextStyle(
- color: passwordStrengthColor,
- fontWeight: FontWeight.w500,
- fontSize: 12,
+ const SizedBox(height: 16),
+ // Confirm Password field
+ Text(
+ context.strings.confirmPassword,
+ style: textTheme.bodyBold.copyWith(
+ color: colorScheme.textBase,
+ ),
),
- ),
- ),
- ),
- const SizedBox(height: 4),
- Padding(
- padding:
- const EdgeInsets.symmetric(vertical: 0, horizontal: 20),
- child: Text(
- context.strings.hearUsWhereTitle,
- style: getEnteTextTheme(context).smallFaint,
- ),
- ),
- const SizedBox(height: 4),
- Padding(
- padding: const EdgeInsets.fromLTRB(20, 0, 20, 0),
- child: TextFormField(
- style: Theme.of(context).textTheme.titleMedium,
- decoration: InputDecoration(
- fillColor: null,
- filled: true,
- contentPadding: const EdgeInsets.symmetric(
- horizontal: 16,
- vertical: 14,
+ const SizedBox(height: 8),
+ TextFormField(
+ keyboardType: TextInputType.visiblePassword,
+ controller: _passwordController2,
+ obscureText: !_password2Visible,
+ autofillHints: const [AutofillHints.newPassword],
+ onEditingComplete: () =>
+ TextInput.finishAutofillContext(),
+ style: textTheme.body.copyWith(
+ color: colorScheme.textBase,
+ ),
+ decoration: InputDecoration(
+ fillColor: _passwordsMatch && _passwordIsValid
+ ? _validFieldValueColor
+ : colorScheme.backdropBase,
+ filled: true,
+ hintText: context.strings.reEnterPassword,
+ hintStyle: TextStyle(color: colorScheme.textMuted),
+ contentPadding: const EdgeInsets.symmetric(
+ horizontal: 16,
+ vertical: 14,
+ ),
+ border: OutlineInputBorder(
+ borderSide: BorderSide.none,
+ borderRadius: BorderRadius.circular(8),
+ ),
+ enabledBorder: OutlineInputBorder(
+ borderSide: BorderSide.none,
+ borderRadius: BorderRadius.circular(8),
+ ),
+ suffixIcon: _password2InFocus
+ ? IconButton(
+ icon: Icon(
+ _password2Visible
+ ? Icons.visibility
+ : Icons.visibility_off,
+ color: colorScheme.textMuted,
+ size: 20,
+ ),
+ onPressed: () {
+ setState(() {
+ _password2Visible = !_password2Visible;
+ });
+ },
+ )
+ : _passwordsMatch
+ ? Icon(
+ Icons.check,
+ color: colorScheme.primary700,
+ )
+ : null,
+ ),
+ focusNode: _password2FocusNode,
+ onChanged: (cnfPassword) {
+ setState(() {
+ _cnfPassword = cnfPassword;
+ if (_password != null || _password != '') {
+ _passwordsMatch = _password == _cnfPassword;
+ }
+ });
+ },
),
- border: UnderlineInputBorder(
- borderSide: BorderSide.none,
- borderRadius: BorderRadius.circular(6),
+ Opacity(
+ opacity: (_password != '') && _password1InFocus ? 1 : 0,
+ child: Padding(
+ padding: const EdgeInsets.symmetric(vertical: 8),
+ child: Text(
+ context.strings
+ .passwordStrength(passwordStrengthText),
+ style: TextStyle(
+ color: passwordStrengthColor,
+ fontWeight: FontWeight.w500,
+ fontSize: 12,
+ ),
+ ),
+ ),
),
- suffixIcon: InkWell(
- onTap: () {
- showToast(
- context,
- context.strings.hearUsExplanation,
- );
- },
- child: Icon(
- Icons.info_outline_rounded,
- color: getEnteColorScheme(context).strokeMuted,
+ const SizedBox(height: 8),
+ // Referral source field
+ Text(
+ context.strings.hearUsWhereTitle,
+ style: textTheme.bodyBold.copyWith(
+ color: colorScheme.textBase,
),
),
- ),
- onChanged: (value) {
- _referralSource = value.trim();
- },
- autocorrect: false,
- keyboardType: TextInputType.text,
- textInputAction: TextInputAction.next,
+ const SizedBox(height: 8),
+ TextFormField(
+ style: textTheme.body.copyWith(
+ color: colorScheme.textBase,
+ ),
+ decoration: InputDecoration(
+ fillColor: colorScheme.backdropBase,
+ filled: true,
+ hintText: context.strings.emailHint,
+ hintStyle: TextStyle(color: colorScheme.textMuted),
+ contentPadding: const EdgeInsets.symmetric(
+ horizontal: 16,
+ vertical: 14,
+ ),
+ border: OutlineInputBorder(
+ borderSide: BorderSide.none,
+ borderRadius: BorderRadius.circular(8),
+ ),
+ enabledBorder: OutlineInputBorder(
+ borderSide: BorderSide.none,
+ borderRadius: BorderRadius.circular(8),
+ ),
+ ),
+ onChanged: (value) {
+ _referralSource = value.trim();
+ },
+ autocorrect: false,
+ keyboardType: TextInputType.text,
+ textInputAction: TextInputAction.next,
+ ),
+ ],
),
),
- const Divider(thickness: 1),
- const SizedBox(height: 12),
+ const SizedBox(height: 16),
_getAgreement(),
+ const SizedBox(height: 16),
+ // Dots indicator
+ Center(
+ child: DotsIndicator(
+ dotsCount: 3,
+ position: 0,
+ decorator: DotsDecorator(
+ activeColor: colorScheme.primary700,
+ color: colorScheme.primary700.withValues(alpha: 0.32),
+ activeShape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(14),
+ ),
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(14),
+ ),
+ size: const Size(10, 10),
+ activeSize: const Size(20, 10),
+ spacing: const EdgeInsets.all(6),
+ ),
+ ),
+ ),
const SizedBox(height: 40),
],
),
diff --git a/mobile/packages/accounts/lib/pages/two_factor_authentication_page.dart b/mobile/packages/accounts/lib/pages/two_factor_authentication_page.dart
index 29cd484aca..68e34cb067 100644
--- a/mobile/packages/accounts/lib/pages/two_factor_authentication_page.dart
+++ b/mobile/packages/accounts/lib/pages/two_factor_authentication_page.dart
@@ -1,5 +1,6 @@
import 'package:ente_accounts/ente_accounts.dart';
import 'package:ente_strings/ente_strings.dart';
+import 'package:ente_ui/components/buttons/dynamic_fab.dart';
import 'package:ente_ui/lifecycle_event_handler.dart';
import 'package:ente_ui/theme/ente_theme.dart';
import 'package:flutter/material.dart';
@@ -19,6 +20,7 @@ class TwoFactorAuthenticationPage extends StatefulWidget {
class _TwoFactorAuthenticationPageState
extends State<TwoFactorAuthenticationPage> {
final _pinController = TextEditingController();
+ final _pinFocusNode = FocusNode();
String _code = "";
late LifecycleEventHandler _lifecycleEventHandler;
@@ -35,128 +37,183 @@ class _TwoFactorAuthenticationPageState
},
);
WidgetsBinding.instance.addObserver(_lifecycleEventHandler);
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ _pinFocusNode.requestFocus();
+ });
super.initState();
}
@override
void dispose() {
WidgetsBinding.instance.removeObserver(_lifecycleEventHandler);
+ _pinFocusNode.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
+ final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100;
final colorScheme = getEnteColorScheme(context);
- // TODO: Use primary500 instead of strokeMuted once theming is properly
- // set up for Locker app to show app-specific colors. Currently,
- // colorScheme.primary500 doesn't work on Locker app.
- final pinPutDecoration = PinTheme(
- height: 45,
- width: 45,
- decoration: BoxDecoration(
- border: Border.all(color: colorScheme.strokeMuted),
- borderRadius: BorderRadius.circular(15.0),
- ),
- );
+ FloatingActionButtonLocation? fabLocation() {
+ if (isKeypadOpen) {
+ return null;
+ } else {
+ return FloatingActionButtonLocation.centerFloat;
+ }
+ }
return Scaffold(
+ resizeToAvoidBottomInset: isKeypadOpen,
+ backgroundColor: colorScheme.backgroundBase,
appBar: AppBar(
- title: Text(
- context.strings.twoFactorAuthTitle,
+ elevation: 0,
+ backgroundColor: colorScheme.backgroundBase,
+ centerTitle: true,
+ title: Image.asset(
+ 'assets/locker-logo-blue.png',
+ height: 24,
+ ),
+ leading: IconButton(
+ icon: const Icon(Icons.arrow_back),
+ color: colorScheme.primary700,
+ onPressed: () {
+ Navigator.of(context).pop();
+ },
),
),
- body: _getBody(pinPutDecoration),
+ body: _getBody(),
+ floatingActionButton: DynamicFAB(
+ isKeypadOpen: isKeypadOpen,
+ isFormValid: _code.length == 6,
+ buttonText: context.strings.verify,
+ onPressedFunction: () async {
+ await _verifyTwoFactorCode(_code);
+ },
+ ),
+ floatingActionButtonLocation: fabLocation(),
+ floatingActionButtonAnimator: NoScalingAnimation(),
);
}
- Widget _getBody(PinTheme pinPutDecoration) {
+ Widget _getBody() {
final colorScheme = getEnteColorScheme(context);
- return Column(
- crossAxisAlignment: CrossAxisAlignment.stretch,
- mainAxisAlignment: MainAxisAlignment.center,
- mainAxisSize: MainAxisSize.max,
- children: [
- Text(
- context.strings.enterCodeHint,
- style: const TextStyle(
- height: 1.4,
- fontSize: 16,
- ),
- textAlign: TextAlign.center,
+ final textTheme = getEnteTextTheme(context);
+
+ final defaultPinTheme = PinTheme(
+ height: 48,
+ width: 48,
+ decoration: BoxDecoration(
+ color: colorScheme.backdropBase,
+ border: Border.all(
+ color: colorScheme.strokeFaint,
+ width: 1.75,
+ ),
+ borderRadius: BorderRadius.circular(18),
+ ),
+ );
+
+ final focusedPinTheme = defaultPinTheme.copyWith(
+ decoration: BoxDecoration(
+ color: colorScheme.backdropBase,
+ border: Border.all(
+ color: colorScheme.primary700,
+ width: 1.75,
),
- const Padding(padding: EdgeInsets.all(32)),
- Padding(
- padding: const EdgeInsets.fromLTRB(40, 0, 40, 0),
- child: Pinput(
- length: 6,
- onCompleted: (String code) {
- _verifyTwoFactorCode(code);
- },
- onChanged: (String pin) {
- setState(() {
- _code = pin;
- });
- },
- controller: _pinController,
- submittedPinTheme: pinPutDecoration.copyWith(
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(20.0),
- border: Border.all(
- color: colorScheme.strokeMuted.withValues(alpha: 0.5),
+ borderRadius: BorderRadius.circular(18),
+ ),
+ );
+
+ final submittedPinTheme = defaultPinTheme.copyWith(
+ textStyle: textTheme.h3Bold.copyWith(
+ color: colorScheme.primary700,
+ ),
+ decoration: BoxDecoration(
+ color: colorScheme.backdropBase,
+ border: Border.all(
+ color: colorScheme.strokeFaint,
+ width: 1.75,
+ ),
+ borderRadius: BorderRadius.circular(18),
+ ),
+ );
+
+ return SafeArea(
+ child: SingleChildScrollView(
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.center,
+ children: [
+ const SizedBox(height: 24),
+ Image.asset(
+ 'packages/ente_lock_screen/assets/locker_pin.png',
+ height: 120,
+ ),
+ const SizedBox(height: 24),
+ Text(
+ context.strings.twoFactorAuthTitle,
+ style: textTheme.body.copyWith(
+ color: colorScheme.textBase,
),
+ textAlign: TextAlign.center,
),
- ),
- defaultPinTheme: pinPutDecoration,
- followingPinTheme: pinPutDecoration.copyWith(
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(10.0),
- border: Border.all(
- color: colorScheme.strokeMuted.withValues(alpha: 0.5),
+ const SizedBox(height: 8),
+ Text(
+ context.strings.enterCodeHint,
+ style: textTheme.small.copyWith(
+ color: colorScheme.textMuted,
),
+ textAlign: TextAlign.center,
),
- ),
- autofocus: true,
- ),
- ),
- const Padding(padding: EdgeInsets.all(24)),
- Container(
- padding: const EdgeInsets.fromLTRB(80, 0, 80, 0),
- width: double.infinity,
- height: 64,
- child: OutlinedButton(
- onPressed: _code.length == 6
- ? () async {
- await _verifyTwoFactorCode(_code);
- }
- : null,
- child: Text(context.strings.verify),
- ),
- ),
- const Padding(padding: EdgeInsets.all(30)),
- GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: () {
- UserService.instance.recoverTwoFactor(
- context,
- widget.sessionID,
- TwoFactorType.totp,
- );
- },
- child: Container(
- padding: const EdgeInsets.all(10),
- child: Center(
- child: Text(
- context.strings.lostDeviceTitle,
- style: const TextStyle(
- decoration: TextDecoration.underline,
- fontSize: 12,
+ const SizedBox(height: 32),
+ Pinput(
+ length: 6,
+ controller: _pinController,
+ focusNode: _pinFocusNode,
+ autofocus: true,
+ defaultPinTheme: defaultPinTheme,
+ focusedPinTheme: focusedPinTheme,
+ submittedPinTheme: submittedPinTheme,
+ showCursor: false,
+ onCompleted: (String code) {
+ _verifyTwoFactorCode(code);
+ },
+ onChanged: (String pin) {
+ setState(() {
+ _code = pin;
+ });
+ },
+ ),
+ const SizedBox(height: 8),
+ Align(
+ alignment: Alignment.centerRight,
+ child: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () {
+ UserService.instance.recoverTwoFactor(
+ context,
+ widget.sessionID,
+ TwoFactorType.totp,
+ );
+ },
+ child: Padding(
+ padding: const EdgeInsets.all(10),
+ child: Text(
+ context.strings.lostDeviceTitle,
+ style: textTheme.small.copyWith(
+ color: colorScheme.primary700,
+ decoration: TextDecoration.underline,
+ decorationColor: colorScheme.primary700,
+ ),
+ ),
+ ),
),
),
- ),
+ ],
),
),
- ],
+ ),
);
}
diff --git a/mobile/packages/strings/lib/l10n/arb/strings_en.arb b/mobile/packages/strings/lib/l10n/arb/strings_en.arb
index cf269b56a5..87e5f047f8 100644
--- a/mobile/packages/strings/lib/l10n/arb/strings_en.arb
+++ b/mobile/packages/strings/lib/l10n/arb/strings_en.arb
@@ -317,6 +317,10 @@
"@logInLabel": {
"description": "Log in button label"
},
+ "alreadyHaveAccount": "Already have an account?",
+ "@alreadyHaveAccount": {
+ "description": "Text asking if user already has an account"
+ },
"welcomeBack": "Welcome back!",
"@welcomeBack": {
"description": "Welcome back message"