mirror of
https://github.com/Iconica-Development/flutter_registration.git
synced 2025-05-19 13:23:45 +02:00
Merge pull request #3 from Iconica-Development/feature/added_styling
feat: Added second textfield too password and added more styling options
This commit is contained in:
commit
63a3223d0f
9 changed files with 298 additions and 165 deletions
13
CHANGELOG.md
13
CHANGELOG.md
|
@ -4,11 +4,16 @@ SPDX-FileCopyrightText: 2022 Iconica
|
||||||
SPDX-License-Identifier: GPL-3.0-or-later
|
SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
-->
|
-->
|
||||||
|
|
||||||
## 0.0.1
|
## 0.2.0
|
||||||
|
|
||||||
* Initial version
|
- Added the abilty to add labels
|
||||||
|
- The default password step now includes two textfields
|
||||||
|
|
||||||
## 0.0.2
|
## 0.0.2
|
||||||
|
|
||||||
* Firebase integration
|
- Firebase integration
|
||||||
* Registration capabilities
|
- Registration capabilities
|
||||||
|
|
||||||
|
## 0.0.1
|
||||||
|
|
||||||
|
- Initial version
|
||||||
|
|
|
@ -5,49 +5,56 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: async
|
name: async
|
||||||
url: "https://pub.dartlang.org"
|
sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.9.0"
|
version: "2.10.0"
|
||||||
boolean_selector:
|
boolean_selector:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: boolean_selector
|
name: boolean_selector
|
||||||
url: "https://pub.dartlang.org"
|
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.0"
|
version: "2.1.1"
|
||||||
characters:
|
characters:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: characters
|
name: characters
|
||||||
url: "https://pub.dartlang.org"
|
sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.1"
|
version: "1.2.1"
|
||||||
clock:
|
clock:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: clock
|
name: clock
|
||||||
url: "https://pub.dartlang.org"
|
sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.1"
|
version: "1.1.1"
|
||||||
collection:
|
collection:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: collection
|
name: collection
|
||||||
url: "https://pub.dartlang.org"
|
sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.16.0"
|
version: "1.17.0"
|
||||||
cupertino_icons:
|
cupertino_icons:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: cupertino_icons
|
name: cupertino_icons
|
||||||
url: "https://pub.dartlang.org"
|
sha256: e35129dc44c9118cee2a5603506d823bab99c68393879edb440e0090d07586be
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.5"
|
version: "1.0.5"
|
||||||
fake_async:
|
fake_async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: fake_async
|
name: fake_async
|
||||||
url: "https://pub.dartlang.org"
|
sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.1"
|
version: "1.3.1"
|
||||||
flutter:
|
flutter:
|
||||||
|
@ -59,14 +66,16 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: flutter_hooks
|
name: flutter_hooks
|
||||||
url: "https://pub.dartlang.org"
|
sha256: "2b202559a4ed3656bbb7aae9d8b335fb0037b23acc7ae3f377d1ba0b95c21aec"
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.18.5+1"
|
version: "0.18.5+1"
|
||||||
flutter_lints:
|
flutter_lints:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
name: flutter_lints
|
name: flutter_lints
|
||||||
url: "https://pub.dartlang.org"
|
sha256: aeb0b80a8b3709709c9cc496cdc027c5b3216796bc0af0ce1007eaf24464fd4c
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.1"
|
version: "2.0.1"
|
||||||
flutter_localizations:
|
flutter_localizations:
|
||||||
|
@ -80,7 +89,7 @@ packages:
|
||||||
path: ".."
|
path: ".."
|
||||||
relative: true
|
relative: true
|
||||||
source: path
|
source: path
|
||||||
version: "0.1.0"
|
version: "0.2.0"
|
||||||
flutter_test:
|
flutter_test:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description: flutter
|
description: flutter
|
||||||
|
@ -90,42 +99,56 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: intl
|
name: intl
|
||||||
url: "https://pub.dartlang.org"
|
sha256: "910f85bce16fb5c6f614e117efa303e85a1731bb0081edf3604a2ae6e9a3cc91"
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.17.0"
|
version: "0.17.0"
|
||||||
|
js:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: js
|
||||||
|
sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.6.5"
|
||||||
lints:
|
lints:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: lints
|
name: lints
|
||||||
url: "https://pub.dartlang.org"
|
sha256: "5cfd6509652ff5e7fe149b6df4859e687fca9048437857cb2e65c8d780f396e3"
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.0"
|
version: "2.0.0"
|
||||||
matcher:
|
matcher:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: matcher
|
name: matcher
|
||||||
url: "https://pub.dartlang.org"
|
sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72"
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.12"
|
version: "0.12.13"
|
||||||
material_color_utilities:
|
material_color_utilities:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: material_color_utilities
|
name: material_color_utilities
|
||||||
url: "https://pub.dartlang.org"
|
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.1.5"
|
version: "0.2.0"
|
||||||
meta:
|
meta:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: meta
|
name: meta
|
||||||
url: "https://pub.dartlang.org"
|
sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42"
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.0"
|
version: "1.8.0"
|
||||||
path:
|
path:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: path
|
name: path
|
||||||
url: "https://pub.dartlang.org"
|
sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.2"
|
version: "1.8.2"
|
||||||
sky_engine:
|
sky_engine:
|
||||||
|
@ -137,51 +160,58 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: source_span
|
name: source_span
|
||||||
url: "https://pub.dartlang.org"
|
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.9.0"
|
version: "1.9.1"
|
||||||
stack_trace:
|
stack_trace:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: stack_trace
|
name: stack_trace
|
||||||
url: "https://pub.dartlang.org"
|
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.10.0"
|
version: "1.11.0"
|
||||||
stream_channel:
|
stream_channel:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: stream_channel
|
name: stream_channel
|
||||||
url: "https://pub.dartlang.org"
|
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.0"
|
version: "2.1.1"
|
||||||
string_scanner:
|
string_scanner:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: string_scanner
|
name: string_scanner
|
||||||
url: "https://pub.dartlang.org"
|
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.1"
|
version: "1.2.0"
|
||||||
term_glyph:
|
term_glyph:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: term_glyph
|
name: term_glyph
|
||||||
url: "https://pub.dartlang.org"
|
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.1"
|
version: "1.2.1"
|
||||||
test_api:
|
test_api:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_api
|
name: test_api
|
||||||
url: "https://pub.dartlang.org"
|
sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.4.12"
|
version: "0.4.16"
|
||||||
vector_math:
|
vector_math:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: vector_math
|
name: vector_math
|
||||||
url: "https://pub.dartlang.org"
|
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.2"
|
version: "2.1.4"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=2.18.0 <3.0.0"
|
dart: ">=2.18.0 <3.0.0"
|
||||||
flutter: ">=3.0.0"
|
flutter: ">=3.0.0"
|
||||||
|
|
|
@ -16,6 +16,8 @@ class AuthScreen extends StatefulWidget {
|
||||||
required this.previousBtnTitle,
|
required this.previousBtnTitle,
|
||||||
required this.onFinish,
|
required this.onFinish,
|
||||||
this.customAppBar,
|
this.customAppBar,
|
||||||
|
this.nextButtonBuilder,
|
||||||
|
this.previousButtonBuilder,
|
||||||
super.key,
|
super.key,
|
||||||
}) : assert(steps.length > 0, 'At least one step is required');
|
}) : assert(steps.length > 0, 'At least one step is required');
|
||||||
|
|
||||||
|
@ -29,6 +31,10 @@ class AuthScreen extends StatefulWidget {
|
||||||
final String nextBtnTitle;
|
final String nextBtnTitle;
|
||||||
final String previousBtnTitle;
|
final String previousBtnTitle;
|
||||||
final AppBar? customAppBar;
|
final AppBar? customAppBar;
|
||||||
|
final Widget Function(VoidCallback onPressed, String label)?
|
||||||
|
nextButtonBuilder;
|
||||||
|
final Widget Function(VoidCallback onPressed, String label)?
|
||||||
|
previousButtonBuilder;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<AuthScreen> createState() => _AuthScreenState();
|
State<AuthScreen> createState() => _AuthScreenState();
|
||||||
|
@ -46,9 +52,52 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||||
title: Text(widget.title),
|
title: Text(widget.title),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
void onPrevious() {
|
||||||
|
_pageController.previousPage(
|
||||||
|
duration: _animationDuration,
|
||||||
|
curve: _animationCurve,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void onNext(AuthStep step) {
|
||||||
|
if (!_formKey.currentState!.validate()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_formKey.currentState!.save();
|
||||||
|
|
||||||
|
FocusScope.of(context).unfocus();
|
||||||
|
|
||||||
|
if (widget.steps.last == step) {
|
||||||
|
var values = HashMap<String, String>();
|
||||||
|
|
||||||
|
for (var step in widget.steps) {
|
||||||
|
for (var field in step.fields) {
|
||||||
|
values[field.name] = field.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
widget.onFinish(
|
||||||
|
values: values,
|
||||||
|
onError: () => _pageController.animateToPage(
|
||||||
|
0,
|
||||||
|
duration: _animationDuration,
|
||||||
|
curve: _animationCurve,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
_pageController.nextPage(
|
||||||
|
duration: _animationDuration,
|
||||||
|
curve: _animationCurve,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => Scaffold(
|
Widget build(BuildContext context) => Scaffold(
|
||||||
backgroundColor: Theme.of(context).backgroundColor,
|
backgroundColor: Theme.of(context).colorScheme.background,
|
||||||
appBar: _appBar,
|
appBar: _appBar,
|
||||||
body: Form(
|
body: Form(
|
||||||
key: _formKey,
|
key: _formKey,
|
||||||
|
@ -75,18 +124,9 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
if (field.title != null) ...[
|
||||||
padding: const EdgeInsets.only(
|
field.title!,
|
||||||
top: 24.0,
|
],
|
||||||
bottom: 12.0,
|
|
||||||
),
|
|
||||||
child: Text(
|
|
||||||
field.title,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
field.build(),
|
field.build(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -108,11 +148,12 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||||
: MainAxisAlignment.end,
|
: MainAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
if (widget.steps.first != step)
|
if (widget.steps.first != step)
|
||||||
|
widget.previousButtonBuilder?.call(
|
||||||
|
onPrevious,
|
||||||
|
widget.previousBtnTitle,
|
||||||
|
) ??
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () => _pageController.previousPage(
|
onPressed: onPrevious,
|
||||||
duration: _animationDuration,
|
|
||||||
curve: _animationCurve,
|
|
||||||
),
|
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
const Icon(
|
const Icon(
|
||||||
|
@ -120,45 +161,22 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||||
size: 18,
|
size: 18,
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 4.0),
|
padding:
|
||||||
|
const EdgeInsets.only(left: 4.0),
|
||||||
child: Text(widget.previousBtnTitle),
|
child: Text(widget.previousBtnTitle),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
widget.nextButtonBuilder?.call(
|
||||||
|
() => onNext(step),
|
||||||
|
widget.steps.last == step
|
||||||
|
? widget.submitBtnTitle
|
||||||
|
: widget.nextBtnTitle,
|
||||||
|
) ??
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (!_formKey.currentState!.validate()) {
|
onNext(step);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
FocusScope.of(context).unfocus();
|
|
||||||
|
|
||||||
if (widget.steps.last == step) {
|
|
||||||
var values = HashMap<String, String>();
|
|
||||||
|
|
||||||
for (var step in widget.steps) {
|
|
||||||
for (var field in step.fields) {
|
|
||||||
values[field.name] = field.value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
widget.onFinish(
|
|
||||||
values: values,
|
|
||||||
onError: () => _pageController.animateToPage(
|
|
||||||
0,
|
|
||||||
duration: _animationDuration,
|
|
||||||
curve: _animationCurve,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_pageController.nextPage(
|
|
||||||
duration: _animationDuration,
|
|
||||||
curve: _animationCurve,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
|
|
|
@ -12,6 +12,8 @@ class RegistrationOptions {
|
||||||
required this.afterRegistration,
|
required this.afterRegistration,
|
||||||
this.registrationTranslations = const RegistrationTranslations(),
|
this.registrationTranslations = const RegistrationTranslations(),
|
||||||
this.customAppbarBuilder,
|
this.customAppbarBuilder,
|
||||||
|
this.nextButtonBuilder,
|
||||||
|
this.previousButtonBuilder,
|
||||||
});
|
});
|
||||||
|
|
||||||
final RegistrationTranslations registrationTranslations;
|
final RegistrationTranslations registrationTranslations;
|
||||||
|
@ -19,17 +21,42 @@ class RegistrationOptions {
|
||||||
final VoidCallback afterRegistration;
|
final VoidCallback afterRegistration;
|
||||||
final RegistrationRepository registrationRepository;
|
final RegistrationRepository registrationRepository;
|
||||||
final AppBar Function(String title)? customAppbarBuilder;
|
final AppBar Function(String title)? customAppbarBuilder;
|
||||||
|
final Widget Function(VoidCallback onPressed, String label)?
|
||||||
|
nextButtonBuilder;
|
||||||
|
final Widget Function(VoidCallback onPressed, String label)?
|
||||||
|
previousButtonBuilder;
|
||||||
|
|
||||||
static List<AuthStep> getDefaultSteps({
|
static List<AuthStep> getDefaultSteps({
|
||||||
RegistrationTranslations translations = const RegistrationTranslations(),
|
RegistrationTranslations translations = const RegistrationTranslations(),
|
||||||
}) =>
|
Function(String title)? titleBuilder,
|
||||||
[
|
Function(String label)? labelBuilder,
|
||||||
|
TextStyle? textStyle,
|
||||||
|
}) {
|
||||||
|
var password1 = '';
|
||||||
|
|
||||||
|
return [
|
||||||
AuthStep(
|
AuthStep(
|
||||||
fields: [
|
fields: [
|
||||||
AuthTextField(
|
AuthTextField(
|
||||||
name: 'email',
|
name: 'email',
|
||||||
title: translations.defaultEmailTitle,
|
title: titleBuilder?.call(
|
||||||
|
translations.defaultEmailTitle,
|
||||||
|
) ??
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
top: 24.0,
|
||||||
|
bottom: 12.0,
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
translations.defaultEmailTitle,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
label: labelBuilder?.call(translations.defaultEmailLabel),
|
||||||
hintText: translations.defaultEmailHint,
|
hintText: translations.defaultEmailHint,
|
||||||
|
textStyle: textStyle,
|
||||||
validators: [
|
validators: [
|
||||||
(email) => (email == null || email.isEmpty)
|
(email) => (email == null || email.isEmpty)
|
||||||
? translations.defaultEmailEmpty
|
? translations.defaultEmailEmpty
|
||||||
|
@ -46,13 +73,44 @@ class RegistrationOptions {
|
||||||
AuthStep(
|
AuthStep(
|
||||||
fields: [
|
fields: [
|
||||||
AuthTextField(
|
AuthTextField(
|
||||||
name: 'password',
|
name: 'password1',
|
||||||
title: translations.defaultPasswordTitle,
|
title: titleBuilder?.call(
|
||||||
hintText: translations.defaultPasswordHint,
|
translations.defaultPassword1Title,
|
||||||
|
) ??
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
top: 24.0,
|
||||||
|
bottom: 12.0,
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
translations.defaultPassword1Title,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
label: labelBuilder?.call(translations.defaultPassword1Label),
|
||||||
|
hintText: translations.defaultPassword1Hint,
|
||||||
|
textStyle: textStyle,
|
||||||
obscureText: true,
|
obscureText: true,
|
||||||
validators: [
|
validators: [
|
||||||
(value) => (value == null || value.isEmpty)
|
(value) => (value == null || value.isEmpty)
|
||||||
? translations.defaultPasswordValidatorMessage
|
? translations.defaultPassword1ValidatorMessage
|
||||||
|
: null,
|
||||||
|
],
|
||||||
|
onChange: (value) {
|
||||||
|
password1 = value;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
AuthTextField(
|
||||||
|
name: 'password2',
|
||||||
|
label: labelBuilder?.call(translations.defaultPassword2Label),
|
||||||
|
hintText: translations.defaultPassword2Hint,
|
||||||
|
textStyle: textStyle,
|
||||||
|
obscureText: true,
|
||||||
|
validators: [
|
||||||
|
(value) => (value != password1)
|
||||||
|
? translations.defaultPassword2ValidatorMessage
|
||||||
: null,
|
: null,
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -60,3 +118,4 @@ class RegistrationOptions {
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -10,12 +10,17 @@ class RegistrationTranslations {
|
||||||
this.nextStepBtn = 'Volgende stap',
|
this.nextStepBtn = 'Volgende stap',
|
||||||
this.closeBtn = 'Sluiten',
|
this.closeBtn = 'Sluiten',
|
||||||
this.defaultEmailTitle = 'Wat is je e-mailadres?',
|
this.defaultEmailTitle = 'Wat is je e-mailadres?',
|
||||||
|
this.defaultEmailLabel = '',
|
||||||
this.defaultEmailHint = 'iemand@voorbeeld.nl',
|
this.defaultEmailHint = 'iemand@voorbeeld.nl',
|
||||||
this.defaultEmailEmpty = 'Geef uw e-mailadres op',
|
this.defaultEmailEmpty = 'Geef uw e-mailadres op',
|
||||||
this.defaultEmailValidatorMessage = 'Geef een geldig e-mailadres op',
|
this.defaultEmailValidatorMessage = 'Geef een geldig e-mailadres op',
|
||||||
this.defaultPasswordTitle = 'Kies een wachtwoord',
|
this.defaultPassword1Title = 'Kies een wachtwoord',
|
||||||
this.defaultPasswordHint = '',
|
this.defaultPassword1Label = '',
|
||||||
this.defaultPasswordValidatorMessage = 'Geef een wachtwoord op',
|
this.defaultPassword1Hint = '',
|
||||||
|
this.defaultPassword1ValidatorMessage = 'Geef een wachtwoord op',
|
||||||
|
this.defaultPassword2Label = '',
|
||||||
|
this.defaultPassword2Hint = '',
|
||||||
|
this.defaultPassword2ValidatorMessage = 'Wachtwoorden moeten gelijk zijn',
|
||||||
});
|
});
|
||||||
|
|
||||||
final String title;
|
final String title;
|
||||||
|
@ -24,10 +29,15 @@ class RegistrationTranslations {
|
||||||
final String nextStepBtn;
|
final String nextStepBtn;
|
||||||
final String closeBtn;
|
final String closeBtn;
|
||||||
final String defaultEmailTitle;
|
final String defaultEmailTitle;
|
||||||
|
final String defaultEmailLabel;
|
||||||
final String defaultEmailHint;
|
final String defaultEmailHint;
|
||||||
final String defaultEmailEmpty;
|
final String defaultEmailEmpty;
|
||||||
final String defaultEmailValidatorMessage;
|
final String defaultEmailValidatorMessage;
|
||||||
final String defaultPasswordTitle;
|
final String defaultPassword1Title;
|
||||||
final String defaultPasswordHint;
|
final String defaultPassword1Label;
|
||||||
final String defaultPasswordValidatorMessage;
|
final String defaultPassword1Hint;
|
||||||
|
final String defaultPassword1ValidatorMessage;
|
||||||
|
final String defaultPassword2Label;
|
||||||
|
final String defaultPassword2Hint;
|
||||||
|
final String defaultPassword2ValidatorMessage;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,13 +7,13 @@ import 'package:flutter/material.dart';
|
||||||
abstract class AuthField {
|
abstract class AuthField {
|
||||||
AuthField({
|
AuthField({
|
||||||
required this.name,
|
required this.name,
|
||||||
required this.title,
|
this.title,
|
||||||
this.validators = const [],
|
this.validators = const [],
|
||||||
this.value = '',
|
this.value = '',
|
||||||
});
|
});
|
||||||
|
|
||||||
final String name;
|
final String name;
|
||||||
final String title;
|
final Widget? title;
|
||||||
List<String? Function(String?)> validators;
|
List<String? Function(String?)> validators;
|
||||||
String value;
|
String value;
|
||||||
|
|
||||||
|
|
|
@ -8,11 +8,14 @@ import 'package:flutter_registration/flutter_registration.dart';
|
||||||
class AuthTextField extends AuthField {
|
class AuthTextField extends AuthField {
|
||||||
AuthTextField({
|
AuthTextField({
|
||||||
required super.name,
|
required super.name,
|
||||||
required super.title,
|
super.title,
|
||||||
super.validators = const [],
|
super.validators = const [],
|
||||||
super.value = '',
|
super.value = '',
|
||||||
this.obscureText = false,
|
this.obscureText = false,
|
||||||
this.hintText,
|
this.hintText,
|
||||||
|
this.label,
|
||||||
|
this.textStyle,
|
||||||
|
this.onChange,
|
||||||
}) {
|
}) {
|
||||||
_textEditingController = TextEditingController();
|
_textEditingController = TextEditingController();
|
||||||
}
|
}
|
||||||
|
@ -20,16 +23,22 @@ class AuthTextField extends AuthField {
|
||||||
late TextEditingController _textEditingController;
|
late TextEditingController _textEditingController;
|
||||||
final bool obscureText;
|
final bool obscureText;
|
||||||
final String? hintText;
|
final String? hintText;
|
||||||
|
final Widget? label;
|
||||||
|
final TextStyle? textStyle;
|
||||||
|
final Function(String value)? onChange;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build() => TextFormField(
|
Widget build() => TextFormField(
|
||||||
|
style: textStyle,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
|
label: label,
|
||||||
hintText: hintText,
|
hintText: hintText,
|
||||||
),
|
),
|
||||||
controller: _textEditingController,
|
controller: _textEditingController,
|
||||||
obscureText: obscureText,
|
obscureText: obscureText,
|
||||||
onChanged: (v) {
|
onChanged: (v) {
|
||||||
value = v;
|
value = v;
|
||||||
|
onChange?.call(value);
|
||||||
},
|
},
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
for (var validator in validators) {
|
for (var validator in validators) {
|
||||||
|
|
|
@ -44,6 +44,8 @@ class RegistrationScreen extends StatelessWidget {
|
||||||
submitBtnTitle: translations.registerBtn,
|
submitBtnTitle: translations.registerBtn,
|
||||||
nextBtnTitle: translations.nextStepBtn,
|
nextBtnTitle: translations.nextStepBtn,
|
||||||
previousBtnTitle: translations.previousStepBtn,
|
previousBtnTitle: translations.previousStepBtn,
|
||||||
|
nextButtonBuilder: registrationOptions.nextButtonBuilder,
|
||||||
|
previousButtonBuilder: registrationOptions.previousButtonBuilder,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
name: flutter_registration
|
name: flutter_registration
|
||||||
description: A Flutter Registration package
|
description: A Flutter Registration package
|
||||||
version: 0.1.0
|
version: 0.2.0
|
||||||
repository: https://github.com/Iconica-Development/flutter_registration
|
repository: https://github.com/Iconica-Development/flutter_registration
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
|
|
Loading…
Reference in a new issue