From 3a977fd2422f51ac2a6c57f7acfb7baff3fbef7c Mon Sep 17 00:00:00 2001 From: Ivan Antunes Date: Tue, 30 Jul 2024 10:57:13 -0300 Subject: [PATCH] =?UTF-8?q?fix:=20Corre=C3=A7=C3=A3o=20Tela=20de=20Login?= =?UTF-8?q?=20e=20Esqueci=20minha=20Senha?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Podfile.lock | 44 +++++ lib/actions/actions.dart | 152 ++++++++--------- .../throw_exception_widget.dart | 161 ++++++++++-------- ...got_password_template_component_model.dart | 4 +- ...ot_password_template_component_widget.dart | 74 ++++---- .../sign_in_template_component_widget.dart | 99 +++++------ lib/flutter_flow/internationalization.dart | 8 +- lib/main.dart | 6 + .../schedule_complete_visit_page_widget.dart | 2 +- lib/shared/enums/enum_throw_exception.dart | 5 + lib/shared/utils/dialog_util.dart | 59 +++++++ lib/shared/utils/log_util.dart | 15 ++ ...ValidatorUtil.dart => validator_util.dart} | 0 pubspec.lock | 16 ++ pubspec.yaml | 1 + 15 files changed, 396 insertions(+), 250 deletions(-) create mode 100644 lib/shared/enums/enum_throw_exception.dart create mode 100644 lib/shared/utils/dialog_util.dart create mode 100644 lib/shared/utils/log_util.dart rename lib/shared/utils/{ValidatorUtil.dart => validator_util.dart} (100%) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index dbd080c3..0aa4fbd2 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -42,6 +42,9 @@ PODS: - FirebaseAnalytics (~> 10.27.0) - Firebase/CoreOnly (10.27.0): - FirebaseCore (= 10.27.0) + - Firebase/Crashlytics (10.27.0): + - Firebase/CoreOnly + - FirebaseCrashlytics (~> 10.27.0) - Firebase/Messaging (10.27.0): - Firebase/CoreOnly - FirebaseMessaging (~> 10.27.0) @@ -52,6 +55,10 @@ PODS: - firebase_core (3.1.0): - Firebase/CoreOnly (= 10.27.0) - Flutter + - firebase_crashlytics (4.0.1): + - Firebase/Crashlytics (= 10.27.0) + - firebase_core + - Flutter - firebase_messaging (15.0.1): - Firebase/Messaging (= 10.27.0) - firebase_core @@ -78,8 +85,19 @@ PODS: - FirebaseCoreInternal (~> 10.0) - GoogleUtilities/Environment (~> 7.12) - GoogleUtilities/Logger (~> 7.12) + - FirebaseCoreExtension (10.29.0): + - FirebaseCore (~> 10.0) - FirebaseCoreInternal (10.28.0): - "GoogleUtilities/NSData+zlib (~> 7.8)" + - FirebaseCrashlytics (10.27.0): + - FirebaseCore (~> 10.5) + - FirebaseInstallations (~> 10.0) + - FirebaseRemoteConfigInterop (~> 10.23) + - FirebaseSessions (~> 10.5) + - GoogleDataTransport (~> 9.2) + - GoogleUtilities/Environment (~> 7.8) + - nanopb (< 2.30911.0, >= 2.30908.0) + - PromisesObjC (~> 2.1) - FirebaseInstallations (10.28.0): - FirebaseCore (~> 10.0) - GoogleUtilities/Environment (~> 7.8) @@ -94,6 +112,16 @@ PODS: - GoogleUtilities/Reachability (~> 7.8) - GoogleUtilities/UserDefaults (~> 7.8) - nanopb (< 2.30911.0, >= 2.30908.0) + - FirebaseRemoteConfigInterop (10.29.0) + - FirebaseSessions (10.29.0): + - FirebaseCore (~> 10.5) + - FirebaseCoreExtension (~> 10.0) + - FirebaseInstallations (~> 10.0) + - GoogleDataTransport (~> 9.2) + - GoogleUtilities/Environment (~> 7.13) + - GoogleUtilities/UserDefaults (~> 7.13) + - nanopb (< 2.30911.0, >= 2.30908.0) + - PromisesSwift (~> 2.1) - Flutter (1.0.0) - flutter_inappwebview_ios (0.0.1): - Flutter @@ -174,6 +202,8 @@ PODS: - permission_handler_apple (9.3.0): - Flutter - PromisesObjC (2.4.0) + - PromisesSwift (2.4.0): + - PromisesObjC (= 2.4.0) - SDWebImage (5.19.2): - SDWebImage/Core (= 5.19.2) - SDWebImage/Core (5.19.2) @@ -199,6 +229,7 @@ DEPENDENCIES: - file_picker (from `.symlinks/plugins/file_picker/ios`) - firebase_analytics (from `.symlinks/plugins/firebase_analytics/ios`) - firebase_core (from `.symlinks/plugins/firebase_core/ios`) + - firebase_crashlytics (from `.symlinks/plugins/firebase_crashlytics/ios`) - firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`) - Flutter (from `Flutter`) - flutter_inappwebview_ios (from `.symlinks/plugins/flutter_inappwebview_ios/ios`) @@ -222,15 +253,20 @@ SPEC REPOS: - Firebase - FirebaseAnalytics - FirebaseCore + - FirebaseCoreExtension - FirebaseCoreInternal + - FirebaseCrashlytics - FirebaseInstallations - FirebaseMessaging + - FirebaseRemoteConfigInterop + - FirebaseSessions - GoogleAppMeasurement - GoogleDataTransport - GoogleUtilities - nanopb - OrderedSet - PromisesObjC + - PromisesSwift - SDWebImage - SwiftyGif @@ -243,6 +279,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/firebase_analytics/ios" firebase_core: :path: ".symlinks/plugins/firebase_core/ios" + firebase_crashlytics: + :path: ".symlinks/plugins/firebase_crashlytics/ios" firebase_messaging: :path: ".symlinks/plugins/firebase_messaging/ios" Flutter: @@ -282,12 +320,17 @@ SPEC CHECKSUMS: Firebase: 26b040b20866a55f55eb3611b9fcf3ae64816b86 firebase_analytics: 0627e95b73eb9e04f59167687ed5bc3f6fb50f23 firebase_core: 483cfad66d24d8f3c233f31db4263830c625c909 + firebase_crashlytics: 8f04c663c8734f97c4ccbe81b8511ce7060e3b28 firebase_messaging: e60c0694699d8a2e56a319e043709583f6544123 FirebaseAnalytics: f9211b719db260cc91aebee8bb539cb367d0dfd1 FirebaseCore: a2b95ae4ce7c83ceecfbbbe3b6f1cddc7415a808 + FirebaseCoreExtension: 705ca5b14bf71d2564a0ddc677df1fc86ffa600f FirebaseCoreInternal: 58d07f1362fddeb0feb6a857d1d1d1c5e558e698 + FirebaseCrashlytics: 81ea6ec96519388687f6061beb838a8eec482293 FirebaseInstallations: 60c1d3bc1beef809fd1ad1189a8057a040c59f2e FirebaseMessaging: 585984d0a1df120617eb10b44cad8968b859815e + FirebaseRemoteConfigInterop: 6efda51fb5e2f15b16585197e26eaa09574e8a4d + FirebaseSessions: dbd14adac65ce996228652c1fc3a3f576bdf3ecc Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 flutter_inappwebview_ios: 97215cf7d4677db55df76782dbd2930c5e1c1ea0 flutter_local_notifications: 4cde75091f6327eb8517fa068a0a5950212d2086 @@ -302,6 +345,7 @@ SPEC CHECKSUMS: path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46 permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2 PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47 + PromisesSwift: 9d77319bbe72ebf6d872900551f7eeba9bce2851 SDWebImage: dfe95b2466a9823cf9f0c6d01217c06550d7b29a share_plus: 8875f4f2500512ea181eef553c3e27dba5135aad shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78 diff --git a/lib/actions/actions.dart b/lib/actions/actions.dart index 5d80d184..2a864382 100644 --- a/lib/actions/actions.dart +++ b/lib/actions/actions.dart @@ -14,6 +14,7 @@ import 'package:hub/flutter_flow/nav/nav.dart'; import 'package:flutter/material.dart'; import 'package:hub/flutter_flow/random_data_util.dart'; import 'package:hub/pages/home_page/home_page_model.dart'; +import 'package:hub/shared/utils/dialog_util.dart'; import 'package:qr_flutter/qr_flutter.dart'; @@ -21,6 +22,8 @@ import 'package:qr_flutter/qr_flutter.dart'; import 'package:url_launcher/url_launcher.dart'; +import '../shared/utils/log_util.dart'; + Future openTermsOfUse(BuildContext context) async { log('openTermsOfUse'); final Uri url = Uri.parse('https://freaccess.com.br/pp/'); @@ -108,92 +111,89 @@ Future singInLoginAction( String? emailAdress, String? password, }) async { - String? devUUID; - ApiCallResponse? loginCall; - await Future.wait([ - Future(() async { - FFAppState().email = emailAdress!; - }), - Future(() async { - FFAppState().passwd = password!; - }), - ]); - if ((FFAppState().email != '') && (FFAppState().passwd != '')) { - devUUID = await getDevUUID(); - FFAppState().devUUID = devUUID!; - loginCall = await PhpGroup.loginCall.call( - email: FFAppState().email, - password: FFAppState().passwd, - uuid: FFAppState().devUUID, - type: FFAppState().device, - description: randomString( - 10, - 10, - true, - false, - false, - ), - ); + try { + String? devUUID; + ApiCallResponse? loginCall; - if (PhpGroup.loginCall.error( + await Future.wait([ + Future(() async { + FFAppState().email = emailAdress!; + }), + Future(() async { + FFAppState().passwd = password!; + }), + ]); + + if ((FFAppState().email != '') && (FFAppState().passwd != '')) { + devUUID = await getDevUUID(); + + FFAppState().devUUID = devUUID!; + + loginCall = await PhpGroup.loginCall.call( + email: FFAppState().email, + password: FFAppState().passwd, + uuid: FFAppState().devUUID, + type: FFAppState().device, + description: randomString( + 10, + 10, + true, + false, + false, + ), + ); + + if (PhpGroup.loginCall.error((loginCall.jsonBody ?? '')) == false) { + + FFAppState().userUUID = PhpGroup.loginCall.userUUID( (loginCall.jsonBody ?? ''), - ) == - false) { - FFAppState().userUUID = PhpGroup.loginCall.userUUID( - (loginCall.jsonBody ?? ''), - )!; - // FFAppState().token = await FirebaseMessaging.instance.getToken(); - FFAppState().createdAt = dateTimeFormat( - 'd/M/y H:mm:ss', - getCurrentTimestamp, - locale: FFLocalizations.of(context).languageCode, - ); - FFAppState().updatedAt = '00/00/0000 00:00:00'; - FFAppState().status = PhpGroup.loginCall.userStatus( - (loginCall.jsonBody ?? ''), - )!; - FFAppState().userDevUUID = PhpGroup.loginCall.userDeviceId( - (loginCall.jsonBody ?? ''), - )!; - FFAppState().name = PhpGroup.loginCall.userName( - (loginCall.jsonBody ?? ''), - )!; - FFAppState().serialNumber = await getSerialNumber() ?? ''; - FFAppState().isLogged = true; - await toggleHomePage(context); - return; - } else { - await showModalBottomSheet( - isScrollControlled: true, - backgroundColor: Colors.transparent, - useSafeArea: true, - context: context, - builder: (context) { - return Padding( - padding: MediaQuery.viewInsetsOf(context), - child: ThrowExceptionWidget( - msg: PhpGroup.loginCall.msg( - (loginCall?.jsonBody ?? ''), - )!, - ), - ); - }, - ); + )!; - FFAppState().deleteEmail(); - FFAppState().email = ''; + FFAppState().createdAt = dateTimeFormat( + 'd/M/y H:mm:ss', + getCurrentTimestamp, + locale: FFLocalizations.of(context).languageCode, + ); - FFAppState().deletePasswd(); - FFAppState().passwd = ''; + FFAppState().updatedAt = '00/00/0000 00:00:00'; - FFAppState().update(() {}); + FFAppState().status = PhpGroup.loginCall.userStatus((loginCall.jsonBody ?? ''))!; + + FFAppState().userDevUUID = PhpGroup.loginCall.userDeviceId((loginCall.jsonBody ?? ''))!; + + FFAppState().name = PhpGroup.loginCall.userName((loginCall.jsonBody ?? ''))!; + + FFAppState().serialNumber = await getSerialNumber() ?? ''; + + FFAppState().isLogged = true; + + await toggleHomePage(context); + } else { + + if (PhpGroup.loginCall.msg((loginCall?.jsonBody ?? '')) == null) { + DialogUtil.errorDefault(context); + } else { + DialogUtil.error(context, PhpGroup.loginCall.msg((loginCall?.jsonBody ?? '')).toString()); + } + + FFAppState().deleteEmail(); + FFAppState().email = ''; + + FFAppState().deletePasswd(); + FFAppState().passwd = ''; + + FFAppState().update(() {}); + } } return; - } else { - return; + + } catch (e, s) { + DialogUtil.errorDefault(context); + LogUtil.requestAPIFailed('login.php', emailAdress.toString(), "Login", e, s); } + } Future signUpRegisterAction( diff --git a/lib/components/molecular_components/throw_exception/throw_exception_widget.dart b/lib/components/molecular_components/throw_exception/throw_exception_widget.dart index 95333ddd..6026a836 100644 --- a/lib/components/molecular_components/throw_exception/throw_exception_widget.dart +++ b/lib/components/molecular_components/throw_exception/throw_exception_widget.dart @@ -1,3 +1,5 @@ +import 'package:hub/shared/enums/enum_throw_exception.dart'; + import '/flutter_flow/flutter_flow_animations.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; @@ -7,15 +9,16 @@ import 'package:google_fonts/google_fonts.dart'; import 'throw_exception_model.dart'; export 'throw_exception_model.dart'; -/// - class ThrowExceptionWidget extends StatefulWidget { - const ThrowExceptionWidget({ + + ThrowExceptionWidget({ super.key, required this.msg, + this.type = EnumThrowException.error }); final String? msg; + EnumThrowException type; @override State createState() => _ThrowExceptionWidgetState(); @@ -61,6 +64,39 @@ class _ThrowExceptionWidgetState extends State super.dispose(); } + Color _getColorByType(BuildContext context) { + switch (widget.type) { + case EnumThrowException.error: + return FlutterFlowTheme.of(context).error; + case EnumThrowException.warning: + return FlutterFlowTheme.of(context).warning; + case EnumThrowException.success: + return FlutterFlowTheme.of(context).success; + } + } + + IconData _getIconByType(BuildContext context) { + switch (widget.type) { + case EnumThrowException.error: + return Icons.cancel_outlined; + case EnumThrowException.warning: + return Icons.warning_amber_outlined; + case EnumThrowException.success: + return Icons.check_circle_outline; + } + } + + String _getTitleByType(BuildContext context) { + switch (widget.type) { + case EnumThrowException.error: + return FFLocalizations.of(context).getVariableText(ptText: "Falha :(", enText: "Fail :("); + case EnumThrowException.warning: + return FFLocalizations.of(context).getVariableText(ptText: "Aviso :O", enText: "Warning :O"); + case EnumThrowException.success: + return FFLocalizations.of(context).getVariableText(ptText: "Sucesso ;)", enText: "Success ;)");; + } + } + @override Widget build(BuildContext context) { return Column( @@ -77,85 +113,62 @@ class _ThrowExceptionWidgetState extends State onTap: () async { Navigator.pop(context); }, - child: Container( - height: 400.0, - decoration: BoxDecoration( - color: FlutterFlowTheme.of(context).primaryBackground, - borderRadius: const BorderRadius.only( - bottomLeft: Radius.circular(10.0), - bottomRight: Radius.circular(10.0), - topLeft: Radius.circular(10.0), - topRight: Radius.circular(10.0), - ), - ), - child: Column( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Stack( - children: [ - Align( - alignment: const AlignmentDirectional(0.0, 0.0), - child: Icon( - Icons.circle_outlined, - color: FlutterFlowTheme.of(context).error, - size: 200.0, - ), + child: Column( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Stack( + children: [ + Align( + alignment: const AlignmentDirectional(0.0, 0.0), + child: Icon( + _getIconByType(context), + color: _getColorByType(context), + size: 150.0, ), - Align( - alignment: const AlignmentDirectional(0.0, 0.0), - child: Icon( - Icons.close_outlined, - color: FlutterFlowTheme.of(context).error, - size: 200.0, + ), + ], + ).animateOnPageLoad( + animationsMap['stackOnPageLoadAnimation']!), + Column( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + _getTitleByType(context), + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: + FlutterFlowTheme.of(context).bodyMediumFamily, + fontSize: 20.0, + letterSpacing: 0.0, + fontWeight: FontWeight.bold, + useGoogleFonts: GoogleFonts.asMap().containsKey( + FlutterFlowTheme.of(context) + .bodyMediumFamily), + ), + ), + Padding( + padding: const EdgeInsetsDirectional.fromSTEB(0.0, 10.0, 0.0, 0.0), + child: Text( + valueOrDefault( + widget.msg, + 'Message Not Found', ), - ), - ], - ).animateOnPageLoad( - animationsMap['stackOnPageLoadAnimation']!), - Column( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Text( - FFLocalizations.of(context).getText( - 'e58xxxiq' /* ERRO */, - ), - style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, - fontSize: 20.0, + style: FlutterFlowTheme.of(context) + .bodyMedium + .override( + fontFamily: FlutterFlowTheme.of(context) + .bodyMediumFamily, letterSpacing: 0.0, - fontWeight: FontWeight.bold, useGoogleFonts: GoogleFonts.asMap().containsKey( FlutterFlowTheme.of(context) .bodyMediumFamily), ), ), - Padding( - padding: - const EdgeInsetsDirectional.fromSTEB(0.0, 10.0, 0.0, 0.0), - child: Text( - valueOrDefault( - widget.msg, - 'Message Not Found', - ), - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .bodyMediumFamily, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context) - .bodyMediumFamily), - ), - ), - ), - ].addToStart(const SizedBox(height: 50.0)), - ), - ], - ), + ), + ].addToStart(const SizedBox(height: 20.0)), + ), + ], ), ), ), diff --git a/lib/components/templates_components/forgot_password_template_component/forgot_password_template_component_model.dart b/lib/components/templates_components/forgot_password_template_component/forgot_password_template_component_model.dart index 2cb2b7f3..13c3c56a 100644 --- a/lib/components/templates_components/forgot_password_template_component/forgot_password_template_component_model.dart +++ b/lib/components/templates_components/forgot_password_template_component/forgot_password_template_component_model.dart @@ -1,3 +1,5 @@ +import 'package:hub/shared/utils/validator_util.dart'; + import '/backend/api_requests/api_calls.dart'; import '/flutter_flow/flutter_flow_util.dart'; import 'forgot_password_template_component_widget.dart' @@ -21,7 +23,7 @@ class ForgotPasswordTemplateComponentModel ); } - if (!RegExp(kTextValidatorEmailRegex).hasMatch(val)) { + if (!ValidatorUtil.isValidEmail(val)) { return FFLocalizations.of(context).getText( 'jh5r2b1w' /* E-mail Inválido */, ); diff --git a/lib/components/templates_components/forgot_password_template_component/forgot_password_template_component_widget.dart b/lib/components/templates_components/forgot_password_template_component/forgot_password_template_component_widget.dart index 22e1d193..1c7a7c0a 100644 --- a/lib/components/templates_components/forgot_password_template_component/forgot_password_template_component_widget.dart +++ b/lib/components/templates_components/forgot_password_template_component/forgot_password_template_component_widget.dart @@ -1,4 +1,9 @@ +import 'dart:developer'; + import 'package:hub/flutter_flow/nav/nav.dart'; +import 'package:hub/shared/utils/dialog_util.dart'; +import 'package:hub/shared/utils/log_util.dart'; +import 'package:hub/shared/utils/validator_util.dart'; import '/backend/api_requests/api_calls.dart'; import '/components/molecular_components/throw_exception/throw_exception_widget.dart'; @@ -187,28 +192,28 @@ class _ForgotPasswordTemplateComponentWidgetState enabledBorder: OutlineInputBorder( borderSide: const BorderSide( color: Colors.black, - width: 0.25, + width: 2.00, ), borderRadius: BorderRadius.circular(12.0), ), focusedBorder: OutlineInputBorder( borderSide: BorderSide( color: FlutterFlowTheme.of(context).primary, - width: 0.25, + width: 2.00, ), borderRadius: BorderRadius.circular(12.0), ), errorBorder: OutlineInputBorder( borderSide: BorderSide( color: FlutterFlowTheme.of(context).error, - width: 0.25, + width: 2.00, ), borderRadius: BorderRadius.circular(12.0), ), focusedErrorBorder: OutlineInputBorder( borderSide: BorderSide( color: FlutterFlowTheme.of(context).error, - width: 0.25, + width: 2.00, ), borderRadius: BorderRadius.circular(12.0), ), @@ -216,7 +221,7 @@ class _ForgotPasswordTemplateComponentWidgetState 24.0, 24.0, 20.0, 24.0), suffixIcon: Icon( Icons.email, - color: FlutterFlowTheme.of(context).accent1, + color: FlutterFlowTheme.of(context).primary, size: 22.0, ), ), @@ -243,38 +248,31 @@ class _ForgotPasswordTemplateComponentWidgetState child: Padding( padding: const EdgeInsetsDirectional.fromSTEB(0.0, 24.0, 0.0, 0.0), child: FFButtonWidget( - onPressed: (_model.emailAddressTextController.text == '') + onPressed: (_model.emailAddressTextController.text == '' || !ValidatorUtil.isValidEmail(_model.emailAddressTextController.text)) ? null : () async { - _model.req = await PhpGroup.forgotPasswordCall.call( - email: _model.emailAddressTextController.text, - ); - if (PhpGroup.forgotPasswordCall.error( - (_model.req?.jsonBody ?? ''), - ) == - false) { - Navigator.pop(context); - } else { - await showModalBottomSheet( - isScrollControlled: true, - backgroundColor: Colors.transparent, - enableDrag: false, - context: context, - builder: (context) { - return Padding( - padding: MediaQuery.viewInsetsOf(context), - child: ThrowExceptionWidget( - msg: PhpGroup.forgotPasswordCall.msg( - (_model.req?.jsonBody ?? ''), - )!, - ), - ); - }, - ).then((value) => safeSetState(() {})); + try { + _model.req = await PhpGroup.forgotPasswordCall.call( + email: _model.emailAddressTextController.text, + ); + + if (PhpGroup.forgotPasswordCall.error((_model.req?.jsonBody ?? '')) == false) { + await DialogUtil.success(context, FFLocalizations.of(context).getVariableText( + enText: "Send E-mail Successful!", + ptText: "E-mail Enviado com Sucesso!" + )); + Navigator.pop(context); + } else { + await DialogUtil.error(context, PhpGroup.forgotPasswordCall.msg((_model.req?.jsonBody ?? ''))!); + } + + setState(() {}); + + } catch (error, stack) { + LogUtil.requestAPIFailed("iforgot.php", _model.emailAddressTextController.text, "Recuperar Senha", error, stack); + await DialogUtil.errorDefault(context); } - - setState(() {}); }, text: FFLocalizations.of(context).getText( '74rnd5bu' /* Enviar */, @@ -285,7 +283,7 @@ class _ForgotPasswordTemplateComponentWidgetState padding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 0.0), iconPadding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 0.0), - color: const Color(0xFF1AAB5F), + color: FlutterFlowTheme.of(context).primary, textStyle: FlutterFlowTheme.of(context).titleSmall.override( fontFamily: 'Plus Jakarta Sans', color: Colors.white, @@ -300,8 +298,14 @@ class _ForgotPasswordTemplateComponentWidgetState color: Colors.transparent, width: 1.0, ), + disabledColor: + FlutterFlowTheme.of( + context) + .customColor5, + disabledTextColor: + Colors.white, ), - showLoadingIndicator: false, + showLoadingIndicator: true, ), ), ), diff --git a/lib/components/templates_components/sign_in_template_component/sign_in_template_component_widget.dart b/lib/components/templates_components/sign_in_template_component/sign_in_template_component_widget.dart index 2d946b1a..572d14f9 100644 --- a/lib/components/templates_components/sign_in_template_component/sign_in_template_component_widget.dart +++ b/lib/components/templates_components/sign_in_template_component/sign_in_template_component_widget.dart @@ -1,6 +1,8 @@ import 'package:hub/components/atomic_components/shared_components_atoms/atom_image_svg_theme.dart'; import 'package:hub/shared/components/atoms/atom_terms_of_use.dart'; -import 'package:hub/shared/utils/ValidatorUtil.dart'; +import 'package:hub/shared/utils/dialog_util.dart'; +import 'package:hub/shared/utils/log_util.dart'; +import 'package:hub/shared/utils/validator_util.dart'; import '/components/templates_components/forgot_password_template_component/forgot_password_template_component_widget.dart'; import '/flutter_flow/flutter_flow_animations.dart'; @@ -695,34 +697,25 @@ class _SignInTemplateComponentWidgetState .fromSTEB(0.0, 0.0, 0.0, 16.0), child: FFButtonWidget( - onPressed: (((_model.emailAddressTextController - .text == - '') || - ((_model.emailAddressFocusNode - ?.hasFocus ?? - false) != - null)) && - ((_model.emailAddressTextController - .text == - '') || - ((_model.passwordTextController.text == - '') || - ((_model.passwordFocusNode?.hasFocus ?? - false) != - null)))) + onPressed: _isFormInvalid() ? null : () async { - await action_blocks - .singInLoginAction( - context, - emailAdress: _model - .emailAddressTextController - .text, - password: _model - .passwordTextController - .text, - ); - setState(() {}); + try { + await action_blocks + .singInLoginAction( + context, + emailAdress: _model + .emailAddressTextController + .text, + password: _model + .passwordTextController + .text, + ); + setState(() {}); + } catch (e, s) { + await DialogUtil.errorDefault(context); + LogUtil.requestAPIFailed('login.php', _model.emailAddressTextController.text, "Login", e, s); + } }, text: FFLocalizations.of( context) @@ -784,8 +777,7 @@ class _SignInTemplateComponentWidgetState disabledColor: const Color(0xE81AAB5F), ), - showLoadingIndicator: - false, + showLoadingIndicator: true, ), ), ), @@ -880,18 +872,13 @@ class _SignInTemplateComponentWidgetState hoverColor: Colors.transparent, highlightColor: Colors.transparent, onTap: () async { - await showModalBottomSheet( isScrollControlled: true, - backgroundColor: - Colors.transparent, - enableDrag: false, + backgroundColor: Colors.transparent, context: context, builder: (context) { return Padding( - padding: - MediaQuery.viewInsetsOf( - context), + padding: MediaQuery.viewInsetsOf(context), child: const ForgotPasswordTemplateComponentWidget(), ); }, @@ -941,29 +928,23 @@ class _SignInTemplateComponentWidgetState ), mouseCursor: SystemMouseCursors.click, - recognizer: - TapGestureRecognizer() - ..onTap = () async { - await showModalBottomSheet( - isScrollControlled: - true, - backgroundColor: - Colors - .transparent, - context: context, - builder: (context) { - return Padding( - padding: MediaQuery - .viewInsetsOf( - context), - child: - const ForgotPasswordTemplateComponentWidget(), - ); - }, - ).then((value) => - safeSetState( - () {})); - }, + // recognizer: TapGestureRecognizer() + // ..onTap = () async { + // await showModalBottomSheet( + // isScrollControlled: true, + // backgroundColor: Colors.transparent, + // context: context, + // useRootNavigator: true, + // builder: (context) { + // return Padding( + // padding: MediaQuery.viewInsetsOf(context), + // child: const ForgotPasswordTemplateComponentWidget(), + // ); + // }, + // ).then((value) => + // safeSetState( + // () {})); + // }, ) ], style: diff --git a/lib/flutter_flow/internationalization.dart b/lib/flutter_flow/internationalization.dart index d00d8320..1a825db4 100644 --- a/lib/flutter_flow/internationalization.dart +++ b/lib/flutter_flow/internationalization.dart @@ -569,8 +569,8 @@ final kTranslationsMap = >>[ // throwException { 'e58xxxiq': { - 'pt': 'ERRO', - 'en': 'ERROR', + 'pt': 'Falha :(', + 'en': 'Fail :(', }, }, // regisiterVistorTemplateComponent @@ -1041,11 +1041,11 @@ final kTranslationsMap = >>[ }, '3hqg8buh': { 'pt': 'E-mail é Obrigatório', - 'en': '', + 'en': 'E-mail is Required', }, 'jh5r2b1w': { 'pt': 'E-mail Inválido', - 'en': '', + 'en': 'Invalid E-mail', }, '1p76vmkn': { 'pt': 'Please choose an option from the dropdown', diff --git a/lib/main.dart b/lib/main.dart index 3348f78f..2590c721 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,6 @@ import 'package:firebase_core/firebase_core.dart'; +import 'package:firebase_crashlytics/firebase_crashlytics.dart'; import 'package:hub/app_state.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/flutter_flow/internationalization.dart'; @@ -29,6 +30,8 @@ void main() async { Future initializeApp() async { await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); + FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterError; + await FlutterFlowTheme.initialize(); await FFLocalizations.initialize(); final appState = FFAppState(); @@ -57,6 +60,9 @@ class _MyAppState extends State { @override void initState() { super.initState(); + + FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(true); + _appStateNotifier = AppStateNotifier.instance; _router = createRouter(_appStateNotifier); Future.delayed(const Duration(milliseconds: 1000), diff --git a/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart b/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart index 8b684610..e1fdf3b6 100644 --- a/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart +++ b/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart @@ -1773,7 +1773,7 @@ Widget scheduleVisit( : FocusScope.of(context).unfocus(), child: Padding( padding: MediaQuery.viewInsetsOf(context), - child: const ThrowExceptionWidget( + child: ThrowExceptionWidget( msg: 'Campos obrigatórios imcompletos.', ), ), diff --git a/lib/shared/enums/enum_throw_exception.dart b/lib/shared/enums/enum_throw_exception.dart new file mode 100644 index 00000000..f1bf2a08 --- /dev/null +++ b/lib/shared/enums/enum_throw_exception.dart @@ -0,0 +1,5 @@ +enum EnumThrowException { + success, + error, + warning +} \ No newline at end of file diff --git a/lib/shared/utils/dialog_util.dart b/lib/shared/utils/dialog_util.dart new file mode 100644 index 00000000..6db1ed89 --- /dev/null +++ b/lib/shared/utils/dialog_util.dart @@ -0,0 +1,59 @@ + +import 'package:flutter/material.dart'; +import 'package:hub/components/molecular_components/throw_exception/throw_exception_widget.dart'; +import 'package:hub/flutter_flow/flutter_flow_util.dart'; +import 'package:hub/shared/enums/enum_throw_exception.dart'; + +class DialogUtil { + static const double _height = 350; + + static Future errorDefault(BuildContext context) { + return error(context, FFLocalizations.of(context).getVariableText( + ptText: "Falha ao efetuar operação, Tente Novamente mais tarde.", + enText: "Failed to perform operation, please try again later." + )); + } + + static Future error(BuildContext context, String message) async { + return await showDialog( + context: context, + builder: (context) { + return Dialog( + child: SizedBox( + height: _height, + child: Padding(padding: MediaQuery.viewInsetsOf(context), child: ThrowExceptionWidget(msg: message, type: EnumThrowException.error)) + ) + ); + } + ); + } + + static Future warning(BuildContext context, String message) async { + return await showDialog( + context: context, + builder: (context) { + return Dialog( + child: SizedBox( + height: _height, + child: Padding(padding: MediaQuery.viewInsetsOf(context), child: ThrowExceptionWidget(msg: message, type: EnumThrowException.warning)) + ) + ); + } + ); + } + + static Future success(BuildContext context, String message) async { + return await showDialog( + context: context, + builder: (context) { + return Dialog( + child: SizedBox( + height: _height, + child: Padding(padding: MediaQuery.viewInsetsOf(context), child: ThrowExceptionWidget(msg: message, type: EnumThrowException.success)) + ) + ); + } + ); + } + +} \ No newline at end of file diff --git a/lib/shared/utils/log_util.dart b/lib/shared/utils/log_util.dart new file mode 100644 index 00000000..64a30e12 --- /dev/null +++ b/lib/shared/utils/log_util.dart @@ -0,0 +1,15 @@ +import 'dart:developer'; + +import 'package:firebase_crashlytics/firebase_crashlytics.dart'; +import 'package:hub/backend/api_requests/api_calls.dart'; + +class LogUtil { + + static void requestAPIFailed(String url, String body, String reason, dynamic error, StackTrace stack) async { + FirebaseCrashlytics.instance.setCustomKey('URL', "${PhpGroup.getBaseUrl()}/$url"); + FirebaseCrashlytics.instance.setCustomKey('Body', body); + + await FirebaseCrashlytics.instance.recordError(error, stack, reason: reason); + } + +} \ No newline at end of file diff --git a/lib/shared/utils/ValidatorUtil.dart b/lib/shared/utils/validator_util.dart similarity index 100% rename from lib/shared/utils/ValidatorUtil.dart rename to lib/shared/utils/validator_util.dart diff --git a/pubspec.lock b/pubspec.lock index a64d3263..db941ddb 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -345,6 +345,22 @@ packages: url: "https://pub.dev" source: hosted version: "2.17.2" + firebase_crashlytics: + dependency: "direct main" + description: + name: firebase_crashlytics + sha256: ad7510d9bcf1f40fc895944942f553a4c5603acb4715c0d6386dd587f82f6ae5 + url: "https://pub.dev" + source: hosted + version: "4.0.1" + firebase_crashlytics_platform_interface: + dependency: transitive + description: + name: firebase_crashlytics_platform_interface + sha256: "318589f1da3bb858872002fa20170234566f0fb080669a8256c85a81513a802a" + url: "https://pub.dev" + source: hosted + version: "3.6.37" firebase_messaging: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 276cf9cc..8efce314 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -107,6 +107,7 @@ dependencies: flutter_riverpod: ^2.5.1 qr_flutter: ^4.1.0 permission_handler: ^11.3.1 + firebase_crashlytics: ^4.0.1 dependency_overrides: http: 1.2.1