mirror of
https://github.com/Iconica-Development/flutter_login_widget.git
synced 2025-05-19 05:33:45 +02:00
Merge pull request #29 from Iconica-Development/feature/added_spacer_options
feat: added spacer options for forgotPasswordForm
This commit is contained in:
commit
a25977fe58
6 changed files with 80 additions and 1 deletions
|
@ -1,3 +1,7 @@
|
|||
## 5.2.0
|
||||
|
||||
* Added spacer options for the ForogotPasswordForm.
|
||||
|
||||
## 5.1.4
|
||||
|
||||
* Added BuildContext to the `onForgotPassword` and `onRegister`.
|
||||
|
|
|
@ -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';
|
||||
|
|
37
lib/src/config/forgot_password_spacer_options.dart
Normal file
37
lib/src/config/forgot_password_spacer_options.dart
Normal 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;
|
||||
}
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -78,17 +78,37 @@ class _ForgotPasswordFormState extends State<ForgotPasswordForm> {
|
|||
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<ForgotPasswordForm> {
|
|||
),
|
||||
),
|
||||
),
|
||||
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<ForgotPasswordForm> {
|
|||
),
|
||||
),
|
||||
),
|
||||
if (options.forgotPasswordSpacerOptions.spacerAfterButton !=
|
||||
null) ...[
|
||||
Spacer(
|
||||
flex: options.forgotPasswordSpacerOptions.spacerAfterButton!,
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue