From a44a419bc4dcbe18d32954b93244d3727192ec6c Mon Sep 17 00:00:00 2001 From: mike doornenbal Date: Thu, 4 Apr 2024 09:29:27 +0200 Subject: [PATCH] fix: input values clearing on next step --- CHANGELOG.md | 3 + lib/src/auth_screen.dart | 194 ++++++++++++----------- lib/src/config/registration_options.dart | 16 ++ lib/src/registration_screen.dart | 4 + pubspec.yaml | 2 +- 5 files changed, 129 insertions(+), 90 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b3cf71..ed20549 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ SPDX-FileCopyrightText: 2022 Iconica SPDX-License-Identifier: GPL-3.0-or-later --> +# 2.0.2 +- fix: fixed the issue with values not being saved when calling nextStep. + # 2.0.1 - feat: added circular progress indicator while awaiting registration of user - feat: added alignment option for buttons diff --git a/lib/src/auth_screen.dart b/lib/src/auth_screen.dart index 64d7a62..8d9d2b9 100644 --- a/lib/src/auth_screen.dart +++ b/lib/src/auth_screen.dart @@ -227,99 +227,115 @@ class _AuthScreenState extends State { ], ), ), - Column( - children: [ - Row( - mainAxisAlignment: widget - .buttonMainAxisAlignment != - null - ? widget.buttonMainAxisAlignment! - : (widget.previousButtonBuilder != null && - widget.previousButtonBuilder?.call( - onPrevious, - widget.previousBtnTitle, - i, - ) == - null) - ? MainAxisAlignment.start - : widget.steps.first != widget.steps[i] - ? MainAxisAlignment.center - : MainAxisAlignment.end, - children: [ - if (widget.previousButtonBuilder == null) ...[ - if (widget.steps.first != widget.steps[i]) - ElevatedButton( - onPressed: onPrevious, - child: Row( - children: [ - const Icon( - Icons.arrow_back, + ], + Expanded( + flex: widget.formFlex ?? 3, + child: Align( + child: Column( + children: [ + for (AuthField field + in widget.steps[i].fields) ...[ + if (field.title != null) ...[ + field.title!, + ], + field.build(context, () { + _validate(i); + }) + ] + ], + ), + ), + ), + Column( + children: [ + Row( + mainAxisAlignment: widget + .buttonMainAxisAlignment != + null + ? widget.buttonMainAxisAlignment! + : (widget.previousButtonBuilder != null && + widget.previousButtonBuilder?.call( + onPrevious, + widget.previousBtnTitle, + i, + ) == + null) + ? MainAxisAlignment.start + : widget.steps.first != widget.steps[i] + ? MainAxisAlignment.center + : MainAxisAlignment.end, + children: [ + if (widget.previousButtonBuilder == null) ...[ + if (widget.steps.first != widget.steps[i]) + ElevatedButton( + onPressed: onPrevious, + child: Row( + children: [ + const Icon( + Icons.arrow_back, + size: 18, + ), + Padding( + padding: const EdgeInsets.only( + left: 4.0), + child: + Text(widget.previousBtnTitle), + ), + ], + ), + ), + ] else if (widget.previousButtonBuilder?.call( + onPrevious, + widget.previousBtnTitle, + i) != + null) ...[ + widget.previousButtonBuilder!.call( + onPrevious, widget.previousBtnTitle, i)! + ], + widget.nextButtonBuilder?.call( + !_formValid + ? null + : () async { + await onNext(widget.steps[i]); + }, + widget.steps.last == widget.steps[i] + ? widget.submitBtnTitle + : widget.nextBtnTitle, + i, + _formValid, + ) ?? + ElevatedButton( + onPressed: !_formValid + ? null + : () async { + await onNext(widget.steps[i]); + }, + child: Row( + children: [ + Text( + widget.steps.last == widget.steps[i] + ? widget.submitBtnTitle + : widget.nextBtnTitle, + ), + const Padding( + padding: EdgeInsets.only(left: 4.0), + child: Icon( + Icons.arrow_forward, size: 18, ), - Padding( - padding: const EdgeInsets.only( - left: 4.0), - child: - Text(widget.previousBtnTitle), - ), - ], - ), + ), + ], ), - ] else if (widget.previousButtonBuilder?.call( - onPrevious, - widget.previousBtnTitle, - i) != - null) ...[ - widget.previousButtonBuilder!.call( - onPrevious, widget.previousBtnTitle, i)! - ], - widget.nextButtonBuilder?.call( - !_formValid - ? null - : () async { - await onNext(widget.steps[i]); - }, - widget.steps.last == widget.steps[i] - ? widget.submitBtnTitle - : widget.nextBtnTitle, - i, - _formValid, - ) ?? - ElevatedButton( - onPressed: !_formValid - ? null - : () async { - await onNext(widget.steps[i]); - }, - child: Row( - children: [ - Text( - widget.steps.last == - widget.steps[i] - ? widget.submitBtnTitle - : widget.nextBtnTitle, - ), - const Padding( - padding: - EdgeInsets.only(left: 4.0), - child: Icon( - Icons.arrow_forward, - size: 18, - ), - ), - ], - ), - ), - ], + ), + ], + ), + if (widget.loginButton != null) + Padding( + padding: const EdgeInsets.only(top: 20.0), + child: widget.loginButton!, ), - if (widget.loginButton != null) - Padding( - padding: const EdgeInsets.only(top: 20.0), - child: widget.loginButton!, - ), - ], - ), - ], + ], + ), ], ), ], diff --git a/lib/src/config/registration_options.dart b/lib/src/config/registration_options.dart index 7598581..7a70646 100644 --- a/lib/src/config/registration_options.dart +++ b/lib/src/config/registration_options.dart @@ -13,6 +13,10 @@ class RegistrationOptions { required this.registrationRepository, required this.registrationSteps, required this.afterRegistration, + this.titleFlex, + this.formFlex, + this.beforeTitleFlex, + this.afterTitleFlex, this.registrationTranslations = const RegistrationTranslations.empty(), this.onError, this.customAppbarBuilder, @@ -62,6 +66,18 @@ class RegistrationOptions { /// A custom widget for displaying a login button. Widget? loginButton; + /// The number of flex units for the title. + final int? titleFlex; + + /// The number of flex units for the form. + final int? formFlex; + + /// The number of flex units for the buttons. + final int? beforeTitleFlex; + + /// The number of flex units for the buttons. + final int? afterTitleFlex; + /// Generates default registration steps. /// /// [emailController] controller for email input. diff --git a/lib/src/registration_screen.dart b/lib/src/registration_screen.dart index 0e12f53..9dbcee3 100644 --- a/lib/src/registration_screen.dart +++ b/lib/src/registration_screen.dart @@ -76,6 +76,10 @@ class RegistrationScreenState extends State { titleWidget: widget.registrationOptions.titleWidget, loginButton: widget.registrationOptions.loginButton, isLoading: _isLoading, + titleFlex: widget.registrationOptions.titleFlex, + formFlex: widget.registrationOptions.formFlex, + beforeTitleFlex: widget.registrationOptions.beforeTitleFlex, + afterTitleFlex: widget.registrationOptions.afterTitleFlex, ); } } diff --git a/pubspec.yaml b/pubspec.yaml index 89d3bd5..e3d9761 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ name: flutter_registration description: A Flutter Registration package -version: 2.0.1 +version: 2.0.2 repository: https://github.com/Iconica-Development/flutter_registration publish_to: none