From 1f173e6748bdfc934d923ab31e071794f72e7ae6 Mon Sep 17 00:00:00 2001 From: Bahrican Yesil Date: Thu, 27 Jan 2022 16:51:29 +0300 Subject: [PATCH] Fixed auth mode change behavior on mobile --- CHANGELOG.md | 5 +++++ example/pubspec.lock | 2 +- lib/animated_login.dart | 19 +++++++++---------- lib/src/widgets/form_part.dart | 14 +++++++++++--- pubspec.yaml | 2 +- 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8232311..7665b24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Versions +## [1.2.1] - 27.01.2022 + +* Fixed the auth mode change behavior on mobile. +* Optimized the spaces/paddings between form and action button for mobile. + ## [1.2.0] - 27.01.2022 * Optimized the use of AnimatedBuilder to avoid unnecessary rebuilds. diff --git a/example/pubspec.lock b/example/pubspec.lock index e0b6abf..795b842 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,7 +7,7 @@ packages: path: ".." relative: true source: path - version: "1.2.0" + version: "1.2.1" animations: dependency: transitive description: diff --git a/lib/animated_login.dart b/lib/animated_login.dart index 2faad38..ccca882 100644 --- a/lib/animated_login.dart +++ b/lib/animated_login.dart @@ -517,20 +517,19 @@ class __ViewState extends State<_View> with SingleTickerProviderStateMixin { auth.setIsReverse(welcomeTransitionAnimation.value <= context.read().formWidthRatio / 2); } else if (_forwardCheck) { - auth.setIsReverse(!auth.isReverse); + auth.setIsReverse(false); + } else if (_reverseCheck) { + auth.setIsReverse(true); } } }); } - bool get _forwardCheck => _isLandscape - ? welcomeTransitionAnimation.value <= - context.read().formWidthRatio / 2 - : welcomeTransitionAnimation.value <= -100 && _statusCheck; + bool get _forwardCheck => + welcomeTransitionAnimation.value > 0 && + welcomeTransitionAnimation.status == AnimationStatus.forward; - bool get _statusCheck => - (welcomeTransitionAnimation.status == AnimationStatus.forward && - _isReverse) || - (welcomeTransitionAnimation.status == AnimationStatus.reverse && - !_isReverse); + bool get _reverseCheck => + welcomeTransitionAnimation.value < 0 && + welcomeTransitionAnimation.status == AnimationStatus.reverse; } diff --git a/lib/src/widgets/form_part.dart b/lib/src/widgets/form_part.dart index 9287b99..f4b705d 100644 --- a/lib/src/widgets/form_part.dart +++ b/lib/src/widgets/form_part.dart @@ -214,14 +214,22 @@ class __FormPartState extends State<_FormPart> { loginTheme.spacingWithoutSocial ?? dynamicSize.height * 6, ), _form, - SizedBox( - height: loginTheme.spacingFormAndAction ?? - dynamicSize.height * (_isLandscape ? 4 : 3)), + SizedBox(height: loginTheme.spacingFormAndAction ?? _customSpace), _actionButton, ], ), ); + double get _customSpace { + double factor = 3; + if (_isLandscape) { + factor = 4; + } else if (_isReverse) { + factor = 0.5; + } + return dynamicSize.height * factor; + } + List get _socialLoginPart => [ SizedBox(height: dynamicSize.height * 2.5), _socialLoginOptions, diff --git a/pubspec.yaml b/pubspec.yaml index de5926d..521003e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: animated_login description: Animated Login for Flutter. You can welcome your users with this beautiful animated screen that gives functionality for both login and sign up. -version: 1.2.0 +version: 1.2.1 homepage: https://github.com/bahricanyesil/flutter-animated-login repository: https://github.com/bahricanyesil/flutter-animated-login