diff --git a/lib/components/my_textfield.dart b/lib/components/my_textfield.dart index e9d5c3e..2026bee 100644 --- a/lib/components/my_textfield.dart +++ b/lib/components/my_textfield.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -class MyTextField extends StatelessWidget { +class MyTextField extends StatefulWidget { final String hintText; final bool obscureText; final TextEditingController controller; @@ -14,14 +14,33 @@ class MyTextField extends StatelessWidget { this.focusNode, }); + @override + State createState() => _MyTextFieldState(); +} + +class _MyTextFieldState extends State { + late bool _visibleText; + + @override + void initState() { + super.initState(); + _visibleText = widget.obscureText; + } + + void _toggleObscureText() { + setState(() { + _visibleText = !_visibleText; + }); + } + @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.symmetric(horizontal: 25.0, vertical: 8), child: TextField( - obscureText: obscureText, - controller: controller, - focusNode: focusNode, + obscureText: _visibleText, + controller: widget.controller, + focusNode: widget.focusNode, decoration: InputDecoration( enabledBorder: OutlineInputBorder( borderSide: @@ -32,7 +51,15 @@ class MyTextField extends StatelessWidget { BorderSide(color: Theme.of(context).colorScheme.primary), ), filled: true, - hintText: hintText, + hintText: widget.hintText, + suffixIcon: widget.obscureText + ? IconButton( + icon: Icon( + _visibleText ? Icons.visibility : Icons.visibility_off, + ), + onPressed: _toggleObscureText, + ) + : null, ), ), ); diff --git a/lib/pages/register_page.dart b/lib/pages/register_page.dart index b610b3e..11565d8 100644 --- a/lib/pages/register_page.dart +++ b/lib/pages/register_page.dart @@ -45,7 +45,8 @@ class RegisterPage extends StatelessWidget { } } } else { - showMsg(context, 'Registration error', 'Passwords do not match!'); + showMsg(context, 'Password Mismatch', + 'Password and repeated password do not match!'); } } diff --git a/lib/services/auth/auth_service.dart b/lib/services/auth/auth_service.dart index ea65860..7992ca6 100644 --- a/lib/services/auth/auth_service.dart +++ b/lib/services/auth/auth_service.dart @@ -12,7 +12,7 @@ class AuthService { /// sign in (login) /// /// @throws FirebaseAuthException - Future signInWithEmailPassword(String email, password) async { + Future signInWithEmailPassword(String email, String password) async { try { UserCredential userCredential = await _auth.signInWithEmailAndPassword( email: email,