mirror of
https://github.com/Iconica-Development/flutter_login_widget.git
synced 2025-05-19 13:43:44 +02:00
fix: change forgotpassword form layout
This commit is contained in:
parent
a25977fe58
commit
9e283f8be4
5 changed files with 105 additions and 96 deletions
|
@ -1,3 +1,7 @@
|
|||
## 6.0.0
|
||||
|
||||
* Changed ForgotPasswordform to use the same layout as the EmailPasswordLoginForm.
|
||||
|
||||
## 5.2.0
|
||||
|
||||
* Added spacer options for the ForogotPasswordForm.
|
||||
|
|
|
@ -68,7 +68,7 @@ packages:
|
|||
path: ".."
|
||||
relative: true
|
||||
source: path
|
||||
version: "5.1.4"
|
||||
version: "6.0.0"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
|
|
|
@ -102,7 +102,7 @@ class _EmailPasswordLoginFormState extends State<EmailPasswordLoginForm> {
|
|||
if (options.title != null) ...[
|
||||
Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: _wrapWithDefaultStyle(
|
||||
child: wrapWithDefaultStyle(
|
||||
options.title,
|
||||
theme.textTheme.headlineSmall,
|
||||
),
|
||||
|
@ -114,7 +114,7 @@ class _EmailPasswordLoginFormState extends State<EmailPasswordLoginForm> {
|
|||
if (options.subtitle != null) ...[
|
||||
Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: _wrapWithDefaultStyle(
|
||||
child: wrapWithDefaultStyle(
|
||||
options.subtitle,
|
||||
theme.textTheme.titleSmall,
|
||||
),
|
||||
|
@ -245,12 +245,12 @@ class _EmailPasswordLoginFormState extends State<EmailPasswordLoginForm> {
|
|||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget? _wrapWithDefaultStyle(Widget? widget, TextStyle? style) {
|
||||
if (style == null || widget == null) {
|
||||
return widget;
|
||||
} else {
|
||||
return DefaultTextStyle(style: style, child: widget);
|
||||
}
|
||||
Widget? wrapWithDefaultStyle(Widget? widget, TextStyle? style) {
|
||||
if (style == null || widget == null) {
|
||||
return widget;
|
||||
} else {
|
||||
return DefaultTextStyle(style: style, child: widget);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,106 +66,111 @@ class _ForgotPasswordFormState extends State<ForgotPasswordForm> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var options = widget.options;
|
||||
var theme = Theme.of(context);
|
||||
return Form(
|
||||
key: _formKey,
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(
|
||||
maxWidth: 300,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (options.forgotPasswordSpacerOptions.spacerBeforeTitle !=
|
||||
null) ...[
|
||||
Spacer(
|
||||
flex: options.forgotPasswordSpacerOptions.spacerBeforeTitle!,
|
||||
),
|
||||
],
|
||||
_wrapWithDefaultStyle(
|
||||
var options = widget.options;
|
||||
|
||||
return CustomScrollView(
|
||||
physics: const ScrollPhysics(),
|
||||
slivers: [
|
||||
SliverFillRemaining(
|
||||
hasScrollBody: false,
|
||||
fillOverscroll: true,
|
||||
child: Column(
|
||||
children: [
|
||||
if (options.forgotPasswordSpacerOptions.spacerBeforeTitle !=
|
||||
null) ...[
|
||||
Spacer(
|
||||
flex: options.forgotPasswordSpacerOptions.spacerBeforeTitle!,
|
||||
),
|
||||
],
|
||||
Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: wrapWithDefaultStyle(
|
||||
widget.title,
|
||||
theme.textTheme.displaySmall,
|
||||
) ??
|
||||
const SizedBox.shrink(),
|
||||
if (options.forgotPasswordSpacerOptions.spacerAfterTitle !=
|
||||
null) ...[
|
||||
Spacer(
|
||||
flex: options.forgotPasswordSpacerOptions.spacerAfterTitle!,
|
||||
),
|
||||
),
|
||||
],
|
||||
_wrapWithDefaultStyle(
|
||||
if (options.forgotPasswordSpacerOptions.spacerAfterTitle !=
|
||||
null) ...[
|
||||
Spacer(
|
||||
flex: options.forgotPasswordSpacerOptions.spacerAfterTitle!,
|
||||
),
|
||||
],
|
||||
Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: wrapWithDefaultStyle(
|
||||
widget.description,
|
||||
theme.textTheme.bodyMedium,
|
||||
) ??
|
||||
const SizedBox.shrink(),
|
||||
if (options.forgotPasswordSpacerOptions.spacerAfterDescription !=
|
||||
null) ...[
|
||||
Spacer(
|
||||
flex:
|
||||
options.forgotPasswordSpacerOptions.spacerAfterDescription!,
|
||||
),
|
||||
),
|
||||
],
|
||||
Expanded(
|
||||
flex: options.forgotPasswordSpacerOptions.formFlexValue,
|
||||
child: Align(
|
||||
child: options.emailInputContainerBuilder(
|
||||
TextFormField(
|
||||
focusNode: _focusNode,
|
||||
onChanged: _updateCurrentEmail,
|
||||
validator: widget.options.validations.validateEmail,
|
||||
initialValue: options.initialEmail,
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
textInputAction: TextInputAction.next,
|
||||
style: options.emailTextStyle,
|
||||
decoration: options.emailDecoration,
|
||||
if (options.forgotPasswordSpacerOptions.spacerAfterDescription !=
|
||||
null) ...[
|
||||
Spacer(
|
||||
flex: options
|
||||
.forgotPasswordSpacerOptions.spacerAfterDescription!,
|
||||
),
|
||||
],
|
||||
Expanded(
|
||||
flex: options.forgotPasswordSpacerOptions.formFlexValue,
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: options.maxFormWidth ?? 300,
|
||||
),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Align(
|
||||
alignment: Alignment.center,
|
||||
child: options.emailInputContainerBuilder(
|
||||
TextFormField(
|
||||
focusNode: _focusNode,
|
||||
onChanged: _updateCurrentEmail,
|
||||
validator: widget.options.validations.validateEmail,
|
||||
initialValue: options.initialEmail,
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
textInputAction: TextInputAction.next,
|
||||
style: options.emailTextStyle,
|
||||
decoration: options.emailDecoration,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (options.forgotPasswordSpacerOptions.spacerBeforeButton !=
|
||||
null) ...[
|
||||
Spacer(
|
||||
flex: options.forgotPasswordSpacerOptions.spacerBeforeButton!,
|
||||
),
|
||||
],
|
||||
AnimatedBuilder(
|
||||
animation: _formValid,
|
||||
builder: (context, snapshot) => Align(
|
||||
child: widget.options.requestForgotPasswordButtonBuilder(
|
||||
context,
|
||||
() async {
|
||||
_formKey.currentState?.validate();
|
||||
if (_formValid.value) {
|
||||
widget.onRequestForgotPassword(_currentEmail);
|
||||
}
|
||||
},
|
||||
!_formValid.value,
|
||||
() {
|
||||
_formKey.currentState?.validate();
|
||||
},
|
||||
options,
|
||||
if (options.forgotPasswordSpacerOptions.spacerBeforeButton !=
|
||||
null) ...[
|
||||
Spacer(
|
||||
flex: options.forgotPasswordSpacerOptions.spacerBeforeButton!,
|
||||
),
|
||||
],
|
||||
AnimatedBuilder(
|
||||
animation: _formValid,
|
||||
builder: (context, snapshot) => Align(
|
||||
child: widget.options.requestForgotPasswordButtonBuilder(
|
||||
context,
|
||||
() async {
|
||||
_formKey.currentState?.validate();
|
||||
if (_formValid.value) {
|
||||
widget.onRequestForgotPassword(_currentEmail);
|
||||
}
|
||||
},
|
||||
!_formValid.value,
|
||||
() {
|
||||
_formKey.currentState?.validate();
|
||||
},
|
||||
options,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (options.forgotPasswordSpacerOptions.spacerAfterButton !=
|
||||
null) ...[
|
||||
Spacer(
|
||||
flex: options.forgotPasswordSpacerOptions.spacerAfterButton!,
|
||||
),
|
||||
if (options.forgotPasswordSpacerOptions.spacerAfterButton !=
|
||||
null) ...[
|
||||
Spacer(
|
||||
flex: options.forgotPasswordSpacerOptions.spacerAfterButton!,
|
||||
),
|
||||
],
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget? _wrapWithDefaultStyle(Widget? widget, TextStyle? style) {
|
||||
if (style == null || widget == null) {
|
||||
return widget;
|
||||
} else {
|
||||
return DefaultTextStyle(style: style, child: widget);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: flutter_login
|
||||
description: Flutter Login Component
|
||||
version: 5.2.0
|
||||
version: 6.0.0
|
||||
|
||||
environment:
|
||||
sdk: ">=2.18.1 <3.0.0"
|
||||
|
|
Loading…
Reference in a new issue