mirror of
https://github.com/Iconica-Development/flutter_login_widget.git
synced 2025-05-19 13:43:44 +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
|
## 5.1.4
|
||||||
|
|
||||||
* Added BuildContext to the `onForgotPassword` and `onRegister`.
|
* Added BuildContext to the `onForgotPassword` and `onRegister`.
|
||||||
|
|
|
@ -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';
|
||||||
|
|
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 '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;
|
||||||
|
|
||||||
|
|
|
@ -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!,
|
||||||
|
),
|
||||||
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -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"
|
||||||
|
|
Loading…
Reference in a new issue