Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Password Validation #4

Merged
merged 4 commits into from
Aug 14, 2023
Merged

Update Password Validation #4

merged 4 commits into from
Aug 14, 2023

Conversation

cbhernan
Copy link
Collaborator

@cbhernan cbhernan commented Jul 20, 2023

What does this PR do?

This PR consolidates the Password field validations to use a single function to validate input. It also adds the icons to the password fields so that the user can toggle between password and text view on their input. It also enables the Change Password button to be enabled once all fields are filled.

Issue

#3

@cbhernan cbhernan marked this pull request as ready for review July 21, 2023 21:10
@cbhernan cbhernan self-assigned this Jul 26, 2023
@cbhernan cbhernan requested a review from a team July 26, 2023 18:49
@cbhernan cbhernan linked an issue Jul 27, 2023 that may be closed by this pull request
2 tasks
@Paz-X
Copy link
Contributor

Paz-X commented Aug 1, 2023

Hey @cbhernan , can you try the following code?

bool passwordVisible=false;  

TextField(
                  obscureText: passwordVisible,
                  decoration: InputDecoration(
                    border: UnderlineInputBorder(),
                    hintText: "Password",
                    labelText: "Password",
                    helperText:"Password must contain special character",
                    helperStyle:TextStyle(color:Colors.green),
                    suffixIcon: IconButton(
                      icon: Icon(passwordVisible
                          ? Icons.visibility
                          : Icons.visibility_off),
                      onPressed: () {
                        setState(
                          () {
                            passwordVisible = !passwordVisible;
                          },
                        );
                      },
                    ),
                    alignLabelWithHint: false,
                    filled: true,
                  ),
                  keyboardType: TextInputType.visiblePassword,
                  textInputAction: TextInputAction.done,
                ),
              ), 
      ),

I noticed you are using variables to determine if the password is visible or not. I think it can all be added to the widget itself instead of the class.

https://www.geeksforgeeks.org/flutter-show-hide-password-in-textfield/

I agree with the validator, we should try to make it into a function.

Also, let's remove import 'package:flutter/cupertino.dart'; since that is iOS specific.

@cbhernan
Copy link
Collaborator Author

cbhernan commented Aug 7, 2023

@Paz-X Thank you for finding the correct icons, I've replaced them and removed the Cupertino icons.

You're right that I could just use the variable instead of using a ternary for obscureText so I'll make that update.

The validator is currently a function, it's called validatePasswords and can be found here

Regarding your suggestion, do you want me to replace what's currently on the branch with it?

Copy link
Contributor

@nickchaula nickchaula left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Paz-X Paz-X merged commit 359b1a1 into development Aug 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Password Screen - Add Form Validation
3 participants