Skip to content

Commit

Permalink
feat(mobile): Adds show password field to login (#6918)
Browse files Browse the repository at this point in the history
Adds show password field to login
  • Loading branch information
martyfuhry committed Feb 5, 2024
1 parent 8e4bf30 commit f6b4024
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions mobile/lib/modules/login/ui/login_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ class EmailInput extends StatelessWidget {
}
}

class PasswordInput extends StatelessWidget {
class PasswordInput extends HookConsumerWidget {
final TextEditingController controller;
final FocusNode? focusNode;
final Function()? onSubmit;
Expand All @@ -528,9 +528,11 @@ class PasswordInput extends StatelessWidget {
});

@override
Widget build(BuildContext context) {
Widget build(BuildContext context, WidgetRef ref) {
final isPasswordVisible = useState<bool>(false);

return TextFormField(
obscureText: true,
obscureText: !isPasswordVisible.value,
controller: controller,
decoration: InputDecoration(
labelText: 'login_form_label_password'.tr(),
Expand All @@ -540,6 +542,14 @@ class PasswordInput extends StatelessWidget {
fontWeight: FontWeight.normal,
fontSize: 14,
),
suffixIcon: IconButton(
onPressed: () => isPasswordVisible.value = !isPasswordVisible.value,
icon: Icon(
isPasswordVisible.value
? Icons.visibility_off_sharp
: Icons.visibility_sharp,
),
),
),
autofillHints: const [AutofillHints.password],
keyboardType: TextInputType.text,
Expand Down

0 comments on commit f6b4024

Please sign in to comment.