diff --git a/CHANGELOG.md b/CHANGELOG.md index 23fa005..bdde506 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 5.2.0 + +* Added spacer options for the ForogotPasswordForm. + ## 5.1.4 * Added BuildContext to the `onForgotPassword` and `onRegister`. diff --git a/lib/flutter_login.dart b/lib/flutter_login.dart index 94185e6..8b0b619 100644 --- a/lib/flutter_login.dart +++ b/lib/flutter_login.dart @@ -1,6 +1,7 @@ /// library flutter_login; +export 'src/config/forgot_password_spacer_options.dart'; export 'src/config/login_options.dart'; export 'src/config/spacer_options.dart'; export 'src/service/login_validation.dart'; diff --git a/lib/src/config/forgot_password_spacer_options.dart b/lib/src/config/forgot_password_spacer_options.dart new file mode 100644 index 0000000..80df0a5 --- /dev/null +++ b/lib/src/config/forgot_password_spacer_options.dart @@ -0,0 +1,37 @@ +import 'package:flutter/material.dart'; + +@immutable + +/// Options for configuring the spacer values for the forgot password form. +/// Use this to adjust the spacing between the title, description, textfield, +/// and button. +class ForgotPasswordSpacerOptions { + /// Constructs a [ForgotPasswordSpacerOptions] widget. + const ForgotPasswordSpacerOptions({ + this.spacerBeforeTitle, + this.spacerAfterTitle, + this.spacerAfterDescription, + this.spacerBeforeButton, + this.spacerAfterButton, + this.formFlexValue = 1, + }); + + /// Flex value for the spacer before the title. + final int? spacerBeforeTitle; + + /// Flex value for the spacer between the title and subtitle. + final int? spacerAfterTitle; + + /// Flex value for the spacer between the description and the textfield. + final int? spacerAfterDescription; + + /// Flex value for the spacer before the button. + final int? spacerBeforeButton; + + /// Flex value for the spacer after the button. + final int? spacerAfterButton; + + /// Flex value for the form. Defaults to 1. Use this when also using the + /// other spacer options. + final int formFlexValue; +} diff --git a/lib/src/config/login_options.dart b/lib/src/config/login_options.dart index dfdbe74..afb8046 100644 --- a/lib/src/config/login_options.dart +++ b/lib/src/config/login_options.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; +import 'package:flutter_login/src/config/forgot_password_spacer_options.dart'; import 'package:flutter_login/src/config/spacer_options.dart'; import 'package:flutter_login/src/service/login_validation.dart'; import 'package:flutter_login/src/service/validation.dart'; @@ -29,6 +30,7 @@ class LoginOptions { this.emailInputContainerBuilder = _createEmailInputContainer, this.passwordInputContainerBuilder = _createPasswordInputContainer, this.showObscurePassword = true, + this.forgotPasswordSpacerOptions = const ForgotPasswordSpacerOptions(), }); /// Builds the login button. @@ -62,6 +64,9 @@ class LoginOptions { /// and button. final LoginSpacerOptions spacers; + /// Option to modify the spacing between the items on the forgotPasswordForm. + final ForgotPasswordSpacerOptions forgotPasswordSpacerOptions; + /// Maximum width of the form. Defaults to 400. final double? maxFormWidth; diff --git a/lib/src/widgets/forgot_password_form.dart b/lib/src/widgets/forgot_password_form.dart index 201cc65..b3c56b3 100644 --- a/lib/src/widgets/forgot_password_form.dart +++ b/lib/src/widgets/forgot_password_form.dart @@ -78,17 +78,37 @@ class _ForgotPasswordFormState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ + if (options.forgotPasswordSpacerOptions.spacerBeforeTitle != + null) ...[ + Spacer( + flex: options.forgotPasswordSpacerOptions.spacerBeforeTitle!, + ), + ], _wrapWithDefaultStyle( widget.title, theme.textTheme.displaySmall, ) ?? const SizedBox.shrink(), + if (options.forgotPasswordSpacerOptions.spacerAfterTitle != + null) ...[ + Spacer( + flex: options.forgotPasswordSpacerOptions.spacerAfterTitle!, + ), + ], _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( @@ -104,6 +124,12 @@ class _ForgotPasswordFormState extends State { ), ), ), + if (options.forgotPasswordSpacerOptions.spacerBeforeButton != + null) ...[ + Spacer( + flex: options.forgotPasswordSpacerOptions.spacerBeforeButton!, + ), + ], AnimatedBuilder( animation: _formValid, builder: (context, snapshot) => Align( @@ -123,6 +149,12 @@ class _ForgotPasswordFormState extends State { ), ), ), + if (options.forgotPasswordSpacerOptions.spacerAfterButton != + null) ...[ + Spacer( + flex: options.forgotPasswordSpacerOptions.spacerAfterButton!, + ), + ], ], ), ), diff --git a/pubspec.yaml b/pubspec.yaml index 3c3cd17..312c130 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_login description: Flutter Login Component -version: 5.1.4 +version: 5.2.0 environment: sdk: ">=2.18.1 <3.0.0"