mirror of
https://github.com/Iconica-Development/flutter_registration.git
synced 2025-05-19 13:23:45 +02:00
fix: registration screen
This commit is contained in:
parent
7a4bcd8b3f
commit
89987c5e8d
7 changed files with 162 additions and 129 deletions
12
CHANGELOG.md
12
CHANGELOG.md
|
@ -4,16 +4,22 @@ SPDX-FileCopyrightText: 2022 Iconica
|
|||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
-->
|
||||
|
||||
# 2.0.2
|
||||
|
||||
- fix: authfields not showing and not being able to set space between widgets
|
||||
|
||||
# 2.0.1
|
||||
|
||||
- feat: added circular progress indicator while awaiting registration of user
|
||||
- feat: added alignment option for buttons
|
||||
|
||||
# 2.0.0
|
||||
|
||||
- feat(buttons): Added the possiblity to only have a next button by return zero on the previous button builder
|
||||
- feat: exposed input decoration in AuthTextField
|
||||
- feat: added title widget and login button builder
|
||||
- feat(bool): Add a boolean field. Can be used for accepting terms and conditions
|
||||
- feat(pass): Add dedicated password screen that manages state internally
|
||||
- feat(pass): Add dedicated password screen that manages state internally
|
||||
- fix: Small refactor and brought back the normal alignment for the screens
|
||||
- fix: Fixed alignment and spacing when opening keyboard
|
||||
- feat: add auth drop down field
|
||||
|
@ -26,7 +32,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||
|
||||
# 1.2.0
|
||||
|
||||
- feat: Added the ability to have an async register function so you can call it asynchronous.
|
||||
- feat: Added the ability to have an async register function so you can call it asynchronous.
|
||||
|
||||
# 1.1.0
|
||||
|
||||
|
@ -43,7 +49,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||
- fix: fix linter
|
||||
- fix: fix translations to English
|
||||
|
||||
# 0.4.0
|
||||
# 0.4.0
|
||||
|
||||
- feat: Added the abilty to show and hide the passwords
|
||||
|
||||
|
|
|
@ -17,3 +17,4 @@ export 'src/registration_screen.dart';
|
|||
export 'src/service/registration_repository.dart';
|
||||
export 'package:flutter_input_library/flutter_input_library.dart'
|
||||
show BoolWidgetType;
|
||||
export 'src/config/registration_spacers.dart';
|
||||
|
|
|
@ -9,6 +9,7 @@ import 'package:flutter_registration/flutter_registration.dart';
|
|||
|
||||
class AuthScreen extends StatefulWidget {
|
||||
const AuthScreen({
|
||||
required this.registrationOptions,
|
||||
required this.appBarTitle,
|
||||
required this.steps,
|
||||
required this.submitBtnTitle,
|
||||
|
@ -22,14 +23,11 @@ class AuthScreen extends StatefulWidget {
|
|||
this.previousButtonBuilder,
|
||||
this.titleWidget,
|
||||
this.loginButton,
|
||||
this.titleFlex,
|
||||
this.formFlex,
|
||||
this.beforeTitleFlex,
|
||||
this.afterTitleFlex,
|
||||
this.isLoading = false,
|
||||
super.key,
|
||||
}) : assert(steps.length > 0, 'At least one step is required');
|
||||
|
||||
final RegistrationOptions registrationOptions;
|
||||
final String appBarTitle;
|
||||
final Future<void> Function({
|
||||
required HashMap<String, dynamic> values,
|
||||
|
@ -48,10 +46,6 @@ class AuthScreen extends StatefulWidget {
|
|||
previousButtonBuilder;
|
||||
final Widget? titleWidget;
|
||||
final Widget? loginButton;
|
||||
final int? titleFlex;
|
||||
final int? formFlex;
|
||||
final int? beforeTitleFlex;
|
||||
final int? afterTitleFlex;
|
||||
final bool isLoading;
|
||||
|
||||
@override
|
||||
|
@ -164,127 +158,144 @@ class _AuthScreenState extends State<AuthScreen> {
|
|||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
if (widget.titleWidget != null) ...[
|
||||
Expanded(
|
||||
flex: widget.titleFlex ?? 1,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: widget.beforeTitleFlex ?? 3,
|
||||
child: Container(),
|
||||
),
|
||||
widget.titleWidget!,
|
||||
Expanded(
|
||||
flex: widget.afterTitleFlex ?? 2,
|
||||
child: Container(),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (widget.registrationOptions.spacerConfig
|
||||
.beforeTitleSpacer !=
|
||||
null)
|
||||
Spacer(
|
||||
flex: widget.registrationOptions.spacerConfig
|
||||
.beforeTitleSpacer!,
|
||||
),
|
||||
Column(
|
||||
widget.titleWidget ?? const SizedBox.shrink(),
|
||||
if (widget.registrationOptions.spacerConfig
|
||||
.afterTitleSpacer !=
|
||||
null)
|
||||
Spacer(
|
||||
flex: widget.registrationOptions.spacerConfig
|
||||
.afterTitleSpacer!,
|
||||
),
|
||||
Flexible(
|
||||
flex: widget
|
||||
.registrationOptions.spacerConfig.formFlex!,
|
||||
child: 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,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (widget.loginButton != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 20.0),
|
||||
child: widget.loginButton!,
|
||||
),
|
||||
for (AuthField field
|
||||
in widget.steps[i].fields)
|
||||
Align(
|
||||
child: Column(
|
||||
children: [
|
||||
if (field.title != null) field.title!,
|
||||
field.build(context, () {
|
||||
_validate(i);
|
||||
})
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
if (widget.registrationOptions.spacerConfig
|
||||
.afterFormSpacer !=
|
||||
null)
|
||||
Spacer(
|
||||
flex: widget.registrationOptions.spacerConfig
|
||||
.afterFormSpacer!,
|
||||
),
|
||||
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,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (widget.loginButton != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 20.0),
|
||||
child: widget.loginButton!,
|
||||
),
|
||||
],
|
||||
),
|
||||
]),
|
||||
]),
|
||||
));
|
||||
|
|
|
@ -12,6 +12,7 @@ class RegistrationOptions {
|
|||
required this.registrationRepository,
|
||||
required this.registrationSteps,
|
||||
required this.afterRegistration,
|
||||
this.spacerConfig = const RegistrationSpacerConfig(),
|
||||
this.registrationTranslations = const RegistrationTranslations.empty(),
|
||||
this.onError,
|
||||
this.customAppbarBuilder,
|
||||
|
@ -23,6 +24,7 @@ class RegistrationOptions {
|
|||
this.loginButton,
|
||||
});
|
||||
|
||||
final RegistrationSpacerConfig spacerConfig;
|
||||
final RegistrationTranslations registrationTranslations;
|
||||
final List<AuthStep> registrationSteps;
|
||||
final int? Function(String error)? onError;
|
||||
|
|
12
lib/src/config/registration_spacers.dart
Normal file
12
lib/src/config/registration_spacers.dart
Normal file
|
@ -0,0 +1,12 @@
|
|||
class RegistrationSpacerConfig {
|
||||
const RegistrationSpacerConfig({
|
||||
this.beforeTitleSpacer,
|
||||
this.afterTitleSpacer,
|
||||
this.afterFormSpacer,
|
||||
this.formFlex = 1,
|
||||
});
|
||||
final int? beforeTitleSpacer;
|
||||
final int? afterTitleSpacer;
|
||||
final int? afterFormSpacer;
|
||||
final int? formFlex;
|
||||
}
|
|
@ -52,6 +52,7 @@ class RegistrationScreenState extends State<RegistrationScreen> {
|
|||
var translations = widget.registrationOptions.registrationTranslations;
|
||||
|
||||
return AuthScreen(
|
||||
registrationOptions: widget.registrationOptions,
|
||||
steps: widget.registrationOptions.registrationSteps,
|
||||
customAppBar: widget.registrationOptions.customAppbarBuilder?.call(
|
||||
translations.title,
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue