π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
refactor: Improve UI consistency and theming in password verification and entry pages
AmanRajSinghMouryafd853d1d3402
diff --git a/mobile/packages/accounts/lib/pages/login_pwd_verification_page.dart b/mobile/packages/accounts/lib/pages/login_pwd_verification_page.dartindex 48edb06d8c..e3a4f4d2a1 100644--- a/mobile/packages/accounts/lib/pages/login_pwd_verification_page.dart+++ b/mobile/packages/accounts/lib/pages/login_pwd_verification_page.dart@@ -34,10 +34,10 @@ class _LoginPasswordVerificationPageStateextends State<LoginPasswordVerificationPage> {final _logger = Logger((_LoginPasswordVerificationPageState).toString());final _passwordController = TextEditingController();- final FocusNode _passwordFocusNode = FocusNode();+ final _passwordFocusNode = FocusNode();String? email;- bool _passwordInFocus = false;bool _passwordVisible = false;+ bool _passwordInFocus = false;Future<void> onPressed() async {FocusScope.of(context).unfocus();@@ -58,6 +58,7 @@ class _LoginPasswordVerificationPageState@overrideWidget build(BuildContext context) {final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100;+ final colorScheme = getEnteColorScheme(context);FloatingActionButtonLocation? fabLocation() {if (isKeypadOpen) {@@ -69,11 +70,18 @@ class _LoginPasswordVerificationPageStatereturn Scaffold(resizeToAvoidBottomInset: isKeypadOpen,+ 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: Theme.of(context).iconTheme.color,+ color: colorScheme.primary700,onPressed: () {Navigator.of(context).pop();},@@ -206,6 +214,9 @@ class _LoginPasswordVerificationPageState}Widget _getBody() {+ final colorScheme = getEnteColorScheme(context);+ final textTheme = getEnteTextTheme(context);+return Column(children: [Expanded(@@ -213,142 +224,137 @@ class _LoginPasswordVerificationPageStatechild: ListView(children: [Padding(- padding: const EdgeInsets.only(top: 30, left: 20, right: 20),- child: Text(- context.strings.enterPassword,- style: Theme.of(context).textTheme.headlineMedium,- ),- ),- Padding(- padding: const EdgeInsets.only(- bottom: 30,- left: 22,- right: 20,- ),- child: Text(- email ?? '',- style: getEnteTextTheme(context).smallMuted,- ),- ),- Visibility(- // hidden textForm for suggesting auto-fill service for saving- // password- visible: false,- child: TextFormField(- autofillHints: const [- AutofillHints.email,- ],- autocorrect: false,- keyboardType: TextInputType.emailAddress,- initialValue: email,- textInputAction: TextInputAction.next,- ),- ),- Padding(- padding: const EdgeInsets.fromLTRB(20, 24, 20, 0),- child: TextFormField(- onFieldSubmitted: _passwordController.text.isNotEmpty- ? (_) => onPressed()- : null,- key: const ValueKey("passwordInputField"),- autofillHints: const [AutofillHints.password],- decoration: InputDecoration(- hintText: context.strings.enterYourPasswordHint,- filled: true,- contentPadding: const EdgeInsets.all(20),- border: UnderlineInputBorder(- borderSide: BorderSide.none,- borderRadius: BorderRadius.circular(6),- ),- suffixIcon: _passwordInFocus- ? IconButton(- icon: Icon(- _passwordVisible- ? Icons.visibility- : Icons.visibility_off,- color: Theme.of(context).iconTheme.color,- size: 20,- ),- onPressed: () {- setState(() {- _passwordVisible = !_passwordVisible;- });- },- )- : null,- ),- style: const TextStyle(- fontSize: 14,- ),- controller: _passwordController,- autofocus: true,- autocorrect: false,- obscureText: !_passwordVisible,- keyboardType: TextInputType.visiblePassword,- focusNode: _passwordFocusNode,- onChanged: (_) {- setState(() {});- },- ),- ),- const Padding(- padding: EdgeInsets.symmetric(vertical: 18),- child: Divider(- thickness: 1,- ),- ),- Padding(- padding: const EdgeInsets.symmetric(horizontal: 20),- child: Row(- mainAxisAlignment: MainAxisAlignment.spaceBetween,+ padding: const EdgeInsets.symmetric(horizontal: 16),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,children: [- GestureDetector(- behavior: HitTestBehavior.opaque,- onTap: () async {- await UserService.instance.sendOtt(- context,- email!,- isResetPasswordScreen: true,- );- },- child: Center(- child: Text(- context.strings.forgotPassword,- style: Theme.of(context)- .textTheme- .titleMedium!- .copyWith(- fontSize: 14,- decoration: TextDecoration.underline,- ),- ),+ const SizedBox(height: 24),+ Text(+ email ?? '',+ style: textTheme.small.copyWith(+ color: colorScheme.textMuted,),),- GestureDetector(- behavior: HitTestBehavior.opaque,- onTap: () async {- final dialog = createProgressDialog(- context,- context.strings.pleaseWait,- );- await dialog.show();- await widget.config.logout();- await dialog.hide();- Navigator.of(context)- .popUntil((route) => route.isFirst);- },- child: Center(- child: Text(- context.strings.changeEmail,- style: Theme.of(context)- .textTheme- .titleMedium!- .copyWith(- fontSize: 14,- decoration: TextDecoration.underline,- ),+ const SizedBox(height: 16),+ Text(+ context.strings.password,+ style: textTheme.bodyBold.copyWith(+ color: colorScheme.textBase,+ ),+ ),+ const SizedBox(height: 8),+ Visibility(+ // hidden textForm for suggesting auto-fill service for saving+ // password+ visible: false,+ child: TextFormField(+ autofillHints: const [+ AutofillHints.email,+ ],+ autocorrect: false,+ keyboardType: TextInputType.emailAddress,+ initialValue: email,+ textInputAction: TextInputAction.next,+ ),+ ),+ TextFormField(+ onFieldSubmitted: _passwordController.text.isNotEmpty+ ? (_) => onPressed()+ : null,+ key: const ValueKey("passwordInputField"),+ autofillHints: const [AutofillHints.password],+ decoration: InputDecoration(+ fillColor: 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: _passwordInFocus+ ? IconButton(+ icon: Icon(+ _passwordVisible+ ? Icons.visibility+ : Icons.visibility_off,+ color: colorScheme.textMuted,+ size: 20,+ ),+ onPressed: () {+ setState(() {+ _passwordVisible = !_passwordVisible;+ });+ },+ )+ : null,+ ),+ style: textTheme.body.copyWith(+ color: colorScheme.textBase,),+ controller: _passwordController,+ autofocus: true,+ autocorrect: false,+ obscureText: !_passwordVisible,+ keyboardType: TextInputType.visiblePassword,+ focusNode: _passwordFocusNode,+ onChanged: (_) {+ setState(() {});+ },+ ),+ const SizedBox(height: 16),+ Row(+ mainAxisAlignment: MainAxisAlignment.spaceBetween,+ children: [+ GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: () async {+ await UserService.instance.sendOtt(+ context,+ email!,+ isResetPasswordScreen: true,+ );+ },+ child: Text(+ "${context.strings.forgotPassword}?",+ style: textTheme.body.copyWith(+ color: colorScheme.primary700,+ decoration: TextDecoration.underline,+ decorationColor: colorScheme.primary700,+ ),+ ),+ ),+ GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: () async {+ final dialog = createProgressDialog(+ context,+ context.strings.pleaseWait,+ );+ await dialog.show();+ await widget.config.logout();+ await dialog.hide();+ Navigator.of(context)+ .popUntil((route) => route.isFirst);+ },+ child: Text(+ context.strings.changeEmail,+ style: textTheme.body.copyWith(+ color: colorScheme.primary700,+ decoration: TextDecoration.underline,+ decorationColor: colorScheme.primary700,+ ),+ ),+ ),+ ],),],),diff --git a/mobile/packages/accounts/lib/pages/password_entry_page.dart b/mobile/packages/accounts/lib/pages/password_entry_page.dartindex 85b6f63b25..87a06bf179 100644--- a/mobile/packages/accounts/lib/pages/password_entry_page.dart+++ b/mobile/packages/accounts/lib/pages/password_entry_page.dart@@ -97,6 +97,8 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {}}+ final colorScheme = getEnteColorScheme(context);+String title = context.strings.setPasswordTitle;if (widget.mode == PasswordEntryMode.update) {title = context.strings.changePasswordTitle;@@ -107,12 +109,19 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {}return Scaffold(resizeToAvoidBottomInset: isKeypadOpen,+ backgroundColor: colorScheme.backgroundBase,appBar: AppBar(+ backgroundColor: colorScheme.backgroundBase,+ centerTitle: true,+ title: Image.asset(+ 'assets/locker-logo-blue.png',+ height: 24,+ ),leading: widget.mode == PasswordEntryMode.reset? Container(): IconButton(icon: const Icon(Icons.arrow_back),- color: Theme.of(context).iconTheme.color,+ color: colorScheme.primary700,onPressed: () {Navigator.of(context).pop();},@@ -138,8 +147,11 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {);}- Widget _getBody(String buttonTextAndHeading) {+ Widget _getBody(String title) {final email = widget.config.getEmail();+ final colorScheme = getEnteColorScheme(context);+ final textTheme = getEnteTextTheme(context);+var passwordStrengthText = context.strings.weakStrength;var passwordStrengthColor = Colors.redAccent;if (_passwordStrength > kStrongPasswordStrengthThreshold) {@@ -149,6 +161,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {passwordStrengthText = context.strings.moderateStrength;passwordStrengthColor = Colors.orangeAccent;}+if (_volatilePassword != null) {return Container();}@@ -161,228 +174,248 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {child: ListView(children: [Padding(- padding: const EdgeInsets.symmetric(- vertical: 30,- horizontal: 20,- ),- child: Text(- buttonTextAndHeading,- style: Theme.of(context).textTheme.headlineMedium,- ),- ),- Padding(- padding: const EdgeInsets.symmetric(horizontal: 20),- child: Text(- widget.mode == PasswordEntryMode.set- ? context.strings.enterPasswordToEncrypt- : context.strings.enterNewPasswordToEncrypt,- textAlign: TextAlign.start,- style: Theme.of(context)- .textTheme- .titleMedium!- .copyWith(fontSize: 14),- ),- ),- const Padding(padding: EdgeInsets.all(8)),- Padding(- padding: const EdgeInsets.symmetric(horizontal: 20),- child: StyledText(- text: context.strings.passwordWarning,- style: Theme.of(context)- .textTheme- .titleMedium!- .copyWith(fontSize: 14),- tags: {- 'underline': StyledTextTag(- style:- Theme.of(context).textTheme.titleMedium!.copyWith(- fontSize: 14,- decoration: TextDecoration.underline,- ),+ padding: const EdgeInsets.symmetric(horizontal: 16),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ const SizedBox(height: 24),+ Text(+ title,+ style: textTheme.h3Bold.copyWith(+ color: colorScheme.textBase,+ ),),- },- ),- ),- const Padding(padding: EdgeInsets.all(12)),- Visibility(- // hidden textForm for suggesting auto-fill service for saving- // password- visible: false,- child: TextFormField(- autofillHints: const [- AutofillHints.email,- ],- autocorrect: false,- keyboardType: TextInputType.emailAddress,- initialValue: email,- textInputAction: TextInputAction.next,- ),- ),- Padding(- padding: const EdgeInsets.fromLTRB(20, 0, 20, 0),- child: TextFormField(- autofillHints: const [AutofillHints.newPassword],- onFieldSubmitted: (_) {- do {- FocusScope.of(context).nextFocus();- } while (FocusScope.of(context).focusedChild!.context ==- null);- },- decoration: InputDecoration(- fillColor: _isPasswordValid- ? _validFieldValueColor- : getEnteColorScheme(context).fillFaint,- filled: true,- hintText: context.strings.password,- contentPadding: const EdgeInsets.all(20),- border: UnderlineInputBorder(- borderSide: BorderSide.none,- borderRadius: BorderRadius.circular(6),+ const SizedBox(height: 8),+ Text(+ widget.mode == PasswordEntryMode.set+ ? context.strings.enterPasswordToEncrypt+ : context.strings.enterNewPasswordToEncrypt,+ textAlign: TextAlign.start,+ style: textTheme.small.copyWith(+ color: colorScheme.textMuted,+ ),),- suffixIcon: _password1InFocus- ? IconButton(- icon: Icon(- _password1Visible- ? Icons.visibility- : Icons.visibility_off,- color: Theme.of(context).iconTheme.color,- size: 20,- ),- onPressed: () {- setState(() {- _password1Visible = !_password1Visible;- });- },- )- : _isPasswordValid- ? Icon(- Icons.check,- color:- getEnteColorScheme(context).primary300,- )- : null,- ),- obscureText: !_password1Visible,- controller: _passwordController1,- autofocus: false,- autocorrect: false,- keyboardType: TextInputType.visiblePassword,- onChanged: (password) {- setState(() {- _passwordInInputBox = password;- _passwordStrength =- estimatePasswordStrength(password);- _isPasswordValid = _passwordStrength >=- kMildPasswordStrengthThreshold;- _passwordsMatch = _passwordInInputBox ==- _passwordInInputConfirmationBox;- });- },- textInputAction: TextInputAction.next,- focusNode: _password1FocusNode,- ),- ),- 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- ? _validFieldValueColor- : getEnteColorScheme(context).fillFaint,- filled: true,- hintText: context.strings.confirmPassword,- contentPadding: const EdgeInsets.symmetric(- horizontal: 20,- vertical: 20,+ const SizedBox(height: 8),+ StyledText(+ text: context.strings.passwordWarning,+ style: textTheme.small.copyWith(+ color: colorScheme.textMuted,+ ),+ tags: {+ 'underline': StyledTextTag(+ style: textTheme.small.copyWith(+ color: colorScheme.textMuted,+ decoration: TextDecoration.underline,+ ),+ ),+ },+ ),+ const SizedBox(height: 24),+ 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),+ Visibility(+ // hidden textForm for suggesting auto-fill service for saving+ // password+ visible: false,+ child: TextFormField(+ autofillHints: const [+ AutofillHints.email,+ ],+ autocorrect: false,+ keyboardType: TextInputType.emailAddress,+ initialValue: email,+ textInputAction: TextInputAction.next,+ ),+ ),+ TextFormField(+ autofillHints: const [AutofillHints.newPassword],+ onFieldSubmitted: (_) {+ do {+ FocusScope.of(context).nextFocus();+ } while (+ FocusScope.of(context).focusedChild!.context ==+ null);+ },+ decoration: InputDecoration(+ fillColor: _isPasswordValid+ ? _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),+ : _isPasswordValid+ ? Icon(+ Icons.check,+ color: colorScheme.primary700,+ )+ : null,+ ),+ style: textTheme.body.copyWith(+ color: colorScheme.textBase,+ ),+ obscureText: !_password1Visible,+ controller: _passwordController1,+ autofocus: false,+ autocorrect: false,+ keyboardType: TextInputType.visiblePassword,+ onChanged: (password) {+ setState(() {+ _passwordInInputBox = password;+ _passwordStrength =+ estimatePasswordStrength(password);+ _isPasswordValid = _passwordStrength >=+ kMildPasswordStrengthThreshold;+ _passwordsMatch = _passwordInInputBox ==+ _passwordInInputConfirmationBox;+ });+ },+ textInputAction: TextInputAction.next,+ focusNode: _password1FocusNode,),- ),- focusNode: _password2FocusNode,- onChanged: (cnfPassword) {- setState(() {- _passwordInInputConfirmationBox = cnfPassword;- if (_passwordInInputBox != '') {- _passwordsMatch = _passwordInInputBox ==- _passwordInInputConfirmationBox;- }- });- },- ),- ),- Opacity(- opacity: (_passwordInInputBox != '') && _password1InFocus- ? 1- : 0,- child: Padding(- padding: const EdgeInsets.symmetric(- horizontal: 20,- vertical: 8,- ),- child: Text(- context.strings.passwordStrength(passwordStrengthText),- style: TextStyle(- color: passwordStrengthColor,+ Opacity(+ opacity:+ (_passwordInInputBox != '') && _password1InFocus+ ? 1+ : 0,+ child: Padding(+ padding: const EdgeInsets.symmetric(vertical: 8),+ child: Text(+ context.strings+ .passwordStrength(passwordStrengthText),+ style: TextStyle(+ color: passwordStrengthColor,+ ),+ ),+ ),),- ),- ),- ),- const SizedBox(height: 8),- GestureDetector(- behavior: HitTestBehavior.translucent,- onTap: () {- PlatformUtil.openWebView(- context,- context.strings.howItWorks,- "https://ente.io/architecture",- );- },- child: Container(- padding: const EdgeInsets.symmetric(horizontal: 20),- child: RichText(- text: TextSpan(- text: context.strings.howItWorks,- style:- Theme.of(context).textTheme.titleMedium!.copyWith(- fontSize: 14,- decoration: TextDecoration.underline,- ),+ const SizedBox(height: 8),+ Text(+ context.strings.confirmPassword,+ style: textTheme.bodyBold.copyWith(+ color: colorScheme.textBase,+ ),),- ),+ const SizedBox(height: 8),+ TextFormField(+ keyboardType: TextInputType.visiblePassword,+ controller: _passwordController2,+ obscureText: !_password2Visible,+ autofillHints: const [AutofillHints.newPassword],+ onEditingComplete: () =>+ TextInput.finishAutofillContext(),+ decoration: InputDecoration(+ fillColor: _passwordsMatch+ ? _validFieldValueColor+ : colorScheme.backdropBase,+ filled: true,+ hintText: context.strings.enterYourPasswordHint,+ hintStyle: TextStyle(color: colorScheme.textMuted),+ contentPadding: const EdgeInsets.symmetric(+ horizontal: 16,+ vertical: 14,+ ),+ 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,+ border: OutlineInputBorder(+ borderSide: BorderSide.none,+ borderRadius: BorderRadius.circular(8),+ ),+ enabledBorder: OutlineInputBorder(+ borderSide: BorderSide.none,+ borderRadius: BorderRadius.circular(8),+ ),+ ),+ style: textTheme.body.copyWith(+ color: colorScheme.textBase,+ ),+ focusNode: _password2FocusNode,+ onChanged: (cnfPassword) {+ setState(() {+ _passwordInInputConfirmationBox = cnfPassword;+ if (_passwordInInputBox != '') {+ _passwordsMatch = _passwordInInputBox ==+ _passwordInInputConfirmationBox;+ }+ });+ },+ ),+ const SizedBox(height: 16),+ Align(+ alignment: Alignment.centerRight,+ child: GestureDetector(+ behavior: HitTestBehavior.translucent,+ onTap: () {+ PlatformUtil.openWebView(+ context,+ "${context.strings.howItWorks}?",+ "https://ente.io/architecture",+ );+ },+ child: Text(+ "${context.strings.howItWorks}?",+ style: textTheme.body.copyWith(+ color: colorScheme.primary700,+ decoration: TextDecoration.underline,+ decorationColor: colorScheme.primary700,+ ),+ ),+ ),+ ),+ const SizedBox(height: 20),+ ],),),- const Padding(padding: EdgeInsets.all(20)),],),),