Merge pull request #24 from Iconica-Development/bugfix/input-values-clearing

fix: input values clearing on next step
This commit is contained in:
Gorter-dev 2024-04-04 09:51:30 +02:00 committed by GitHub
commit 05b143a5bd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 129 additions and 90 deletions

View file

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

View file

@ -227,99 +227,115 @@ class _AuthScreenState extends State<AuthScreen> {
],
),
),
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!,
),
],
),
],
],
),
],
),
],

View file

@ -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.

View file

@ -76,6 +76,10 @@ class RegistrationScreenState extends State<RegistrationScreen> {
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,
);
}
}

View file

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