From f46dd989deaed901eab536e19c2db6ac732618ba Mon Sep 17 00:00:00 2001 From: mike doornenbal Date: Mon, 20 Nov 2023 16:37:21 +0100 Subject: [PATCH] feat: added the options to disable the show password button --- CHANGELOG.md | 3 +++ example/pubspec.lock | 2 +- lib/src/config/login_options.dart | 2 ++ lib/src/widgets/email_password_login.dart | 27 +++++++++++++---------- pubspec.yaml | 2 +- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff35d90..89b5f95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 5.1.0 +* Added the option to disable the showPassword button on the passwordfield. + ## 5.0.0 * Removed the redundant initialEmail parameter from 'ForgotPasswordForm'. The only one to use now is the one in the 'LoginOptions'. diff --git a/example/pubspec.lock b/example/pubspec.lock index abf4bb3..b3c57a6 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -68,7 +68,7 @@ packages: path: ".." relative: true source: path - version: "4.2.0" + version: "5.0.0" flutter_test: dependency: "direct dev" description: flutter diff --git a/lib/src/config/login_options.dart b/lib/src/config/login_options.dart index 6f3af51..a9e9c6f 100644 --- a/lib/src/config/login_options.dart +++ b/lib/src/config/login_options.dart @@ -28,6 +28,7 @@ class LoginOptions { this.registrationButtonBuilder = _createRegisterButton, this.emailInputContainerBuilder = _createEmailInputContainer, this.passwordInputContainerBuilder = _createPasswordInputContainer, + this.showObscurePassword = true, }); final ButtonBuilder loginButtonBuilder; @@ -55,6 +56,7 @@ class LoginOptions { final TextStyle? passwordTextStyle; final LoginTranslations translations; final ValidationService? validationService; + final bool showObscurePassword; ValidationService get validations => validationService ?? LoginValidationService(this); diff --git a/lib/src/widgets/email_password_login.dart b/lib/src/widgets/email_password_login.dart index 1e57110..b08c1a3 100644 --- a/lib/src/widgets/email_password_login.dart +++ b/lib/src/widgets/email_password_login.dart @@ -161,18 +161,21 @@ class _EmailPasswordLoginFormState extends State { style: options.passwordTextStyle, onFieldSubmitted: (_) => _handleLogin(), decoration: options.passwordDecoration.copyWith( - suffixIcon: IconButton( - onPressed: () { - setState(() { - _obscurePassword = !_obscurePassword; - }); - }, - icon: Icon( - _obscurePassword - ? Icons.visibility - : Icons.visibility_off, - ), - ), + suffixIcon: options.showObscurePassword + ? IconButton( + onPressed: () { + setState(() { + _obscurePassword = + !_obscurePassword; + }); + }, + icon: Icon( + _obscurePassword + ? Icons.visibility + : Icons.visibility_off, + ), + ) + : null, ), ), ), diff --git a/pubspec.yaml b/pubspec.yaml index cff9d12..63ecbfb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_login description: Flutter Login Component -version: 5.0.0 +version: 5.1.0 environment: sdk: ">=2.18.1 <3.0.0"