Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add keyboardDismissBehavior to ScrollView #467

Merged
merged 2 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3

COCOAPODS: 1.12.1
COCOAPODS: 1.14.2
2 changes: 1 addition & 1 deletion example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = "The Chromium Authors";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion example/lib/login_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart' show timeDilation;
import 'package:flutter_login/flutter_login.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';

import 'package:login_example/constants.dart';
import 'package:login_example/custom_route.dart';
import 'package:login_example/dashboard_screen.dart';
Expand Down Expand Up @@ -52,6 +51,7 @@ class LoginScreen extends StatelessWidget {
Widget build(BuildContext context) {
return FlutterLogin(
title: Constants.appName,
keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
logo: const AssetImage('assets/images/ecorp.png'),
logoTag: Constants.logoTag,
titleTag: Constants.titleTag,
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -382,4 +382,4 @@ packages:
version: "0.3.0"
sdks:
dart: ">=3.2.0 <4.0.0"
flutter: ">=3.16.0"
flutter: ">=3.10.0"
10 changes: 5 additions & 5 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -98,4 +98,4 @@ flutter:
- asset: assets/fonts/Quicksand-SemiBold.ttf
weight: 600
- asset: assets/fonts/Quicksand-Bold.ttf
weight: 700
weight: 700
5 changes: 5 additions & 0 deletions lib/flutter_login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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?;

Expand Down Expand Up @@ -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!';
Expand Down Expand Up @@ -821,6 +824,7 @@ class _FlutterLoginState extends State<FlutterLogin>
],
),
SingleChildScrollView(
keyboardDismissBehavior: widget.keyboardDismissBehavior,
child: Theme(
data: theme,
child: Stack(
Expand All @@ -830,6 +834,7 @@ class _FlutterLoginState extends State<FlutterLogin>
child: AuthCard(
key: authCardKey,
userType: widget.userType,
keyboardDismissBehavior: widget.keyboardDismissBehavior,
padding: EdgeInsets.only(top: cardTopPosition),
loadingController: _loadingController,
userValidator: userValidator,
Expand Down
5 changes: 5 additions & 0 deletions lib/src/widgets/cards/auth_card_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class AuthCard extends StatefulWidget {
required this.confirmSignupKeyboardType,
this.introWidget,
required this.initialIsoCode,
this.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
});

final EdgeInsets padding;
Expand All @@ -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;
Expand Down Expand Up @@ -490,6 +494,7 @@ class AuthCardState extends State<AuthCard> with TickerProviderStateMixin {
child: Scrollbar(
controller: _scrollController,
child: SingleChildScrollView(
keyboardDismissBehavior: widget.keyboardDismissBehavior,
controller: _scrollController,
child: _changeToCard(context, index),
),
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 4.2.3
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
Expand All @@ -28,4 +28,4 @@ dev_dependencies:
flutter:
uses-material-design: true
assets:
- assets/images/ecorp.png
- assets/images/ecorp.png