import '/application_components/molecular_components/throw_exception/throw_exception_widget.dart'; import '/backend/api_requests/api_calls.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import '/custom_code/actions/index.dart' as actions; import '/flutter_flow/random_data_util.dart' as random_data; import 'package:flutter/material.dart'; Future repeatVisitScheduleAction( BuildContext context, { List? visitorJsonList, String? visitorStrList, String? visitStartDateStr, String? visitEndDateStr, String? visitReasonStr, String? visitLevelStr, bool? visitTempBol, String? visitObsStr, }) async { context.pushNamed( 'scheduleCompleteVisitPage', queryParameters: { 'visitStartDateStr': serializeParam( visitStartDateStr, ParamType.String, ), 'visitEndDateStr': serializeParam( visitEndDateStr, ParamType.String, ), 'visitReasonStr': serializeParam( visitReasonStr, ParamType.String, ), 'visitLevelStr': serializeParam( visitLevelStr, ParamType.String, ), 'visitTempBol': serializeParam( visitTempBol, ParamType.bool, ), 'visitObsStr': serializeParam( visitObsStr, ParamType.String, ), 'visitorStrList': serializeParam( visitorStrList, ParamType.String, ), 'visitorJsonList': serializeParam( visitorJsonList, ParamType.JSON, true, ), }.withoutNulls, ); } Future manageStatusColorAction( BuildContext context, { required String? visitStatusStr, }) async { if (visitStatusStr == 'A') { return FlutterFlowTheme.of(context).success; } else if ((visitStatusStr == 'C') || (visitStatusStr == 'F') || (visitStatusStr == 'B') || (visitStatusStr == 'I')) { return FlutterFlowTheme.of(context).error; } return FlutterFlowTheme.of(context).warning; } Future singInActionApp( BuildContext context, { 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 actions.getDevUUID(); FFAppState().devUUID = devUUID!; loginCall = await PhpGroup.loginCall.call( email: FFAppState().email, password: FFAppState().passwd, uuid: FFAppState().devUUID, type: FFAppState().device, description: random_data.randomString( 10, 10, true, false, false, ), ); FFAppState().userUUID = PhpGroup.loginCall.userUUID( (loginCall.jsonBody ?? ''), )!; if (PhpGroup.loginCall.error( (loginCall.jsonBody ?? ''), ) == false) { FFAppState().isLogged = true; context.goNamed( 'homePage', extra: { kTransitionInfoKey: const TransitionInfo( hasTransition: true, transitionType: PageTransitionType.fade, ), }, ); } else { await showModalBottomSheet( isScrollControlled: true, backgroundColor: Colors.transparent, enableDrag: false, context: context, builder: (context) { return Padding( padding: MediaQuery.viewInsetsOf(context), child: ThrowExceptionWidget( msg: PhpGroup.loginCall.msg( (loginCall?.jsonBody ?? ''), )!, ), ); }, ); FFAppState().email = ''; FFAppState().passwd = ''; FFAppState().update(() {}); } } else { return; } } Future signUpActionApp( BuildContext context, { required String? name, String? passwd, required String? email, String? device, }) async { ApiCallResponse? registerCall; if ((email != null && email != '') && (passwd != null && passwd != '') && (name != null && name != '')) { registerCall = await PhpGroup.registerCall.call( name: name, password: passwd, email: email, token: random_data.randomString( 36, 36, false, false, true, ), uuid: random_data.randomString( 36, 36, false, false, true, ), tipo: device, descricao: random_data.randomString( 36, 36, true, false, false, ), ); if (PhpGroup.registerCall.error( (registerCall.jsonBody ?? ''), ) == false) { return true; } await showDialog( context: context, builder: (alertDialogContext) { return AlertDialog( title: const Text('ERROR2'), content: const Text('ERROR2'), actions: [ TextButton( onPressed: () => Navigator.pop(alertDialogContext), child: const Text('ERROR2 '), ), ], ); }, ); return false; } else { await showDialog( context: context, builder: (alertDialogContext) { return AlertDialog( title: const Text('ERROR1'), content: const Text('ERROR1'), actions: [ TextButton( onPressed: () => Navigator.pop(alertDialogContext), child: const Text('ERROR1 '), ), ], ); }, ); return false; } } Future forgotPasswdAction( BuildContext context, { required String? email, }) async { ApiCallResponse? forgotPasswd; forgotPasswd = await PhpGroup.forgotPasswordCall.call( email: email, ); if (PhpGroup.forgotPasswordCall.error( (forgotPasswd.jsonBody ?? ''), ) == false) { context.pushNamed( 'LoginPage', queryParameters: { 'device': serializeParam( FFAppState().device, ParamType.String, ), }.withoutNulls, ); } else { return; } } Future cachingLoginActionApp(BuildContext context) async { if (FFAppState().isLogged == true) { context.pushNamed('homePage'); } else { if (isAndroid == true) { FFAppState().device = 'Android'; } else if (isiOS == true) { FFAppState().device = 'iOS'; } else { FFAppState().device = 'Web'; } } }