Skip to content

Commit

Permalink
Don't unfocus text fields when data is valid
Browse files Browse the repository at this point in the history
  • Loading branch information
bbedward committed Aug 25, 2019
1 parent 58f15c1 commit ed6a397
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
1 change: 0 additions & 1 deletion lib/ui/intro/intro_import_private_key.dart
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ class _IntroImportPrivateKeyPageState extends State<IntroImportPrivateKeyPage> {

void onKeyTextChanged(String newText) {
if (privateKeyIsValid(newText)) {
privateKeyFocusNode.unfocus();
setState(() {
_privateKeyValid = true;
_showPrivateKeyError = false;
Expand Down
34 changes: 30 additions & 4 deletions lib/ui/settings/backup_private_key/encrypt_private_key_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ class _EncryptPrivateKeySheetState extends State<EncryptPrivateKeySheet> {

String passwordError;

bool passwordsMatch;

@override
void initState() {
super.initState();
this.passwordsMatch = false;
this.passwordFocusNode = FocusNode();
this.confirmPasswordFocusNode = FocusNode();
this.passwordController = TextEditingController();
Expand Down Expand Up @@ -142,7 +145,7 @@ class _EncryptPrivateKeySheetState extends State<EncryptPrivateKeySheet> {
child: AppTextField(
label: AppLocalization.of(context)
.newPasswordTextFieldHeader,
style: AppStyles.paragraphMedium(context),
style: this.passwordsMatch ? AppStyles.paragraphMediumPrimary(context) : AppStyles.paragraphMedium(context),
maxLines: 1,
passwordField: true,
focusNode: passwordFocusNode,
Expand All @@ -153,6 +156,20 @@ class _EncryptPrivateKeySheetState extends State<EncryptPrivateKeySheet> {
passwordError = null;
});
}
if (confirmPasswordController.text ==
passwordController.text) {
if (mounted) {
setState(() {
passwordsMatch = true;
});
}
} else {
if (mounted) {
setState(() {
passwordsMatch = false;
});
}
}
},
),
),
Expand All @@ -163,7 +180,7 @@ class _EncryptPrivateKeySheetState extends State<EncryptPrivateKeySheet> {
child: AppTextField(
label: AppLocalization.of(context)
.confirmPasswordTextFieldHeader,
style: AppStyles.paragraphMedium(context),
style: this.passwordsMatch ? AppStyles.paragraphMediumPrimary(context) : AppStyles.paragraphMedium(context),
maxLines: 1,
passwordField: true,
focusNode: confirmPasswordFocusNode,
Expand All @@ -176,8 +193,17 @@ class _EncryptPrivateKeySheetState extends State<EncryptPrivateKeySheet> {
}
if (confirmPasswordController.text ==
passwordController.text) {
confirmPasswordFocusNode.unfocus();
passwordFocusNode.unfocus();
if (mounted) {
setState(() {
passwordsMatch = true;
});
}
} else {
if (mounted) {
setState(() {
passwordsMatch = false;
});
}
}
},
),
Expand Down
10 changes: 10 additions & 0 deletions lib/ui/util/text_styles.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ class AppStyles {
fontWeight: FontWeight.w500);
}

static TextStyle paragraphMediumPrimary(BuildContext context) {
return TextStyle(
fontFamily: "Metropolis",
fontFamilyFallback: ["RobotoRegular"],
color: StateContainer.of(context).curTheme.primary,
fontSize: 14.0,
height: 1.3,
fontWeight: FontWeight.w500);
}

// For paragraphs
static TextStyle paragraphPrimary(BuildContext context) {
return TextStyle(
Expand Down

0 comments on commit ed6a397

Please sign in to comment.