Skip to content

Commit

Permalink
feat: Autofill and showing passsword for login
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusz-bak committed Jan 1, 2023
1 parent 15a4251 commit 720303a
Showing 1 changed file with 53 additions and 31 deletions.
84 changes: 53 additions & 31 deletions lib/ui/login_screen/login_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class LoginScreen extends StatefulWidget {
class _LoginScreenState extends State<LoginScreen> {
bool _loading = false;
bool _loginError = false;
bool _passwordVisible = false;

final _emailController = TextEditingController();
final _passwordController = TextEditingController();
Expand Down Expand Up @@ -107,37 +108,58 @@ class _LoginScreenState extends State<LoginScreen> {
],
),
const SizedBox(height: 30),
Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
color: const Color(0xff2295F3).withAlpha(30),
borderRadius: BorderRadius.circular(5),
),
child: TextField(
controller: _emailController,
textInputAction: TextInputAction.next,
decoration: const InputDecoration.collapsed(
hintText: 'Email',
),
),
),
const SizedBox(height: 10),
Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
color: const Color(0xff2295F3).withAlpha(30),
borderRadius: BorderRadius.circular(5),
),
child: TextField(
controller: _passwordController,
textInputAction: TextInputAction.done,
obscureText: true,
decoration: const InputDecoration.collapsed(
hintText: 'Hasło',
),
onSubmitted: (_) {
_loading ? null : _login(context);
},
AutofillGroup(
child: Column(
children: [
Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
color: const Color(0xff2295F3).withAlpha(30),
borderRadius: BorderRadius.circular(5),
),
child: TextField(
controller: _emailController,
autofillHints: const [AutofillHints.email],
textInputAction: TextInputAction.next,
decoration: const InputDecoration(
hintText: 'Email',
border: InputBorder.none,
),
),
),
const SizedBox(height: 15),
Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
color: const Color(0xff2295F3).withAlpha(30),
borderRadius: BorderRadius.circular(5),
),
child: TextField(
controller: _passwordController,
autofillHints: const [AutofillHints.password],
textInputAction: TextInputAction.done,
obscureText: !_passwordVisible,
decoration: InputDecoration(
hintText: 'Hasło',
border: InputBorder.none,
suffixIcon: IconButton(
onPressed: () {
setState(() {
_passwordVisible = !_passwordVisible;
});
},
icon: Icon(
_passwordVisible
? Icons.visibility
: Icons.visibility_off,
),
)),
onSubmitted: (_) {
_loading ? null : _login(context);
},
),
),
],
),
),
const SizedBox(height: 30),
Expand Down

0 comments on commit 720303a

Please sign in to comment.