Merge pull request #29 from Iconica-Development/feature/added_spacer_options

feat: added spacer options for forgotPasswordForm
This commit is contained in:
Gorter-dev 2024-03-05 11:39:55 +01:00 committed by GitHub
commit a25977fe58
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 80 additions and 1 deletions

View file

@ -1,3 +1,7 @@
## 5.2.0
* Added spacer options for the ForogotPasswordForm.
## 5.1.4 ## 5.1.4
* Added BuildContext to the `onForgotPassword` and `onRegister`. * Added BuildContext to the `onForgotPassword` and `onRegister`.

View file

@ -1,6 +1,7 @@
/// ///
library flutter_login; library flutter_login;
export 'src/config/forgot_password_spacer_options.dart';
export 'src/config/login_options.dart'; export 'src/config/login_options.dart';
export 'src/config/spacer_options.dart'; export 'src/config/spacer_options.dart';
export 'src/service/login_validation.dart'; export 'src/service/login_validation.dart';

View file

@ -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;
}

View file

@ -1,6 +1,7 @@
import 'dart:async'; import 'dart:async';
import 'package:flutter/material.dart'; 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/config/spacer_options.dart';
import 'package:flutter_login/src/service/login_validation.dart'; import 'package:flutter_login/src/service/login_validation.dart';
import 'package:flutter_login/src/service/validation.dart'; import 'package:flutter_login/src/service/validation.dart';
@ -29,6 +30,7 @@ class LoginOptions {
this.emailInputContainerBuilder = _createEmailInputContainer, this.emailInputContainerBuilder = _createEmailInputContainer,
this.passwordInputContainerBuilder = _createPasswordInputContainer, this.passwordInputContainerBuilder = _createPasswordInputContainer,
this.showObscurePassword = true, this.showObscurePassword = true,
this.forgotPasswordSpacerOptions = const ForgotPasswordSpacerOptions(),
}); });
/// Builds the login button. /// Builds the login button.
@ -62,6 +64,9 @@ class LoginOptions {
/// and button. /// and button.
final LoginSpacerOptions spacers; 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. /// Maximum width of the form. Defaults to 400.
final double? maxFormWidth; final double? maxFormWidth;

View file

@ -78,17 +78,37 @@ class _ForgotPasswordFormState extends State<ForgotPasswordForm> {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
if (options.forgotPasswordSpacerOptions.spacerBeforeTitle !=
null) ...[
Spacer(
flex: options.forgotPasswordSpacerOptions.spacerBeforeTitle!,
),
],
_wrapWithDefaultStyle( _wrapWithDefaultStyle(
widget.title, widget.title,
theme.textTheme.displaySmall, theme.textTheme.displaySmall,
) ?? ) ??
const SizedBox.shrink(), const SizedBox.shrink(),
if (options.forgotPasswordSpacerOptions.spacerAfterTitle !=
null) ...[
Spacer(
flex: options.forgotPasswordSpacerOptions.spacerAfterTitle!,
),
],
_wrapWithDefaultStyle( _wrapWithDefaultStyle(
widget.description, widget.description,
theme.textTheme.bodyMedium, theme.textTheme.bodyMedium,
) ?? ) ??
const SizedBox.shrink(), const SizedBox.shrink(),
if (options.forgotPasswordSpacerOptions.spacerAfterDescription !=
null) ...[
Spacer(
flex:
options.forgotPasswordSpacerOptions.spacerAfterDescription!,
),
],
Expanded( Expanded(
flex: options.forgotPasswordSpacerOptions.formFlexValue,
child: Align( child: Align(
child: options.emailInputContainerBuilder( child: options.emailInputContainerBuilder(
TextFormField( TextFormField(
@ -104,6 +124,12 @@ class _ForgotPasswordFormState extends State<ForgotPasswordForm> {
), ),
), ),
), ),
if (options.forgotPasswordSpacerOptions.spacerBeforeButton !=
null) ...[
Spacer(
flex: options.forgotPasswordSpacerOptions.spacerBeforeButton!,
),
],
AnimatedBuilder( AnimatedBuilder(
animation: _formValid, animation: _formValid,
builder: (context, snapshot) => Align( builder: (context, snapshot) => Align(
@ -123,6 +149,12 @@ class _ForgotPasswordFormState extends State<ForgotPasswordForm> {
), ),
), ),
), ),
if (options.forgotPasswordSpacerOptions.spacerAfterButton !=
null) ...[
Spacer(
flex: options.forgotPasswordSpacerOptions.spacerAfterButton!,
),
],
], ],
), ),
), ),

View file

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