325 lines
7.6 KiB
Dart
325 lines
7.6 KiB
Dart
import '/backend/api_requests/api_calls.dart';
|
|
import '/flutter_flow/flutter_flow_theme.dart';
|
|
import '/flutter_flow/flutter_flow_util.dart';
|
|
import '/modals/throw_exception/throw_exception_widget.dart';
|
|
import '/actions/actions.dart' as action_blocks;
|
|
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<dynamic>? 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,
|
|
isList: true,
|
|
),
|
|
}.withoutNulls,
|
|
extra: <String, dynamic>{
|
|
kTransitionInfoKey: const TransitionInfo(
|
|
hasTransition: true,
|
|
transitionType: PageTransitionType.fade,
|
|
),
|
|
},
|
|
);
|
|
}
|
|
|
|
Future<Color> 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 singInLoginAction(
|
|
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,
|
|
),
|
|
);
|
|
|
|
if (PhpGroup.loginCall.error(
|
|
(loginCall.jsonBody ?? ''),
|
|
) ==
|
|
false) {
|
|
FFAppState().userUUID = PhpGroup.loginCall.userUUID(
|
|
(loginCall.jsonBody ?? ''),
|
|
)!;
|
|
FFAppState().token = PhpGroup.loginCall.userDeviceId(
|
|
(loginCall.jsonBody ?? ''),
|
|
)!;
|
|
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().name = PhpGroup.loginCall.userName(
|
|
(loginCall.jsonBody ?? ''),
|
|
)!;
|
|
FFAppState().isLogged = true;
|
|
await action_blocks.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().deletePasswd();
|
|
FFAppState().passwd = '';
|
|
|
|
FFAppState().update(() {});
|
|
}
|
|
|
|
return;
|
|
} else {
|
|
return;
|
|
}
|
|
}
|
|
|
|
Future<bool> signUpRegisterAction(
|
|
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) {
|
|
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';
|
|
}
|
|
}
|
|
}
|
|
|
|
Future toggleSignInPage(BuildContext context) async {
|
|
context.pushNamed(
|
|
'signInPage',
|
|
extra: <String, dynamic>{
|
|
kTransitionInfoKey: const TransitionInfo(
|
|
hasTransition: true,
|
|
transitionType: PageTransitionType.fade,
|
|
),
|
|
},
|
|
);
|
|
}
|
|
|
|
Future toggleSignUpPage(BuildContext context) async {
|
|
context.pushNamed(
|
|
'signUpPage',
|
|
extra: <String, dynamic>{
|
|
kTransitionInfoKey: const TransitionInfo(
|
|
hasTransition: true,
|
|
transitionType: PageTransitionType.fade,
|
|
),
|
|
},
|
|
);
|
|
}
|
|
|
|
Future toggleHomePage(BuildContext context) async {
|
|
context.goNamed(
|
|
'homePage',
|
|
extra: <String, dynamic>{
|
|
kTransitionInfoKey: const TransitionInfo(
|
|
hasTransition: true,
|
|
transitionType: PageTransitionType.fade,
|
|
),
|
|
},
|
|
);
|
|
}
|