From 0bd1739b7aaa30be8c3f3f763ffdb44d2c63aea8 Mon Sep 17 00:00:00 2001 From: MaddinMade Date: Mon, 21 Feb 2022 20:30:55 +0100 Subject: [PATCH 1/5] adds termsOfService animation --- lib/src/widgets/cards/login_card.dart | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/src/widgets/cards/login_card.dart b/lib/src/widgets/cards/login_card.dart index da51e145..01708845 100644 --- a/lib/src/widgets/cards/login_card.dart +++ b/lib/src/widgets/cards/login_card.dart @@ -608,22 +608,23 @@ class _LoginCardState extends State<_LoginCard> with TickerProviderStateMixin { vertical: 10, ), onExpandCompleted: () => _postSwitchAuthController.forward(), - child: _buildConfirmPasswordField(textFieldWidth, messages, auth), + child: Column(children: [ + _buildConfirmPasswordField(textFieldWidth, messages, auth), + ...auth.termsOfService + .map((e) => ScaleTransition( + scale: _buttonScaleAnimation, + child: TermCheckbox( + termOfService: e, + ), + )) + .toList(), + ]), ), Container( padding: Paddings.fromRBL(cardPadding), width: cardWidth, child: Column( children: [ - if (auth.isSignup && auth.termsOfService.isNotEmpty) - ...auth.termsOfService - .map((e) => ScaleTransition( - scale: _buttonScaleAnimation, - child: TermCheckbox( - termOfService: e, - ), - )) - .toList(), !widget.hideForgotPasswordButton ? _buildForgotPassword(theme, messages) : SizedBox.fromSize( From 67ffe21888fb61a065bac6ccb19d28bcc4fc0af3 Mon Sep 17 00:00:00 2001 From: MaddinMade Date: Mon, 21 Feb 2022 20:53:01 +0100 Subject: [PATCH 2/5] fixes padding --- lib/src/widgets/cards/login_card.dart | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/lib/src/widgets/cards/login_card.dart b/lib/src/widgets/cards/login_card.dart index 01708845..0130ec1d 100644 --- a/lib/src/widgets/cards/login_card.dart +++ b/lib/src/widgets/cards/login_card.dart @@ -603,21 +603,15 @@ class _LoginCardState extends State<_LoginCard> with TickerProviderStateMixin { alignment: Alignment.topLeft, color: theme.cardTheme.color, width: cardWidth, - padding: const EdgeInsets.symmetric( - horizontal: cardPadding, - vertical: 10, - ), + padding: const EdgeInsets.symmetric(horizontal: cardPadding), onExpandCompleted: () => _postSwitchAuthController.forward(), child: Column(children: [ - _buildConfirmPasswordField(textFieldWidth, messages, auth), - ...auth.termsOfService - .map((e) => ScaleTransition( - scale: _buttonScaleAnimation, - child: TermCheckbox( - termOfService: e, - ), - )) - .toList(), + Padding( + padding: const EdgeInsets.symmetric(vertical: 10.0), + child: + _buildConfirmPasswordField(textFieldWidth, messages, auth), + ), + for (var e in auth.termsOfService) TermCheckbox(termOfService: e), ]), ), Container( From da18d716649ffbc6964291717701b442c4f13f0b Mon Sep 17 00:00:00 2001 From: MaddinMade Date: Tue, 22 Feb 2022 03:10:16 +0100 Subject: [PATCH 3/5] fixes termsOfService validation --- lib/src/widgets/cards/login_card.dart | 6 +++++- lib/src/widgets/term_of_service_checkbox.dart | 11 +++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/src/widgets/cards/login_card.dart b/lib/src/widgets/cards/login_card.dart index 0130ec1d..1c425f85 100644 --- a/lib/src/widgets/cards/login_card.dart +++ b/lib/src/widgets/cards/login_card.dart @@ -611,7 +611,11 @@ class _LoginCardState extends State<_LoginCard> with TickerProviderStateMixin { child: _buildConfirmPasswordField(textFieldWidth, messages, auth), ), - for (var e in auth.termsOfService) TermCheckbox(termOfService: e), + for (var e in auth.termsOfService) + TermCheckbox( + termOfService: e, + validation: auth.isSignup, + ), ]), ), Container( diff --git a/lib/src/widgets/term_of_service_checkbox.dart b/lib/src/widgets/term_of_service_checkbox.dart index 38d27f84..2f23d76c 100644 --- a/lib/src/widgets/term_of_service_checkbox.dart +++ b/lib/src/widgets/term_of_service_checkbox.dart @@ -4,8 +4,13 @@ import 'package:url_launcher/url_launcher.dart'; class TermCheckbox extends StatefulWidget { final TermOfService termOfService; + final bool validation; - const TermCheckbox({Key? key, required this.termOfService}) : super(key: key); + const TermCheckbox({ + Key? key, + required this.termOfService, + this.validation = true, + }) : super(key: key); @override _TermCheckboxState createState() => _TermCheckboxState(); @@ -49,10 +54,12 @@ class _TermCheckboxState extends State { textAlign: TextAlign.left, ), validator: (bool? value) { - if (widget.termOfService.mandatory == true && + if (widget.validation && + widget.termOfService.mandatory == true && widget.termOfService.getStatus() != true) { return widget.termOfService.validationErrorMessage; } + return null; }, ); } From e6df72910e040124482c10d481821feeeb5b3c53 Mon Sep 17 00:00:00 2001 From: MaddinMade Date: Tue, 22 Feb 2022 21:02:21 +0100 Subject: [PATCH 4/5] minor changes --- lib/src/widgets/term_of_service_checkbox.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/widgets/term_of_service_checkbox.dart b/lib/src/widgets/term_of_service_checkbox.dart index 2f23d76c..10a278a2 100644 --- a/lib/src/widgets/term_of_service_checkbox.dart +++ b/lib/src/widgets/term_of_service_checkbox.dart @@ -55,8 +55,8 @@ class _TermCheckboxState extends State { ), validator: (bool? value) { if (widget.validation && - widget.termOfService.mandatory == true && - widget.termOfService.getStatus() != true) { + widget.termOfService.mandatory && + !widget.termOfService.getStatus()) { return widget.termOfService.validationErrorMessage; } return null; From 052baca359839fd74782b07454f1b2a27471af71 Mon Sep 17 00:00:00 2001 From: Julian Steenbakker Date: Tue, 15 Mar 2022 14:03:03 +0100 Subject: [PATCH 5/5] style: flutter format --- test/flutter_login_test.dart | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/test/flutter_login_test.dart b/test/flutter_login_test.dart index 9d297c85..4cdbe1e8 100644 --- a/test/flutter_login_test.dart +++ b/test/flutter_login_test.dart @@ -868,7 +868,13 @@ void main() { onLogin: (data) => null, onRecoverPassword: (data) => null, passwordValidator: (value) => value!.length == 5 ? null : 'Invalid!', - loginProviders: [LoginProvider(icon: Icons.ac_unit, callback: () {})], + loginProviders: [ + LoginProvider( + icon: Icons.ac_unit, + callback: () { + return null; + }) + ], messages: LoginMessages( signupButton: 'REGISTER', forgotPasswordButton: 'Forgot huh?', @@ -903,7 +909,13 @@ void main() { onRecoverPassword: (data) => null, passwordValidator: (value) => value!.length == 5 ? null : 'Invalid!', hideProvidersTitle: true, - loginProviders: [LoginProvider(icon: Icons.ac_unit, callback: () {})], + loginProviders: [ + LoginProvider( + icon: Icons.ac_unit, + callback: () { + return null; + }) + ], messages: LoginMessages( signupButton: 'REGISTER', forgotPasswordButton: 'Forgot huh?',