fix: add default field size

This commit is contained in:
mike doornenbal 2024-04-22 13:01:35 +02:00
parent 444b11a44f
commit c91a1c0856
5 changed files with 32 additions and 15 deletions

View file

@ -3,6 +3,10 @@ SPDX-FileCopyrightText: 2022 Iconica
SPDX-License-Identifier: GPL-3.0-or-later SPDX-License-Identifier: GPL-3.0-or-later
--> -->
# 2.0.4
- feat: added maxFormWidth to AuthScreen
# 2.0.3 # 2.0.3
- feat: added default registrationOptions - feat: added default registrationOptions

View file

@ -65,6 +65,7 @@ class AuthScreen extends StatefulWidget {
this.beforeTitleFlex, this.beforeTitleFlex,
this.afterTitleFlex, this.afterTitleFlex,
this.isLoading = false, this.isLoading = false,
this.maxFormWidth,
Key? key, Key? key,
}) : assert(steps.length > 0, 'At least one step is required'), }) : assert(steps.length > 0, 'At least one step is required'),
super(key: key); super(key: key);
@ -92,6 +93,7 @@ class AuthScreen extends StatefulWidget {
final int? beforeTitleFlex; final int? beforeTitleFlex;
final int? afterTitleFlex; final int? afterTitleFlex;
final bool isLoading; final bool isLoading;
final double? maxFormWidth;
@override @override
State<AuthScreen> createState() => _AuthScreenState(); State<AuthScreen> createState() => _AuthScreenState();
@ -234,6 +236,11 @@ class _AuthScreenState extends State<AuthScreen> {
Expanded( Expanded(
flex: widget.formFlex ?? 3, flex: widget.formFlex ?? 3,
child: Align( child: Align(
alignment: Alignment.topCenter,
child: ConstrainedBox(
constraints: BoxConstraints(
maxWidth: widget.maxFormWidth ?? 300,
),
child: Column( child: Column(
children: [ children: [
for (AuthField field for (AuthField field
@ -249,6 +256,7 @@ class _AuthScreenState extends State<AuthScreen> {
), ),
), ),
), ),
),
Column( Column(
children: [ children: [
Row( Row(

View file

@ -27,6 +27,7 @@ class RegistrationOptions {
this.backgroundColor, this.backgroundColor,
this.titleWidget, this.titleWidget,
this.loginButton, this.loginButton,
this.maxFormWidth,
}) { }) {
if (registrationSteps == null || registrationSteps!.isEmpty) { if (registrationSteps == null || registrationSteps!.isEmpty) {
steps = RegistrationOptions.getDefaultSteps(); steps = RegistrationOptions.getDefaultSteps();
@ -88,6 +89,9 @@ class RegistrationOptions {
/// The number of flex units for the buttons. /// The number of flex units for the buttons.
final int? afterTitleFlex; final int? afterTitleFlex;
/// The maximum width of the form. Defaults to 300.
final double? maxFormWidth;
/// Generates default registration steps. /// Generates default registration steps.
/// ///
/// [emailController] controller for email input. /// [emailController] controller for email input.
@ -149,7 +153,7 @@ class RegistrationOptions {
border: const OutlineInputBorder(), border: const OutlineInputBorder(),
), ),
textStyle: textStyle, textStyle: textStyle,
padding: const EdgeInsets.symmetric(horizontal: 60, vertical: 20), padding: const EdgeInsets.symmetric(vertical: 20),
validators: [ validators: [
(email) => (email == null || email.isEmpty) (email) => (email == null || email.isEmpty)
? translations.defaultEmailEmpty ? translations.defaultEmailEmpty
@ -186,7 +190,7 @@ class RegistrationOptions {
hintText: translations.defaultPasswordHint, hintText: translations.defaultPasswordHint,
border: const OutlineInputBorder(), border: const OutlineInputBorder(),
), ),
padding: const EdgeInsets.symmetric(horizontal: 60, vertical: 20), padding: const EdgeInsets.symmetric(vertical: 20),
textStyle: textStyle, textStyle: textStyle,
validators: [ validators: [
(value) => (value == null || value.isEmpty) (value) => (value == null || value.isEmpty)

View file

@ -80,6 +80,7 @@ class RegistrationScreenState extends State<RegistrationScreen> {
formFlex: widget.registrationOptions.formFlex, formFlex: widget.registrationOptions.formFlex,
beforeTitleFlex: widget.registrationOptions.beforeTitleFlex, beforeTitleFlex: widget.registrationOptions.beforeTitleFlex,
afterTitleFlex: widget.registrationOptions.afterTitleFlex, afterTitleFlex: widget.registrationOptions.afterTitleFlex,
maxFormWidth: widget.registrationOptions.maxFormWidth,
); );
} }
} }

View file

@ -4,7 +4,7 @@
name: flutter_registration name: flutter_registration
description: A Flutter Registration package description: A Flutter Registration package
version: 2.0.3 version: 2.0.4
repository: https://github.com/Iconica-Development/flutter_registration repository: https://github.com/Iconica-Development/flutter_registration
publish_to: none publish_to: none