feat: add default loginOptions

This commit is contained in:
mike doornenbal 2024-04-17 11:05:58 +02:00
parent aeb0a93c8d
commit d828e2306c
4 changed files with 130 additions and 7 deletions

View file

@ -1,3 +1,7 @@
## 6.0.2
* Added more default loginOptions for login, forgot password and register.
## 6.0.1
* Added default loginOptions for email and password fields.

View file

@ -35,14 +35,131 @@ class LoginOptions {
this.forgotPasswordSpacerOptions = const ForgotPasswordSpacerOptions(),
});
factory LoginOptions.defaults() => const LoginOptions(
emailDecoration: InputDecoration(
labelText: 'Email',
hintText: 'Enter your email',
factory LoginOptions.defaults() => LoginOptions(
spacers: const LoginSpacerOptions(
spacerBeforeTitle: 8,
spacerAfterTitle: 2,
formFlexValue: 2,
),
passwordDecoration: InputDecoration(
title: const Text(
'Log in',
style: TextStyle(
color: Color(0xff71C6D1),
fontWeight: FontWeight.w800,
fontSize: 24,
),
),
emailDecoration: const InputDecoration(
contentPadding: EdgeInsets.symmetric(horizontal: 8),
labelText: 'Email address',
border: OutlineInputBorder(),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Color(0xff71C6D1),
),
),
labelStyle: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w400,
fontSize: 16,
),
),
passwordDecoration: const InputDecoration(
contentPadding: EdgeInsets.symmetric(horizontal: 8),
labelText: 'Password',
hintText: 'Enter your password',
border: OutlineInputBorder(),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Color(0xff71C6D1),
),
),
labelStyle: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w400,
fontSize: 16,
),
),
loginButtonBuilder:
(context, onPressed, isDisabled, onDisabledPress, options) =>
InkWell(
onTap: () async => onPressed.call(),
child: Container(
height: 44,
width: 254,
decoration: const BoxDecoration(
color: Color(0xff71C6D1),
borderRadius: BorderRadius.all(Radius.circular(20)),
),
child: const Center(
child: Text(
'Log in',
style: TextStyle(
fontWeight: FontWeight.w800,
fontSize: 20,
color: Colors.white,
),
),
),
),
),
registrationButtonBuilder:
(context, onPressed, isDisabled, onDisabledPress, options) =>
TextButton(
onPressed: () async {
await onPressed.call();
},
child: const Text(
'Create account',
style: TextStyle(
decoration: TextDecoration.underline,
decorationColor: Color(0xff71C6D1),
color: Color(0xff71C6D1),
fontSize: 18,
fontWeight: FontWeight.w800,
),
),
),
forgotPasswordButtonBuilder:
(context, onPressed, isDisabled, onDisabledPress, options) =>
TextButton(
onPressed: () async {
await onPressed.call();
},
child: const Text(
'Forgot password?',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w500,
color: Color(0xff8D8D8D),
),
),
),
forgotPasswordSpacerOptions: const ForgotPasswordSpacerOptions(
spacerAfterButton: 3,
spacerBeforeTitle: 1,
),
requestForgotPasswordButtonBuilder:
(context, onPressed, isDisabled, onDisabledPress, options) =>
InkWell(
onTap: onPressed,
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: const Color(0xff71C6D1),
),
height: 44,
width: 254,
child: const Center(
child: Text(
'Send link',
style: TextStyle(
fontWeight: FontWeight.w800,
fontSize: 20,
color: Colors.white,
),
),
),
),
),
);

View file

@ -204,6 +204,8 @@ class _EmailPasswordLoginFormState extends State<EmailPasswordLoginForm> {
options,
),
),
] else ...[
const SizedBox(height: 16),
],
if (options.spacers.spacerAfterForm != null) ...[
Spacer(flex: options.spacers.spacerAfterForm!),

View file

@ -1,6 +1,6 @@
name: flutter_login
description: Flutter Login Component
version: 6.0.1
version: 6.0.2
environment:
sdk: ">=2.18.1 <3.0.0"