231 lines
8.8 KiB
Dart
231 lines
8.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:hub/actions/actions.dart';
|
|
import 'package:hub/components/templates_components/details_component/details_component_widget.dart';
|
|
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
|
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
|
import 'package:hub/flutter_flow/flutter_flow_widgets.dart';
|
|
import 'package:hub/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart';
|
|
import 'package:hub/shared/utils/validator_util.dart';
|
|
import 'package:share_plus/share_plus.dart';
|
|
|
|
Widget buildDetails(
|
|
dynamic visitaWrapItem,
|
|
BuildContext context,
|
|
Future<dynamic> Function(BuildContext, int, int, String, String)?
|
|
changeStatusAction) {
|
|
return DetailsComponentWidget(
|
|
buttons: [
|
|
if (getStatus(visitaWrapItem['VAW_STATUS']) ==
|
|
status.active) // REJECT ACTION
|
|
FFButtonWidget(
|
|
text: FFLocalizations.of(context).getVariableText(
|
|
ptText: 'Cancelar',
|
|
enText: 'Cancel',
|
|
),
|
|
icon: const Icon(Icons.close),
|
|
onPressed: () async {
|
|
showAlertDialog(
|
|
context,
|
|
FFLocalizations.of(context).getVariableText(
|
|
ptText: 'Bloquear Visita',
|
|
enText: 'Block Visit',
|
|
),
|
|
FFLocalizations.of(context).getVariableText(
|
|
ptText: 'Você tem certeza que deseja bloquear essa visita?',
|
|
enText: 'Are you sure you want to block this visit?',
|
|
), () async {
|
|
await changeStatusAction
|
|
?.call(
|
|
context,
|
|
int.parse(visitaWrapItem['VAW_DESTINO']),
|
|
int.parse(visitaWrapItem['VAW_ID']),
|
|
visitaWrapItem['VAW_CHAVE'] ?? '',
|
|
visitaWrapItem['VTE_DOCUMENTO'] ?? '',
|
|
)
|
|
.then((value) {
|
|
Navigator.pop(context, value);
|
|
if (value == false) {
|
|
showSnackbar(
|
|
context,
|
|
FFLocalizations.of(context).getVariableText(
|
|
enText: 'Error blocking visit',
|
|
ptText: 'Erro ao bloquear visita',
|
|
),
|
|
true,
|
|
);
|
|
} else if (value == true) {
|
|
showSnackbar(
|
|
context,
|
|
FFLocalizations.of(context).getVariableText(
|
|
enText: 'Success canceling visit',
|
|
ptText: 'Succeso ao cancelar visita',
|
|
),
|
|
false,
|
|
);
|
|
}
|
|
}).catchError((err, stack) {
|
|
Navigator.pop(context);
|
|
showSnackbar(
|
|
context,
|
|
FFLocalizations.of(context).getVariableText(
|
|
enText: 'Error blocking visit',
|
|
ptText: 'Erro ao bloquear visita',
|
|
),
|
|
true,
|
|
);
|
|
});
|
|
});
|
|
},
|
|
options: FFButtonOptions(
|
|
width: 130,
|
|
height: 40,
|
|
color: FlutterFlowTheme.of(context).primaryBackground,
|
|
elevation: 0,
|
|
textStyle: TextStyle(
|
|
color: FlutterFlowTheme.of(context).primaryText,
|
|
),
|
|
borderSide: BorderSide(
|
|
color: FlutterFlowTheme.of(context).primaryBackground,
|
|
width: 1,
|
|
),
|
|
// borderRadius: 12,
|
|
),
|
|
),
|
|
if (getStatus(visitaWrapItem['VAW_STATUS']) !=
|
|
status.active) // RECALL ACTION
|
|
FFButtonWidget(
|
|
text: FFLocalizations.of(context).getVariableText(
|
|
ptText: 'Reagendar',
|
|
enText: 'Reschedule',
|
|
),
|
|
icon: const Icon(Icons.refresh),
|
|
onPressed: () async {
|
|
Navigator.pop(context);
|
|
Navigator.pop(context);
|
|
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => ScheduleCompleteVisitPageWidget(
|
|
dropdownValue1: visitaWrapItem['MOT_DESCRICAO'],
|
|
dropdownValue2: visitaWrapItem['NAC_DESCRICAO'],
|
|
visitorJsonList: [visitaWrapItem],
|
|
visitorStrList: visitaWrapItem['VTE_DOCUMENTO'],
|
|
)),
|
|
);
|
|
},
|
|
options: FFButtonOptions(
|
|
width: 130,
|
|
height: 40,
|
|
color: FlutterFlowTheme.of(context).primaryBackground,
|
|
elevation: 0,
|
|
textStyle: TextStyle(
|
|
color: FlutterFlowTheme.of(context).primaryText,
|
|
),
|
|
borderSide: BorderSide(
|
|
color: FlutterFlowTheme.of(context).primaryBackground,
|
|
width: 1,
|
|
),
|
|
// borderRadius: 12,
|
|
),
|
|
),
|
|
if (getStatus(visitaWrapItem['VAW_STATUS']) ==
|
|
status.active) // SHARE ACTION
|
|
FFButtonWidget(
|
|
text: FFLocalizations.of(context).getVariableText(
|
|
ptText: 'Compartilhar',
|
|
enText: 'Share',
|
|
),
|
|
icon: const Icon(Icons.share),
|
|
onPressed: () async {
|
|
Share.share('''
|
|
Olá, \*${visitaWrapItem['VTE_NOME']}\*! Você foi convidado para \*${AppState().local}\*.
|
|
|
|
\*Validade do Convite\*:
|
|
- Início: ${visitaWrapItem['VAW_DTINICIO']}
|
|
- Fim: ${visitaWrapItem['VAW_DTFIM']}
|
|
|
|
URL do Convite: https://visita.freaccess.com.br/${visitaWrapItem['VAW_ID']}/${AppState().cliUUID}/${visitaWrapItem['VAW_CHAVE']}
|
|
''');
|
|
},
|
|
options: FFButtonOptions(
|
|
width: 130,
|
|
height: 40,
|
|
color: FlutterFlowTheme.of(context).primaryBackground,
|
|
elevation: 0,
|
|
textStyle: TextStyle(
|
|
color: FlutterFlowTheme.of(context).primaryText,
|
|
),
|
|
borderSide: BorderSide(
|
|
color: FlutterFlowTheme.of(context).primaryBackground,
|
|
width: 1,
|
|
),
|
|
// borderRadius: 12,
|
|
),
|
|
),
|
|
],
|
|
labelsHashMap: Map<String, String>.from({
|
|
'${FFLocalizations.of(context).getVariableText(ptText: "Nome", enText: "Name")}:':
|
|
visitaWrapItem['VTE_NOME'] ?? '',
|
|
'${FFLocalizations.of(context).getVariableText(ptText: "Inicio", enText: "Start")}:':
|
|
visitaWrapItem['VAW_DTINICIO'] != '' &&
|
|
visitaWrapItem['VAW_DTINICIO'] != null
|
|
? ValidatorUtil.toLocalDateTime(
|
|
'yyyy-MM-dd HH:mm:ss', visitaWrapItem['VAW_DTINICIO'])
|
|
: '',
|
|
'${FFLocalizations.of(context).getVariableText(ptText: "Fim", enText: "End")}:':
|
|
visitaWrapItem['VAW_DTFIM'] != '' &&
|
|
visitaWrapItem['VAW_DTFIM'] != null
|
|
? ValidatorUtil.toLocalDateTime(
|
|
'yyyy-MM-dd HH:mm:ss', visitaWrapItem['VAW_DTFIM'])
|
|
: '',
|
|
}),
|
|
imagePath:
|
|
'https://freaccess.com.br/freaccess/getImage.php?cliID=${AppState().cliUUID}&atividade=getFoto&Documento=${visitaWrapItem['VTE_DOCUMENTO'] ?? ''}&tipo=E',
|
|
statusHashMap: [
|
|
if (getStatus(visitaWrapItem['VAW_STATUS']) == status.active)
|
|
Map<String, Color>.from({
|
|
FFLocalizations.of(context).getVariableText(
|
|
ptText: 'Ativo',
|
|
enText: 'Active',
|
|
): FlutterFlowTheme.of(context).warning,
|
|
}),
|
|
if (getStatus(visitaWrapItem['VAW_STATUS']) == status.unknown)
|
|
Map<String, Color>.from({
|
|
FFLocalizations.of(context).getVariableText(
|
|
ptText: 'Pendente',
|
|
enText: 'Pending',
|
|
): FlutterFlowTheme.of(context).alternate,
|
|
}),
|
|
if (getStatus(visitaWrapItem['VAW_STATUS']) == status.canceled)
|
|
Map<String, Color>.from({
|
|
FFLocalizations.of(context).getVariableText(
|
|
ptText: 'Cancelado',
|
|
enText: 'Canceled',
|
|
): FlutterFlowTheme.of(context).error,
|
|
}),
|
|
if (getStatus(visitaWrapItem['VAW_STATUS']) == status.finished)
|
|
Map<String, Color>.from({
|
|
FFLocalizations.of(context).getVariableText(
|
|
ptText: 'Finalizado',
|
|
enText: 'Finished',
|
|
): FlutterFlowTheme.of(context).success,
|
|
}),
|
|
if (getStatus(visitaWrapItem['VAW_STATUS']) == status.blocked)
|
|
Map<String, Color>.from({
|
|
FFLocalizations.of(context).getVariableText(
|
|
ptText: 'Bloqueado',
|
|
enText: 'Blocked',
|
|
): FlutterFlowTheme.of(context).error,
|
|
}),
|
|
if (getStatus(visitaWrapItem['VAW_STATUS']) == status.inactive)
|
|
Map<String, Color>.from({
|
|
FFLocalizations.of(context).getVariableText(
|
|
ptText: 'Inativo',
|
|
enText: 'Inactive',
|
|
): FlutterFlowTheme.of(context).warning,
|
|
}),
|
|
],
|
|
);
|
|
}
|