diff --git a/.gitignore b/.gitignore index 96486fd..d920ae6 100644 --- a/.gitignore +++ b/.gitignore @@ -19,7 +19,7 @@ migrate_working_dir/ # The .vscode folder contains launch configuration and tasks you configure in # VS Code which you may wish to be included in version control, so this line # is commented out by default. -#.vscode/ +.vscode/ # Flutter/Dart/Pub related # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. diff --git a/CHANGELOG.md b/CHANGELOG.md index 29c00b5..d87e4bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2.0.2 +* Added more translatable options + ## 2.0.1 * Fixed email regex diff --git a/example/lib/main.dart b/example/lib/main.dart index 94b1b34..1dcb826 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -16,6 +16,7 @@ final loginOptions = LoginOptions( onPressed, isDisabled, onDisabledPress, + translations, ) { return Opacity( opacity: isDisabled ? 0.5 : 1.0, diff --git a/example/pubspec.lock b/example/pubspec.lock index 93429bf..d2a7089 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -61,7 +61,7 @@ packages: path: ".." relative: true source: path - version: "2.0.1" + version: "2.0.2" flutter_test: dependency: "direct dev" description: flutter diff --git a/lib/src/config/login_options.dart b/lib/src/config/login_options.dart index 9a6f3d4..b4917fd 100644 --- a/lib/src/config/login_options.dart +++ b/lib/src/config/login_options.dart @@ -60,11 +60,19 @@ class LoginTranslations { this.emailEmpty = 'Email is required', this.passwordEmpty = 'Password is required', this.emailInvalid = 'Enter a valid email address', + this.loginButton = 'Login', + this.forgotPasswordButton = 'Forgot password?', + this.requestForgotPasswordButton = 'Send request', + this.registrationButton = 'Create Account', }); final String emailInvalid; final String emailEmpty; final String passwordEmpty; + final String loginButton; + final String forgotPasswordButton; + final String requestForgotPasswordButton; + final String registrationButton; } Widget _createEmailInputContainer(Widget child) => child; @@ -76,12 +84,13 @@ Widget _createLoginButton( OptionalAsyncCallback onPressed, bool disabled, OptionalAsyncCallback onDisabledPress, + LoginTranslations translations, ) { return Opacity( opacity: disabled ? 0.5 : 1.0, child: ElevatedButton( onPressed: !disabled ? onPressed : onDisabledPress, - child: const Text('Login'), + child: Text(translations.loginButton), ), ); } @@ -91,12 +100,13 @@ Widget _createForgotPasswordButton( OptionalAsyncCallback onPressed, bool disabled, OptionalAsyncCallback onDisabledPress, + LoginTranslations translations, ) { return Opacity( opacity: disabled ? 0.5 : 1.0, child: ElevatedButton( onPressed: !disabled ? onPressed : onDisabledPress, - child: const Text('Forgot password?'), + child: Text(translations.forgotPasswordButton), ), ); } @@ -106,12 +116,13 @@ Widget _createRequestForgotPasswordButton( OptionalAsyncCallback onPressed, bool disabled, OptionalAsyncCallback onDisabledPress, + LoginTranslations translations, ) { return Opacity( opacity: disabled ? 0.5 : 1.0, child: ElevatedButton( onPressed: !disabled ? onPressed : onDisabledPress, - child: const Text('Send request'), + child: Text(translations.requestForgotPasswordButton), ), ); } @@ -121,12 +132,13 @@ Widget _createRegisterButton( OptionalAsyncCallback onPressed, bool disabled, OptionalAsyncCallback onDisabledPress, + LoginTranslations translations, ) { return Opacity( opacity: disabled ? 0.5 : 1.0, child: ElevatedButton( onPressed: !disabled ? onPressed : onDisabledPress, - child: const Text('Create Account'), + child: Text(translations.registrationButton), ), ); } @@ -136,6 +148,7 @@ typedef ButtonBuilder = Widget Function( OptionalAsyncCallback onPressed, bool isDisabled, OptionalAsyncCallback onDisabledPress, + LoginTranslations options, ); typedef InputContainerBuilder = Widget Function( diff --git a/lib/src/widgets/email_password_login.dart b/lib/src/widgets/email_password_login.dart index 4bad483..df527db 100644 --- a/lib/src/widgets/email_password_login.dart +++ b/lib/src/widgets/email_password_login.dart @@ -162,6 +162,7 @@ class _EmailPasswordLoginFormState extends State { }, false, () {}, + options.translations, ), ), ], @@ -176,6 +177,7 @@ class _EmailPasswordLoginFormState extends State { () { _formKey.currentState?.validate(); }, + options.translations, ); }, ), @@ -190,6 +192,7 @@ class _EmailPasswordLoginFormState extends State { }, false, () {}, + options.translations, ), ] ], diff --git a/lib/src/widgets/forgot_password_form.dart b/lib/src/widgets/forgot_password_form.dart index 3a1a5eb..8355aff 100644 --- a/lib/src/widgets/forgot_password_form.dart +++ b/lib/src/widgets/forgot_password_form.dart @@ -133,6 +133,7 @@ class _ForgotPasswordFormState extends State { () { _formKey.currentState?.validate(); }, + options.translations, ), ); }, diff --git a/pubspec.yaml b/pubspec.yaml index a62d64a..3e54b8e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_login description: A new Flutter package project. -version: 2.0.1 +version: 2.0.2 environment: sdk: ">=2.18.1 <3.0.0" @@ -15,39 +15,4 @@ dev_dependencies: sdk: flutter flutter_lints: ^2.0.0 -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - -# The following section is specific to Flutter packages. flutter: - - # To add assets to your package, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - # - # For details regarding assets in packages, see - # https://flutter.dev/assets-and-images/#from-packages - # - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware - - # To add custom fonts to your package, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts in packages, see - # https://flutter.dev/custom-fonts/#from-packages