diff --git a/.gitignore b/.gitignore index 8089648..dde2eb5 100644 --- a/.gitignore +++ b/.gitignore @@ -33,4 +33,5 @@ migrate_working_dir/ .packages build/ .flutter-plugins -.flutter-plugins-dependencies \ No newline at end of file +.flutter-plugins-dependencies +.metadata \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 501e26b..e87f410 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ SPDX-License-Identifier: GPL-3.0-or-later - feat: added validation to disable next button - feat(auth-screen): add flexible spacing between fields - fix(keyboard-focus): add unfocus for onPrevious +- fix: add empty and required constructors for the RegistrationTranslations # 1.2.0 diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml deleted file mode 100644 index ecb97fe..0000000 --- a/bitbucket-pipelines.yml +++ /dev/null @@ -1,48 +0,0 @@ -# SPDX-FileCopyrightText: 2022 Iconica -# -# SPDX-License-Identifier: GPL-3.0-or-later - -image: cirrusci/flutter - -pipelines: - pull-requests: - feature/*: - - step: - caches: - - gradle - - gradlewrapper - - flutter - name: Run analyzer & test - script: - - flutter pub get - - flutter format -o none --set-exit-if-changed . - - flutter analyze - - develop: - - step: - caches: - - gradle - - gradlewrapper - - flutter - name: Run analyzer & test - script: - - flutter pub get - - flutter format -o none --set-exit-if-changed . - - flutter analyze - - hotfix/*: - - step: - caches: - - gradle - - gradlewrapper - - flutter - name: Run analyzer & test - script: - - flutter pub get - - flutter format -o none --set-exit-if-changed . - - flutter analyze - -definitions: - caches: - gradlewrapper: ~/.gradle/wrapper - flutter: ~/.pub-cache diff --git a/lib/flutter_registration.dart b/lib/flutter_registration.dart index d599a3c..d4d9e9a 100644 --- a/lib/flutter_registration.dart +++ b/lib/flutter_registration.dart @@ -1,7 +1,7 @@ // SPDX-FileCopyrightText: 2022 Iconica // // SPDX-License-Identifier: BSD-3-Clause - +/// Flutter registration component that provides a registration screen with multiple registration steps. library flutter_registration; export 'src/config/registration_options.dart'; diff --git a/lib/src/auth_screen.dart b/lib/src/auth_screen.dart index 12b2bf1..511bf6e 100644 --- a/lib/src/auth_screen.dart +++ b/lib/src/auth_screen.dart @@ -159,14 +159,12 @@ class _AuthScreenState extends State { mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ - Expanded( + Spacer( flex: widget.beforeTitleFlex ?? 3, - child: Container(), ), widget.titleWidget!, - Expanded( + Spacer( flex: widget.afterTitleFlex ?? 2, - child: Container(), ), ], ), diff --git a/lib/src/config/registration_options.dart b/lib/src/config/registration_options.dart index 1d3e9e3..7ba7d6c 100644 --- a/lib/src/config/registration_options.dart +++ b/lib/src/config/registration_options.dart @@ -12,7 +12,7 @@ class RegistrationOptions { required this.registrationRepository, required this.registrationSteps, required this.afterRegistration, - this.registrationTranslations = const RegistrationTranslations(), + this.registrationTranslations = const RegistrationTranslations.empty(), this.onError, this.customAppbarBuilder, this.nextButtonBuilder, @@ -43,7 +43,8 @@ class RegistrationOptions { TextEditingController? pass2Controller, bool pass2Hidden = true, Function(bool mainPass, bool value)? passHideOnChange, - RegistrationTranslations translations = const RegistrationTranslations(), + RegistrationTranslations translations = + const RegistrationTranslations.empty(), Function(String title)? titleBuilder, Function(String label)? labelBuilder, TextStyle? textStyle, diff --git a/lib/src/config/registration_translations.dart b/lib/src/config/registration_translations.dart index 8c60be4..81b6dca 100644 --- a/lib/src/config/registration_translations.dart +++ b/lib/src/config/registration_translations.dart @@ -2,28 +2,49 @@ // // SPDX-License-Identifier: BSD-3-Clause +/// Holds all the translations for the standard elements on the registration screen. class RegistrationTranslations { const RegistrationTranslations({ - this.title = 'Register', - this.registerBtn = 'Register', - this.previousStepBtn = 'Previous', - this.nextStepBtn = 'Next', - this.closeBtn = 'Close', - this.defaultEmailTitle = 'What is your email?', - this.defaultEmailLabel = '', - this.defaultEmailHint = 'john.doe@domain.com', - this.defaultEmailEmpty = 'Enter your email', - this.defaultEmailValidatorMessage = 'Enter a valid email address', - this.defaultPassword1Title = 'Enter a password', - this.defaultPassword1Label = '', - this.defaultPassword1Hint = '', - this.defaultPassword1ValidatorMessage = 'Enter a valid password', - this.defaultPassword2Title = 'Re-enter password', - this.defaultPassword2Label = '', - this.defaultPassword2Hint = '', - this.defaultPassword2ValidatorMessage = 'Passwords have to be equal', + required this.title, + required this.registerBtn, + required this.previousStepBtn, + required this.nextStepBtn, + required this.closeBtn, + required this.defaultEmailTitle, + required this.defaultEmailLabel, + required this.defaultEmailHint, + required this.defaultEmailEmpty, + required this.defaultEmailValidatorMessage, + required this.defaultPassword1Title, + required this.defaultPassword1Label, + required this.defaultPassword1Hint, + required this.defaultPassword1ValidatorMessage, + required this.defaultPassword2Title, + required this.defaultPassword2Label, + required this.defaultPassword2Hint, + required this.defaultPassword2ValidatorMessage, }); + const RegistrationTranslations.empty() + : title = 'Register', + registerBtn = 'Register', + previousStepBtn = 'Previous', + nextStepBtn = 'Next', + closeBtn = 'Close', + defaultEmailTitle = 'What is your email?', + defaultEmailLabel = '', + defaultEmailHint = 'john.doe@domain.com', + defaultEmailEmpty = 'Enter your email', + defaultEmailValidatorMessage = 'Enter a valid email address', + defaultPassword1Title = 'Enter a password', + defaultPassword1Label = '', + defaultPassword1Hint = '', + defaultPassword1ValidatorMessage = 'Enter a valid password', + defaultPassword2Title = 'Re-enter password', + defaultPassword2Label = '', + defaultPassword2Hint = '', + defaultPassword2ValidatorMessage = 'Passwords have to be equal'; + final String title; final String registerBtn; final String previousStepBtn; @@ -42,4 +63,54 @@ class RegistrationTranslations { final String defaultPassword2Label; final String defaultPassword2Hint; final String defaultPassword2ValidatorMessage; + + // create a copywith + RegistrationTranslations copyWith({ + String? title, + String? registerBtn, + String? previousStepBtn, + String? nextStepBtn, + String? closeBtn, + String? defaultEmailTitle, + String? defaultEmailLabel, + String? defaultEmailHint, + String? defaultEmailEmpty, + String? defaultEmailValidatorMessage, + String? defaultPassword1Title, + String? defaultPassword1Label, + String? defaultPassword1Hint, + String? defaultPassword1ValidatorMessage, + String? defaultPassword2Title, + String? defaultPassword2Label, + String? defaultPassword2Hint, + String? defaultPassword2ValidatorMessage, + }) { + return RegistrationTranslations( + title: title ?? this.title, + registerBtn: registerBtn ?? this.registerBtn, + previousStepBtn: previousStepBtn ?? this.previousStepBtn, + nextStepBtn: nextStepBtn ?? this.nextStepBtn, + closeBtn: closeBtn ?? this.closeBtn, + defaultEmailTitle: defaultEmailTitle ?? this.defaultEmailTitle, + defaultEmailLabel: defaultEmailLabel ?? this.defaultEmailLabel, + defaultEmailHint: defaultEmailHint ?? this.defaultEmailHint, + defaultEmailEmpty: defaultEmailEmpty ?? this.defaultEmailEmpty, + defaultEmailValidatorMessage: + defaultEmailValidatorMessage ?? this.defaultEmailValidatorMessage, + defaultPassword1Title: + defaultPassword1Title ?? this.defaultPassword1Title, + defaultPassword1Label: + defaultPassword1Label ?? this.defaultPassword1Label, + defaultPassword1Hint: defaultPassword1Hint ?? this.defaultPassword1Hint, + defaultPassword1ValidatorMessage: defaultPassword1ValidatorMessage ?? + this.defaultPassword1ValidatorMessage, + defaultPassword2Title: + defaultPassword2Title ?? this.defaultPassword2Title, + defaultPassword2Label: + defaultPassword2Label ?? this.defaultPassword2Label, + defaultPassword2Hint: defaultPassword2Hint ?? this.defaultPassword2Hint, + defaultPassword2ValidatorMessage: defaultPassword2ValidatorMessage ?? + this.defaultPassword2ValidatorMessage, + ); + } } diff --git a/lib/src/model/auth_bool_field.dart b/lib/src/model/auth_bool_field.dart index 3fc243b..503c4f4 100644 --- a/lib/src/model/auth_bool_field.dart +++ b/lib/src/model/auth_bool_field.dart @@ -12,7 +12,7 @@ class AuthBoolField extends AuthField { required this.widgetType, super.title, super.validators = const [], - super.value = '', + super.value = false, this.leftWidget, this.rightWidget, this.onChange, diff --git a/pubspec.yaml b/pubspec.yaml index 716570e..2f50a67 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,7 +17,7 @@ dependencies: flutter_input_library: git: url: https://github.com/Iconica-Development/flutter_input_library - ref: 3.0.1 + ref: 3.1.0 flutter: sdk: flutter