From be82836fd633690e5f54de63fa801dc8ea4292b4 Mon Sep 17 00:00:00 2001 From: Yusif Jasim Date: Mon, 27 Nov 2023 15:06:13 +0300 Subject: [PATCH] feat: add keyboardDismissBehavior to ScrollView --- example/ios/Podfile.lock | 2 +- example/ios/Runner.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- example/lib/login_screen.dart | 2 +- example/pubspec.lock | 46 +++++++++---------- example/pubspec.yaml | 10 ++-- lib/flutter_login.dart | 5 ++ .../widgets/cards/additional_signup_card.dart | 8 ++-- lib/src/widgets/cards/auth_card_builder.dart | 5 ++ lib/src/widgets/cards/login_card.dart | 4 +- pubspec.yaml | 5 +- 11 files changed, 49 insertions(+), 42 deletions(-) diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index a3cec427..3b3786ef 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -37,4 +37,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3 -COCOAPODS: 1.12.1 +COCOAPODS: 1.14.2 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index c67a3553..a78b39ef 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -165,7 +165,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1430; ORGANIZATIONNAME = "The Chromium Authors"; TargetAttributes = { 97C146ED1CF9000F007C117D = { diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 3db53b6e..b52b2e69 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ =3.1.0-185.0.dev <4.0.0" + dart: ">=3.2.0-194.0.dev <4.0.0" flutter: ">=3.10.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 33d2a1a2..0a1ceb18 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -4,7 +4,7 @@ version: 1.0.0+1 publish_to: none environment: - sdk: '>=2.12.0 <3.0.0' + sdk: ">=2.12.0 <3.0.0" dependencies: cupertino_icons: ^1.0.3 @@ -24,9 +24,9 @@ flutter: uses-material-design: true assets: - - assets/images/ecorp.png - - assets/images/ecorp-lightblue.png - - assets/images/ecorp-lightgreen.png + - assets/images/ecorp.png + - assets/images/ecorp-lightblue.png + - assets/images/ecorp-lightgreen.png fonts: - family: OpenSans @@ -98,4 +98,4 @@ flutter: - asset: assets/fonts/Quicksand-SemiBold.ttf weight: 600 - asset: assets/fonts/Quicksand-Bold.ttf - weight: 700 \ No newline at end of file + weight: 700 diff --git a/lib/flutter_login.dart b/lib/flutter_login.dart index 10a922d9..ef96305f 100644 --- a/lib/flutter_login.dart +++ b/lib/flutter_login.dart @@ -314,6 +314,7 @@ class FlutterLogin extends StatefulWidget { this.headerWidget, this.onSwitchToAdditionalFields, this.initialIsoCode, + this.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual, }) : assert((logo is String?) || (logo is ImageProvider?)), logo = logo is String ? AssetImage(logo) : logo as ImageProvider?; @@ -460,6 +461,8 @@ class FlutterLogin extends StatefulWidget { /// if not specified. This field will show ['US'] by default. final String? initialIsoCode; + final ScrollViewKeyboardDismissBehavior keyboardDismissBehavior; + static String? defaultEmailValidator(String? value) { if (value == null || value.isEmpty || !Regex.email.hasMatch(value)) { return 'Invalid email!'; @@ -821,6 +824,7 @@ class _FlutterLoginState extends State ], ), SingleChildScrollView( + keyboardDismissBehavior: widget.keyboardDismissBehavior, child: Theme( data: theme, child: Stack( @@ -830,6 +834,7 @@ class _FlutterLoginState extends State child: AuthCard( key: authCardKey, userType: widget.userType, + keyboardDismissBehavior: widget.keyboardDismissBehavior, padding: EdgeInsets.only(top: cardTopPosition), loadingController: _loadingController, userValidator: userValidator, diff --git a/lib/src/widgets/cards/additional_signup_card.dart b/lib/src/widgets/cards/additional_signup_card.dart index e35f0af3..3e630835 100644 --- a/lib/src/widgets/cards/additional_signup_card.dart +++ b/lib/src/widgets/cards/additional_signup_card.dart @@ -56,10 +56,10 @@ class _AdditionalSignUpCardState extends State<_AdditionalSignUpCard> super.initState(); _nameControllers = { - for (var formField in widget.formFields) + for (final formField in widget.formFields) formField.keyName: TextEditingController( text: formField.defaultValue, - ) + ), }; if (_nameControllers.length != widget.formFields.length) { @@ -186,7 +186,7 @@ class _AdditionalSignUpCardState extends State<_AdditionalSignUpCard> const Icon(FontAwesomeIcons.solidCircleUser), keyboardType: TextFieldUtils.getKeyboardType(formField.userType), autofillHints: [ - TextFieldUtils.getAutofillHints(formField.userType) + TextFieldUtils.getAutofillHints(formField.userType), ], textInputAction: formField.keyName == widget.formFields.last.keyName @@ -199,7 +199,7 @@ class _AdditionalSignUpCardState extends State<_AdditionalSignUpCard> ), const SizedBox( height: 5, - ) + ), ], ); }).toList(), diff --git a/lib/src/widgets/cards/auth_card_builder.dart b/lib/src/widgets/cards/auth_card_builder.dart index b880dd35..4fe2e7ce 100644 --- a/lib/src/widgets/cards/auth_card_builder.dart +++ b/lib/src/widgets/cards/auth_card_builder.dart @@ -53,6 +53,7 @@ class AuthCard extends StatefulWidget { required this.confirmSignupKeyboardType, this.introWidget, required this.initialIsoCode, + this.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual, }); final EdgeInsets padding; @@ -75,6 +76,9 @@ class AuthCard extends StatefulWidget { final bool navigateBackAfterRecovery; final bool scrollable; + + final ScrollViewKeyboardDismissBehavior keyboardDismissBehavior; + final TextInputType? confirmSignupKeyboardType; final Widget? introWidget; final String? initialIsoCode; @@ -490,6 +494,7 @@ class AuthCardState extends State with TickerProviderStateMixin { child: Scrollbar( controller: _scrollController, child: SingleChildScrollView( + keyboardDismissBehavior: widget.keyboardDismissBehavior, controller: _scrollController, child: _changeToCard(context, index), ), diff --git a/lib/src/widgets/cards/login_card.dart b/lib/src/widgets/cards/login_card.dart index 263ef233..911dfc0e 100644 --- a/lib/src/widgets/cards/login_card.dart +++ b/lib/src/widgets/cards/login_card.dart @@ -638,7 +638,7 @@ class _LoginCardState extends State<_LoginCard> with TickerProviderStateMixin { loginProvider: loginProvider, ), ), - Text(loginProvider.label) + Text(loginProvider.label), ], ), ), @@ -736,7 +736,7 @@ class _LoginCardState extends State<_LoginCard> with TickerProviderStateMixin { auth, ), ), - for (var e in auth.termsOfService) + for (final e in auth.termsOfService) TermCheckbox( termOfService: e, validation: auth.isSignup, diff --git a/pubspec.yaml b/pubspec.yaml index c2f50689..4b51c079 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ version: 4.2.1 repository: https://github.com/NearHuscarl/flutter_login environment: - sdk: '>=2.19.0 <4.0.0' + sdk: ">=2.19.0 <4.0.0" dependencies: another_flushbar: ^1.10.29 @@ -25,8 +25,7 @@ dev_dependencies: lint: ^2.0.1 mockito: ^5.0.16 - flutter: uses-material-design: true assets: - - assets/images/ecorp.png \ No newline at end of file + - assets/images/ecorp.png