mirror of
https://github.com/Iconica-Development/flutter_login_widget.git
synced 2025-05-19 21:53:45 +02:00
Merge pull request #5 from Iconica-Development/feature/add-forget-password-validation
feat: add password validation and fix initialEmail
This commit is contained in:
commit
b29872f534
6 changed files with 37 additions and 10 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
## 2.0.0
|
||||||
|
|
||||||
|
* add forgot password validation on button press
|
||||||
|
* add onDisabledPress param for methods
|
||||||
|
* correctly use initialEmail in forgot password screen
|
||||||
|
|
||||||
|
|
||||||
## 0.0.1
|
## 0.0.1
|
||||||
|
|
||||||
* TODO: Describe initial release.
|
* TODO: Describe initial release.
|
||||||
|
|
|
@ -11,11 +11,16 @@ final loginOptions = LoginOptions(
|
||||||
passwordInputPrefix: const Icon(Icons.password),
|
passwordInputPrefix: const Icon(Icons.password),
|
||||||
title: const Text('Login'),
|
title: const Text('Login'),
|
||||||
image: const FlutterLogo(),
|
image: const FlutterLogo(),
|
||||||
requestForgotPasswordButtonBuilder: (context, onPressed, isDisabled) {
|
requestForgotPasswordButtonBuilder: (
|
||||||
|
context,
|
||||||
|
onPressed,
|
||||||
|
isDisabled,
|
||||||
|
onDisabledPress,
|
||||||
|
) {
|
||||||
return Opacity(
|
return Opacity(
|
||||||
opacity: isDisabled ? 0.5 : 1.0,
|
opacity: isDisabled ? 0.5 : 1.0,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
onPressed: onPressed,
|
onPressed: isDisabled ? onDisabledPress : onPressed,
|
||||||
child: const Text('Send request'),
|
child: const Text('Send request'),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -71,11 +71,12 @@ Widget _createLoginButton(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
OptionalAsyncCallback onPressed,
|
OptionalAsyncCallback onPressed,
|
||||||
bool disabled,
|
bool disabled,
|
||||||
|
OptionalAsyncCallback onDisabledPress,
|
||||||
) {
|
) {
|
||||||
return Opacity(
|
return Opacity(
|
||||||
opacity: disabled ? 0.5 : 1.0,
|
opacity: disabled ? 0.5 : 1.0,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
onPressed: onPressed,
|
onPressed: !disabled ? onPressed : onDisabledPress,
|
||||||
child: const Text('Login'),
|
child: const Text('Login'),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -85,11 +86,12 @@ Widget _createForgotPasswordButton(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
OptionalAsyncCallback onPressed,
|
OptionalAsyncCallback onPressed,
|
||||||
bool disabled,
|
bool disabled,
|
||||||
|
OptionalAsyncCallback onDisabledPress,
|
||||||
) {
|
) {
|
||||||
return Opacity(
|
return Opacity(
|
||||||
opacity: disabled ? 0.5 : 1.0,
|
opacity: disabled ? 0.5 : 1.0,
|
||||||
child: TextButton(
|
child: ElevatedButton(
|
||||||
onPressed: onPressed,
|
onPressed: !disabled ? onPressed : onDisabledPress,
|
||||||
child: const Text('Forgot password?'),
|
child: const Text('Forgot password?'),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -99,11 +101,12 @@ Widget _createRequestForgotPasswordButton(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
OptionalAsyncCallback onPressed,
|
OptionalAsyncCallback onPressed,
|
||||||
bool disabled,
|
bool disabled,
|
||||||
|
OptionalAsyncCallback onDisabledPress,
|
||||||
) {
|
) {
|
||||||
return Opacity(
|
return Opacity(
|
||||||
opacity: disabled ? 0.5 : 1.0,
|
opacity: disabled ? 0.5 : 1.0,
|
||||||
child: TextButton(
|
child: ElevatedButton(
|
||||||
onPressed: onPressed,
|
onPressed: !disabled ? onPressed : onDisabledPress,
|
||||||
child: const Text('Send request'),
|
child: const Text('Send request'),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -113,11 +116,12 @@ Widget _createRegisterButton(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
OptionalAsyncCallback onPressed,
|
OptionalAsyncCallback onPressed,
|
||||||
bool disabled,
|
bool disabled,
|
||||||
|
OptionalAsyncCallback onDisabledPress,
|
||||||
) {
|
) {
|
||||||
return Opacity(
|
return Opacity(
|
||||||
opacity: disabled ? 0.5 : 1.0,
|
opacity: disabled ? 0.5 : 1.0,
|
||||||
child: TextButton(
|
child: ElevatedButton(
|
||||||
onPressed: onPressed,
|
onPressed: !disabled ? onPressed : onDisabledPress,
|
||||||
child: const Text('Create Account'),
|
child: const Text('Create Account'),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -127,6 +131,7 @@ typedef ButtonBuilder = Widget Function(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
OptionalAsyncCallback onPressed,
|
OptionalAsyncCallback onPressed,
|
||||||
bool isDisabled,
|
bool isDisabled,
|
||||||
|
OptionalAsyncCallback onDisabledPress,
|
||||||
);
|
);
|
||||||
|
|
||||||
typedef InputContainerBuilder = Widget Function(
|
typedef InputContainerBuilder = Widget Function(
|
||||||
|
|
|
@ -159,6 +159,7 @@ class _EmailPasswordLoginFormState extends State<EmailPasswordLoginForm> {
|
||||||
widget.onForgotPassword?.call(_currentEmail);
|
widget.onForgotPassword?.call(_currentEmail);
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
|
() {},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -170,6 +171,9 @@ class _EmailPasswordLoginFormState extends State<EmailPasswordLoginForm> {
|
||||||
context,
|
context,
|
||||||
_handleLogin,
|
_handleLogin,
|
||||||
!_formValid.value,
|
!_formValid.value,
|
||||||
|
() {
|
||||||
|
_formKey.currentState?.validate();
|
||||||
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -183,6 +187,7 @@ class _EmailPasswordLoginFormState extends State<EmailPasswordLoginForm> {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
|
() {},
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
|
|
@ -33,6 +33,7 @@ class _ForgotPasswordFormState extends State<ForgotPasswordForm> {
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_focusNode.requestFocus();
|
_focusNode.requestFocus();
|
||||||
|
_currentEmail = widget.initialEmail ?? widget.options.initialEmail;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -123,11 +124,15 @@ class _ForgotPasswordFormState extends State<ForgotPasswordForm> {
|
||||||
child: widget.options.requestForgotPasswordButtonBuilder(
|
child: widget.options.requestForgotPasswordButtonBuilder(
|
||||||
context,
|
context,
|
||||||
() {
|
() {
|
||||||
|
_formKey.currentState?.validate();
|
||||||
if (_formValid.value) {
|
if (_formValid.value) {
|
||||||
widget.onRequestForgotPassword(_currentEmail);
|
widget.onRequestForgotPassword(_currentEmail);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
!_formValid.value,
|
!_formValid.value,
|
||||||
|
() {
|
||||||
|
_formKey.currentState?.validate();
|
||||||
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: flutter_login
|
name: flutter_login
|
||||||
description: A new Flutter package project.
|
description: A new Flutter package project.
|
||||||
version: 1.0.0
|
version: 2.0.0
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.18.1 <3.0.0"
|
sdk: ">=2.18.1 <3.0.0"
|
||||||
|
|
Loading…
Reference in a new issue