save for fd-374
This commit is contained in:
parent
f493c0744e
commit
8d829ca997
|
@ -98,7 +98,7 @@ class _CardItemTemplateComponentWidgetState
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _generateImage() {
|
Widget _generateImage() {
|
||||||
// CachedNetworkImage.evictFromCache(widget.imagePath ?? '');
|
CachedNetworkImage.evictFromCache(widget.imagePath ?? '');
|
||||||
return ClipRRect(
|
return ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius: BorderRadius.circular(20),
|
||||||
child: CachedNetworkImage(
|
child: CachedNetworkImage(
|
||||||
|
|
|
@ -1,415 +0,0 @@
|
||||||
import 'dart:convert';
|
|
||||||
import 'dart:developer';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:http/http.dart';
|
|
||||||
import 'package:hub/backend/api_requests/api_calls.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/flutter_flow/form_field_controller.dart';
|
|
||||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
|
||||||
import 'package:hub/pages/pets_page/pets_page_model.dart';
|
|
||||||
import 'package:hub/shared/mixins/status_mixin.dart';
|
|
||||||
import 'package:hub/shared/utils/validator_util.dart';
|
|
||||||
import 'package:share_plus/share_plus.dart';
|
|
||||||
|
|
||||||
Widget buildVisitDetails({
|
|
||||||
required dynamic item,
|
|
||||||
required BuildContext context,
|
|
||||||
required Future<dynamic> Function(BuildContext, int, int, String, String)
|
|
||||||
changeStatusAction,
|
|
||||||
required String devUUID,
|
|
||||||
required String userUUID,
|
|
||||||
required String cliUUID,
|
|
||||||
required String cliName,
|
|
||||||
}) {
|
|
||||||
return DetailsComponentWidget(
|
|
||||||
buttons: [
|
|
||||||
if (Status.getStatus(item['VAW_STATUS']) ==
|
|
||||||
StatusEnum.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: 'Cancelar Visita',
|
|
||||||
enText: 'Cancel 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(item['VAW_DESTINO']),
|
|
||||||
int.parse(item['VAW_ID']),
|
|
||||||
item['VAW_CHAVE'] ?? '',
|
|
||||||
item['VTE_DOCUMENTO'] ?? '',
|
|
||||||
)
|
|
||||||
.then((value) {
|
|
||||||
// Navigator.pop(context, value);
|
|
||||||
context.pop(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) {
|
|
||||||
context.pop();
|
|
||||||
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 (Status.getStatus(item['VAW_STATUS']) !=
|
|
||||||
StatusEnum.active) // RECALL ACTION
|
|
||||||
FFButtonWidget(
|
|
||||||
text: FFLocalizations.of(context).getVariableText(
|
|
||||||
ptText: 'Reagendar',
|
|
||||||
enText: 'Reschedule',
|
|
||||||
),
|
|
||||||
icon: const Icon(Icons.refresh),
|
|
||||||
onPressed: () async {
|
|
||||||
context.pop();
|
|
||||||
context.pop();
|
|
||||||
|
|
||||||
context.pushNamed('scheduleCompleteVisitPage', extra: {
|
|
||||||
'dropdownValue1': item['MOT_DESCRICAO'],
|
|
||||||
'dropdownValue2': item['NAC_DESCRICAO'],
|
|
||||||
'visitorJsonList': [item],
|
|
||||||
'visitorStrList': item['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 (Status.getStatus(item['VAW_STATUS']) ==
|
|
||||||
StatusEnum.active) // SHARE ACTION
|
|
||||||
FFButtonWidget(
|
|
||||||
text: FFLocalizations.of(context).getVariableText(
|
|
||||||
ptText: 'Compartilhar',
|
|
||||||
enText: 'Share',
|
|
||||||
),
|
|
||||||
icon: const Icon(Icons.share),
|
|
||||||
onPressed: () async {
|
|
||||||
Share.share('''
|
|
||||||
Olá, \*${item['VTE_NOME']}\*! Você foi convidado para \*${cliName}\*.
|
|
||||||
|
|
||||||
\*Validade do Convite\*:
|
|
||||||
- Início: ${item['VAW_DTINICIO']}
|
|
||||||
- Fim: ${item['VAW_DTFIM']}
|
|
||||||
|
|
||||||
URL do Convite: https://visita.freaccess.com.br/${item['VAW_ID']}/${cliUUID}/${item['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")}:':
|
|
||||||
item['VTE_NOME'] ?? '',
|
|
||||||
'${FFLocalizations.of(context).getVariableText(ptText: "Inicio", enText: "Start")}:':
|
|
||||||
item['VAW_DTINICIO'] != '' && item['VAW_DTINICIO'] != null
|
|
||||||
? ValidatorUtil.toLocalDateTime(
|
|
||||||
'yyyy-MM-dd HH:mm:ss', item['VAW_DTINICIO'])
|
|
||||||
: '',
|
|
||||||
'${FFLocalizations.of(context).getVariableText(ptText: "Fim", enText: "End")}:':
|
|
||||||
item['VAW_DTFIM'] != '' && item['VAW_DTFIM'] != null
|
|
||||||
? ValidatorUtil.toLocalDateTime(
|
|
||||||
'yyyy-MM-dd HH:mm:ss', item['VAW_DTFIM'])
|
|
||||||
: '',
|
|
||||||
}),
|
|
||||||
imagePath:
|
|
||||||
'https://freaccess.com.br/freaccess/getImage.php?cliID=${cliUUID}&atividade=getFoto&Documento=${item['VTE_DOCUMENTO'] ?? ''}&tipo=E',
|
|
||||||
statusHashMap: [
|
|
||||||
if (Status.getStatus(item['VAW_STATUS']) == StatusEnum.active)
|
|
||||||
Map<String, Color>.from({
|
|
||||||
FFLocalizations.of(context).getVariableText(
|
|
||||||
ptText: 'Ativo',
|
|
||||||
enText: 'Active',
|
|
||||||
): FlutterFlowTheme.of(context).warning,
|
|
||||||
}),
|
|
||||||
if (Status.getStatus(item['VAW_STATUS']) == StatusEnum.unknown)
|
|
||||||
Map<String, Color>.from({
|
|
||||||
FFLocalizations.of(context).getVariableText(
|
|
||||||
ptText: 'Pendente',
|
|
||||||
enText: 'Pending',
|
|
||||||
): FlutterFlowTheme.of(context).alternate,
|
|
||||||
}),
|
|
||||||
if (Status.getStatus(item['VAW_STATUS']) == StatusEnum.canceled)
|
|
||||||
Map<String, Color>.from({
|
|
||||||
FFLocalizations.of(context).getVariableText(
|
|
||||||
ptText: 'Cancelado',
|
|
||||||
enText: 'Canceled',
|
|
||||||
): FlutterFlowTheme.of(context).error,
|
|
||||||
}),
|
|
||||||
if (Status.getStatus(item['VAW_STATUS']) == StatusEnum.finished)
|
|
||||||
Map<String, Color>.from({
|
|
||||||
FFLocalizations.of(context).getVariableText(
|
|
||||||
ptText: 'Finalizado',
|
|
||||||
enText: 'Finished',
|
|
||||||
): FlutterFlowTheme.of(context).success,
|
|
||||||
}),
|
|
||||||
if (Status.getStatus(item['VAW_STATUS']) == StatusEnum.blocked)
|
|
||||||
Map<String, Color>.from({
|
|
||||||
FFLocalizations.of(context).getVariableText(
|
|
||||||
ptText: 'Bloqueado',
|
|
||||||
enText: 'Blocked',
|
|
||||||
): FlutterFlowTheme.of(context).error,
|
|
||||||
}),
|
|
||||||
if (Status.getStatus(item['VAW_STATUS']) == StatusEnum.inactive)
|
|
||||||
Map<String, Color>.from({
|
|
||||||
FFLocalizations.of(context).getVariableText(
|
|
||||||
ptText: 'Inativo',
|
|
||||||
enText: 'Inactive',
|
|
||||||
): FlutterFlowTheme.of(context).warning,
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget buildPetDetails({
|
|
||||||
required dynamic item,
|
|
||||||
required BuildContext context,
|
|
||||||
required String devUUID,
|
|
||||||
required String userUUID,
|
|
||||||
required String cliUUID,
|
|
||||||
required String cliName,
|
|
||||||
required PetsPageModel model,
|
|
||||||
}) {
|
|
||||||
return DetailsComponentWidget(
|
|
||||||
buttons: [
|
|
||||||
// EDIT ACTION
|
|
||||||
FFButtonWidget(
|
|
||||||
text: FFLocalizations.of(context).getVariableText(
|
|
||||||
ptText: 'Editar',
|
|
||||||
enText: 'Edit',
|
|
||||||
),
|
|
||||||
icon: const Icon(Icons.edit),
|
|
||||||
onPressed: () async {
|
|
||||||
context.pop();
|
|
||||||
|
|
||||||
model.isEditing = true;
|
|
||||||
model.item = item;
|
|
||||||
model.switchTab(0);
|
|
||||||
model.setEditForm();
|
|
||||||
// model.safeSetState!();
|
|
||||||
},
|
|
||||||
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,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
// DELETE ACTION
|
|
||||||
FFButtonWidget(
|
|
||||||
text: FFLocalizations.of(context).getVariableText(
|
|
||||||
ptText: 'Excluir',
|
|
||||||
enText: 'Delete',
|
|
||||||
),
|
|
||||||
icon: const Icon(Icons.close),
|
|
||||||
onPressed: () async {
|
|
||||||
showAlertDialog(
|
|
||||||
context,
|
|
||||||
FFLocalizations.of(context).getVariableText(
|
|
||||||
ptText: 'Excluir Pet',
|
|
||||||
enText: 'Delete Pet',
|
|
||||||
),
|
|
||||||
FFLocalizations.of(context).getVariableText(
|
|
||||||
ptText: 'Você tem certeza que deseja excluir esse pet?',
|
|
||||||
enText: 'Are you sure you want to delete this pet?',
|
|
||||||
), () async {
|
|
||||||
int id = item['id'];
|
|
||||||
await PhpGroup.deletePet
|
|
||||||
.call(
|
|
||||||
petID: id,
|
|
||||||
)
|
|
||||||
.then((value) {
|
|
||||||
// Navigator.pop(context, value);
|
|
||||||
context.pop(value);
|
|
||||||
context.pop(value);
|
|
||||||
|
|
||||||
if (value == false) {
|
|
||||||
showSnackbar(
|
|
||||||
context,
|
|
||||||
FFLocalizations.of(context).getVariableText(
|
|
||||||
ptText: 'Erro ao excluir pet',
|
|
||||||
enText: 'Error deleting pet',
|
|
||||||
),
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
} else if (value == true) {
|
|
||||||
showSnackbar(
|
|
||||||
context,
|
|
||||||
FFLocalizations.of(context).getVariableText(
|
|
||||||
enText: 'Success deleting pet',
|
|
||||||
ptText: 'Succeso ao excluir pet',
|
|
||||||
),
|
|
||||||
false,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}).catchError((err, stack) {
|
|
||||||
context.pop();
|
|
||||||
showSnackbar(
|
|
||||||
context,
|
|
||||||
FFLocalizations.of(context).getVariableText(
|
|
||||||
enText: 'Error deleting pet',
|
|
||||||
ptText: 'Erro ao excluir pet',
|
|
||||||
),
|
|
||||||
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,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
// 'MIN', 'PEQ', 'MED', 'GRA', 'GIG'
|
|
||||||
labelsHashMap: Map<String, String>.from({
|
|
||||||
if (item['species'] != null && item['species'] != '')
|
|
||||||
'${FFLocalizations.of(context).getVariableText(ptText: "Espécie", enText: "Species")}:':
|
|
||||||
item['species'].toString().toUpperCase(),
|
|
||||||
if (item['breed'] != null && item['breed'] != '')
|
|
||||||
'${FFLocalizations.of(context).getVariableText(ptText: "Raça", enText: "Breed")}:':
|
|
||||||
item['breed'].toString().toUpperCase(),
|
|
||||||
if (item['color'] != null && item['color'] != '')
|
|
||||||
'${FFLocalizations.of(context).getVariableText(ptText: "Cor", enText: "Color")}:':
|
|
||||||
item['color'].toString().toUpperCase(),
|
|
||||||
if (item['birthdayDate'] != null && item['birthdayDate'] != '')
|
|
||||||
'${FFLocalizations.of(context).getVariableText(ptText: "Data de Nascimento", enText: "Date of Birth")}:':
|
|
||||||
ValidatorUtil.formatDateTimePicker(item['birthdayDate']),
|
|
||||||
if (item['gender'] != null && item['gender'] != '')
|
|
||||||
'${FFLocalizations.of(context).getVariableText(ptText: "Gênero", enText: "Gender")}:':
|
|
||||||
item['gender'] == 'MAC'
|
|
||||||
? FFLocalizations.of(context)
|
|
||||||
.getVariableText(ptText: 'MACHO', enText: 'MALE')
|
|
||||||
: FFLocalizations.of(context)
|
|
||||||
.getVariableText(enText: 'FEMALE', ptText: 'FÊMEA'),
|
|
||||||
if (item['size'] != null && item['size'] != '')
|
|
||||||
'${FFLocalizations.of(context).getVariableText(ptText: "Porte", enText: "Size")}:':
|
|
||||||
item['size'] == 'MIN'
|
|
||||||
? FFLocalizations.of(context)
|
|
||||||
.getVariableText(ptText: 'MINI', enText: 'MINI')
|
|
||||||
: item['size'] == 'PEQ'
|
|
||||||
? FFLocalizations.of(context)
|
|
||||||
.getVariableText(ptText: 'PEQUENO', enText: 'SMALL')
|
|
||||||
: item['size'] == 'MED'
|
|
||||||
? FFLocalizations.of(context)
|
|
||||||
.getVariableText(ptText: 'MÉDIO', enText: 'MEDIUM')
|
|
||||||
: item['size'] == 'GRD'
|
|
||||||
? FFLocalizations.of(context).getVariableText(
|
|
||||||
ptText: 'GRANDE', enText: 'LARGE')
|
|
||||||
: item['size'] == 'GIG'
|
|
||||||
? FFLocalizations.of(context).getVariableText(
|
|
||||||
ptText: 'GIGANTE', enText: 'GIANT')
|
|
||||||
: '',
|
|
||||||
if (item['notes'] != null && item['notes'] != '')
|
|
||||||
'${FFLocalizations.of(context).getVariableText(ptText: "Observação", enText: "Notes")}:':
|
|
||||||
item['notes'] ?? '',
|
|
||||||
}),
|
|
||||||
imagePath:
|
|
||||||
'https://freaccess.com.br/freaccess/getImage.php?devUUID=${devUUID}&userUUID=${userUUID}&cliID=${cliUUID}&atividade=consultaFotoPet&petId=${item['id'] ?? ''}',
|
|
||||||
statusHashMap: [
|
|
||||||
if (item['gender'] == "MAC")
|
|
||||||
Map<String, Color>.from({
|
|
||||||
item['name']: Color(0xFF094CB0),
|
|
||||||
}),
|
|
||||||
if (item['gender'] == "FEM")
|
|
||||||
Map<String, Color>.from({
|
|
||||||
item['name']: Color(0xFFE463E7),
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -3,6 +3,8 @@ import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'form_field_controller.dart';
|
import 'form_field_controller.dart';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class FlutterFlowDropDown<T> extends StatefulWidget {
|
class FlutterFlowDropDown<T> extends StatefulWidget {
|
||||||
const FlutterFlowDropDown({
|
const FlutterFlowDropDown({
|
||||||
super.key,
|
super.key,
|
||||||
|
|
|
@ -104,29 +104,7 @@ GoRouter createRouter(AppStateNotifier appStateNotifier) => GoRouter(
|
||||||
name: 'scheduleCompleteVisitPage',
|
name: 'scheduleCompleteVisitPage',
|
||||||
path: '/scheduleCompleteVisitPage',
|
path: '/scheduleCompleteVisitPage',
|
||||||
builder: (context, params) {
|
builder: (context, params) {
|
||||||
final dropdownValue1 = params.getParam(
|
return const ScheduleCompleteVisitPageWidget();
|
||||||
'dropdownValue1',
|
|
||||||
ParamType.String,
|
|
||||||
);
|
|
||||||
final dropdownValue2 = params.getParam(
|
|
||||||
'dropdownValue2',
|
|
||||||
ParamType.String,
|
|
||||||
);
|
|
||||||
final visitorStrList = params.getParam(
|
|
||||||
'visitorStrList',
|
|
||||||
ParamType.String,
|
|
||||||
);
|
|
||||||
final visitorJsonList = params.getParam<dynamic>(
|
|
||||||
'visitorJsonList',
|
|
||||||
ParamType.JSON,
|
|
||||||
isList: true,
|
|
||||||
);
|
|
||||||
return ScheduleCompleteVisitPageWidget(
|
|
||||||
dropdownValue1: dropdownValue1 ?? '',
|
|
||||||
dropdownValue2: dropdownValue2 ?? '',
|
|
||||||
visitorStrList: visitorStrList ?? '',
|
|
||||||
visitorJsonList: visitorJsonList ?? [],
|
|
||||||
);
|
|
||||||
}),
|
}),
|
||||||
FFRoute(
|
FFRoute(
|
||||||
name: 'deliverySchedule',
|
name: 'deliverySchedule',
|
||||||
|
|
|
@ -1,48 +1,16 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:hub/backend/api_requests/api_calls.dart';
|
|
||||||
import 'package:hub/backend/api_requests/api_manager.dart';
|
import 'package:hub/backend/api_requests/api_manager.dart';
|
||||||
import 'package:hub/components/molecular_components/message_opt_modal/opt_modal_widget.dart';
|
import 'package:hub/components/molecular_components/message_opt_modal/opt_modal_widget.dart';
|
||||||
import 'package:hub/flutter_flow/flutter_flow_model.dart';
|
import 'package:hub/flutter_flow/flutter_flow_model.dart';
|
||||||
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
|
||||||
import 'package:hub/flutter_flow/internationalization.dart';
|
|
||||||
import 'package:hub/flutter_flow/request_manager.dart';
|
import 'package:hub/flutter_flow/request_manager.dart';
|
||||||
import 'package:hub/pages/acess_history_page/acess_history_page_widget.dart';
|
import 'package:hub/pages/acess_history_page/acess_history_page_widget.dart';
|
||||||
import 'package:hub/shared/helpers/db_helper.dart';
|
import 'package:hub/shared/helpers/db_helper.dart';
|
||||||
import 'package:hub/shared/utils/dialog_util.dart';
|
|
||||||
import 'package:hub/shared/utils/log_util.dart';
|
|
||||||
import 'package:rxdart/rxdart.dart';
|
|
||||||
|
|
||||||
class AccessHistoryModel extends FlutterFlowModel<AccessHistoryScreen> {
|
|
||||||
// Singleton instance
|
|
||||||
static final AccessHistoryModel _instance = AccessHistoryModel._internal();
|
|
||||||
|
|
||||||
// Private constructor
|
|
||||||
AccessHistoryModel._internal() : super();
|
|
||||||
|
|
||||||
// Factory constructor to return the singleton instance
|
|
||||||
factory AccessHistoryModel() {
|
|
||||||
return _instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
class AcessHistoryPageModel extends FlutterFlowModel<AccessHistoryScreen> {
|
||||||
final DatabaseHelper db = DatabaseHelper();
|
final DatabaseHelper db = DatabaseHelper();
|
||||||
late final String devUUID;
|
late final String devUUID;
|
||||||
late final String userUUID;
|
late final String userUUID;
|
||||||
late final String cliUUID;
|
late final String cliUUID;
|
||||||
final BehaviorSubject<Map<String, String>> selectedTypeSubject;
|
|
||||||
bool isSubjectClosed = false;
|
|
||||||
final scaffoldKey = GlobalKey<ScaffoldState>();
|
|
||||||
late Function(Function) safeSetState;
|
|
||||||
|
|
||||||
late ScrollController scrollController;
|
|
||||||
int pageNumber = 1;
|
|
||||||
final int pageSize = 10;
|
|
||||||
bool hasData = false;
|
|
||||||
bool loading = false;
|
|
||||||
|
|
||||||
String personType = '.*';
|
|
||||||
|
|
||||||
late Future<void> accessFuture;
|
|
||||||
List<dynamic> accessWrap = [];
|
|
||||||
|
|
||||||
final unfocusNode = FocusNode();
|
final unfocusNode = FocusNode();
|
||||||
final _accessHistoryManager = FutureRequestManager<ApiCallResponse>();
|
final _accessHistoryManager = FutureRequestManager<ApiCallResponse>();
|
||||||
|
@ -62,10 +30,10 @@ class AccessHistoryModel extends FlutterFlowModel<AccessHistoryScreen> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState(BuildContext context) {
|
void initState(BuildContext context) {
|
||||||
_initAsync();
|
initDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _initAsync() async {
|
Future<void> initDatabase() async {
|
||||||
devUUID = await db
|
devUUID = await db
|
||||||
.get(key: 'devUUID', field: 'value')
|
.get(key: 'devUUID', field: 'value')
|
||||||
.then((value) => value.toString());
|
.then((value) => value.toString());
|
||||||
|
@ -77,95 +45,11 @@ class AccessHistoryModel extends FlutterFlowModel<AccessHistoryScreen> {
|
||||||
.then((value) => value.toString());
|
.then((value) => value.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void _updateAccessHistoryAction(
|
@override
|
||||||
Map<String, String> newType, BuildContext context) {
|
void dispose() {
|
||||||
if (!isSubjectClosed) {
|
unfocusNode.dispose();
|
||||||
final currentType = selectedTypeSubject.value;
|
|
||||||
final updatedType = Map<String, String>.from(currentType);
|
|
||||||
bool needsUpdate = false;
|
|
||||||
newType.forEach((key, newValue) {
|
|
||||||
if (currentType[key] != newValue) {
|
|
||||||
updatedType[key] = newValue;
|
|
||||||
needsUpdate = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (needsUpdate) {
|
|
||||||
selectedTypeSubject.add(updatedType);
|
|
||||||
fetchCardListViewService(updatedType, context);
|
|
||||||
safeSetState?.call(() {});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<ApiCallResponse?> fetchAccessHistoryService(
|
clearAccessHistoryCache();
|
||||||
BuildContext context) async {
|
|
||||||
try {
|
|
||||||
safeSetState.call(() => loading = true);
|
|
||||||
var response = await PhpGroup.getAccessCall.call(
|
|
||||||
pageSize: pageSize.toString(),
|
|
||||||
pageNumber: pageNumber.toString(),
|
|
||||||
pesTipo: personType != 'E' && personType != 'O' ? 'T' : personType,
|
|
||||||
);
|
|
||||||
|
|
||||||
final List<dynamic> accessHistory = response.jsonBody['acessos'] ?? [];
|
|
||||||
|
|
||||||
List<dynamic> filteredAccess = accessHistory.where((item) {
|
|
||||||
final personTypeMatches =
|
|
||||||
personType == '.*' || item["PES_TIPO"].toString() == personType;
|
|
||||||
return personTypeMatches;
|
|
||||||
}).toList();
|
|
||||||
|
|
||||||
if (filteredAccess != null && filteredAccess.isNotEmpty) {
|
|
||||||
safeSetState.call(() {
|
|
||||||
accessWrap.addAll(filteredAccess);
|
|
||||||
hasData = true;
|
|
||||||
loading = false;
|
|
||||||
});
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
_showNoMoreDataSnackbar(context);
|
|
||||||
safeSetState.call(() {
|
|
||||||
hasData = false;
|
|
||||||
loading = false;
|
|
||||||
});
|
|
||||||
return null;
|
|
||||||
} catch (e, s) {
|
|
||||||
DialogUtil.errorDefault(context);
|
|
||||||
LogUtil.requestAPIFailed('processRequest', "", "Busca Acesso", e, s);
|
|
||||||
safeSetState.call(() {
|
|
||||||
hasData = false;
|
|
||||||
loading = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
void _showNoMoreDataSnackbar(BuildContext context) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(
|
|
||||||
content: Text(
|
|
||||||
FFLocalizations.of(context).getVariableText(
|
|
||||||
ptText: "Não há mais dados.", enText: "No more data."),
|
|
||||||
),
|
|
||||||
duration: const Duration(seconds: 3),
|
|
||||||
backgroundColor: FlutterFlowTheme.of(context).primary,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _loadMoreAccess(BuildContext context) {
|
|
||||||
if (hasData == true) {
|
|
||||||
pageNumber++;
|
|
||||||
accessFuture = fetchAccessHistoryService(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void fetchCardListViewService(
|
|
||||||
Map<String, String> select, BuildContext context) {
|
|
||||||
personType = select['personType']!;
|
|
||||||
accessWrap = [];
|
|
||||||
pageNumber = 1;
|
|
||||||
accessFuture = fetchAccessHistoryService(context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future toggleOptionsAction(BuildContext context) async {
|
Future toggleOptionsAction(BuildContext context) async {
|
||||||
|
@ -187,11 +71,4 @@ class AccessHistoryModel extends FlutterFlowModel<AccessHistoryScreen> {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
unfocusNode.dispose();
|
|
||||||
|
|
||||||
clearAccessHistoryCache();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ import 'package:hub/shared/utils/log_util.dart';
|
||||||
import 'package:rxdart/rxdart.dart';
|
import 'package:rxdart/rxdart.dart';
|
||||||
|
|
||||||
@immutable
|
@immutable
|
||||||
// ignore: must_be_immutable
|
|
||||||
class AccessHistoryScreen extends StatefulWidget {
|
class AccessHistoryScreen extends StatefulWidget {
|
||||||
late Map<String, String> opt = {
|
late Map<String, String> opt = {
|
||||||
'personType': '.*',
|
'personType': '.*',
|
||||||
|
@ -24,13 +23,27 @@ class AccessHistoryScreen extends StatefulWidget {
|
||||||
};
|
};
|
||||||
AccessHistoryScreen({super.key, required this.opt});
|
AccessHistoryScreen({super.key, required this.opt});
|
||||||
@override
|
@override
|
||||||
State<AccessHistoryScreen> createState() => _AccessHistoryScreenState(opt);
|
State<AccessHistoryScreen> createState() => _AccessHistoryState(opt);
|
||||||
}
|
}
|
||||||
|
|
||||||
class _AccessHistoryScreenState extends State<AccessHistoryScreen> {
|
class _AccessHistoryState extends State<AccessHistoryScreen> {
|
||||||
late AccessHistoryModel _model;
|
late AcessHistoryPageModel _model;
|
||||||
|
final BehaviorSubject<Map<String, String>> selectedTypeSubject;
|
||||||
|
bool _isSubjectClosed = false;
|
||||||
|
final scaffoldKey = GlobalKey<ScaffoldState>();
|
||||||
|
|
||||||
_AccessHistoryScreenState(Map<String, String> opt)
|
late ScrollController _scrollController;
|
||||||
|
int _pageNumber = 1;
|
||||||
|
final int _pageSize = 10;
|
||||||
|
bool _hasData = false;
|
||||||
|
bool _loading = false;
|
||||||
|
|
||||||
|
String _personType = '.*';
|
||||||
|
|
||||||
|
late Future<void> _accessFuture;
|
||||||
|
List<dynamic> _accessWrap = [];
|
||||||
|
|
||||||
|
_AccessHistoryState(Map<String, String> opt)
|
||||||
: selectedTypeSubject = BehaviorSubject.seeded(opt) {
|
: selectedTypeSubject = BehaviorSubject.seeded(opt) {
|
||||||
selectedTypeSubject.listen((value) {});
|
selectedTypeSubject.listen((value) {});
|
||||||
}
|
}
|
||||||
|
@ -38,13 +51,13 @@ class _AccessHistoryScreenState extends State<AccessHistoryScreen> {
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_model = createModel(context, () => AccessHistoryModel());
|
_model = createModel(context, () => AcessHistoryPageModel());
|
||||||
_model.accessFuture = fetchAccessHistoryService();
|
_accessFuture = fetchAccessHistoryService();
|
||||||
|
|
||||||
_model.scrollController = ScrollController()
|
_scrollController = ScrollController()
|
||||||
..addListener(() {
|
..addListener(() {
|
||||||
if (_model.scrollController.position.atEdge &&
|
if (_scrollController.position.atEdge &&
|
||||||
_model.scrollController.position.pixels != 0) {
|
_scrollController.position.pixels != 0) {
|
||||||
_loadMoreAccess();
|
_loadMoreAccess();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -53,7 +66,7 @@ class _AccessHistoryScreenState extends State<AccessHistoryScreen> {
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
selectedTypeSubject.close();
|
selectedTypeSubject.close();
|
||||||
_model.isSubjectClosed = true;
|
_isSubjectClosed = true;
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +75,7 @@ class _AccessHistoryScreenState extends State<AccessHistoryScreen> {
|
||||||
final theme = FlutterFlowTheme.of(context);
|
final theme = FlutterFlowTheme.of(context);
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
key: _model.scaffoldKey,
|
key: scaffoldKey,
|
||||||
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
|
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
|
||||||
appBar: _appBar(context, theme),
|
appBar: _appBar(context, theme),
|
||||||
body: _body(context));
|
body: _body(context));
|
||||||
|
@ -150,13 +163,84 @@ class _AccessHistoryScreenState extends State<AccessHistoryScreen> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _updateAccessHistoryAction(Map<String, String> newType) {
|
||||||
|
if (!_isSubjectClosed) {
|
||||||
|
final currentType = selectedTypeSubject.value;
|
||||||
|
final updatedType = Map<String, String>.from(currentType);
|
||||||
|
bool needsUpdate = false;
|
||||||
|
newType.forEach((key, newValue) {
|
||||||
|
if (currentType[key] != newValue) {
|
||||||
|
updatedType[key] = newValue;
|
||||||
|
needsUpdate = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (needsUpdate) {
|
||||||
|
selectedTypeSubject.add(updatedType);
|
||||||
|
fetchCardListViewService(updatedType);
|
||||||
|
safeSetState(() {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<ApiCallResponse?> fetchAccessHistoryService() async {
|
||||||
|
try {
|
||||||
|
setState(() => _loading = true);
|
||||||
|
var response = await PhpGroup.getAccessCall.call(
|
||||||
|
pageSize: _pageSize.toString(),
|
||||||
|
pageNumber: _pageNumber.toString(),
|
||||||
|
pesTipo: _personType != 'E' && _personType != 'O' ? 'T' : _personType,
|
||||||
|
);
|
||||||
|
|
||||||
|
final List<dynamic> accessHistory = response.jsonBody['acessos'] ?? [];
|
||||||
|
|
||||||
|
List<dynamic> filteredAccess = accessHistory.where((item) {
|
||||||
|
final personTypeMatches =
|
||||||
|
_personType == '.*' || item["PES_TIPO"].toString() == _personType;
|
||||||
|
return personTypeMatches;
|
||||||
|
}).toList();
|
||||||
|
|
||||||
|
if (filteredAccess != null && filteredAccess.isNotEmpty) {
|
||||||
|
setState(() {
|
||||||
|
_accessWrap.addAll(filteredAccess);
|
||||||
|
_hasData = true;
|
||||||
|
_loading = false;
|
||||||
|
});
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
_showNoMoreDataSnackbar(context);
|
||||||
|
setState(() {
|
||||||
|
_hasData = false;
|
||||||
|
_loading = false;
|
||||||
|
});
|
||||||
|
return null;
|
||||||
|
} catch (e, s) {
|
||||||
|
DialogUtil.errorDefault(context);
|
||||||
|
LogUtil.requestAPIFailed('processRequest', "", "Busca Acesso", e, s);
|
||||||
|
setState(() {
|
||||||
|
_hasData = false;
|
||||||
|
_loading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showNoMoreDataSnackbar(BuildContext context) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text(
|
||||||
|
FFLocalizations.of(context).getVariableText(
|
||||||
|
ptText: "Não há mais dados.", enText: "No more data."),
|
||||||
|
),
|
||||||
|
duration: const Duration(seconds: 3),
|
||||||
|
backgroundColor: FlutterFlowTheme.of(context).primary,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Widget _body(BuildContext context) {
|
Widget _body(BuildContext context) {
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
if (_model.hasData == false &&
|
if (_hasData == false && _pageNumber <= 1 && _loading == false)
|
||||||
_model.pageNumber <= 1 &&
|
|
||||||
_model.loading == false)
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
@ -171,9 +255,9 @@ class _AccessHistoryScreenState extends State<AccessHistoryScreen> {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
else if (_model.hasData || _model.pageNumber >= 1)
|
else if (_hasData || _pageNumber >= 1)
|
||||||
Expanded(child: _cardListViewOrganismWidget()),
|
Expanded(child: _cardListViewOrganismWidget()),
|
||||||
if (_model.hasData == true && _model.loading)
|
if (_hasData == true && _loading)
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.only(top: 15, bottom: 15),
|
padding: const EdgeInsets.only(top: 15, bottom: 15),
|
||||||
child: Center(
|
child: Center(
|
||||||
|
@ -188,12 +272,26 @@ class _AccessHistoryScreenState extends State<AccessHistoryScreen> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _loadMoreAccess() {
|
||||||
|
if (_hasData == true) {
|
||||||
|
_pageNumber++;
|
||||||
|
_accessFuture = fetchAccessHistoryService();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void fetchCardListViewService(Map<String, String> select) {
|
||||||
|
_personType = select['personType']!;
|
||||||
|
_accessWrap = [];
|
||||||
|
_pageNumber = 1;
|
||||||
|
_accessFuture = fetchAccessHistoryService();
|
||||||
|
}
|
||||||
|
|
||||||
Widget _cardListViewOrganismWidget() {
|
Widget _cardListViewOrganismWidget() {
|
||||||
return FutureBuilder<void>(
|
return FutureBuilder<void>(
|
||||||
future: _model.accessFuture,
|
future: _accessFuture,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
if (snapshot.connectionState == ConnectionState.waiting &&
|
if (snapshot.connectionState == ConnectionState.waiting &&
|
||||||
_model.accessWrap.isEmpty) {
|
_accessWrap.isEmpty) {
|
||||||
return Center(
|
return Center(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: 50.0,
|
width: 50.0,
|
||||||
|
@ -215,10 +313,10 @@ class _AccessHistoryScreenState extends State<AccessHistoryScreen> {
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
physics: const BouncingScrollPhysics(),
|
physics: const BouncingScrollPhysics(),
|
||||||
controller: _model.scrollController,
|
controller: _scrollController,
|
||||||
itemCount: _model.accessWrap.length,
|
itemCount: _accessWrap.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final accessHistoryItem = _model.accessWrap[index];
|
final accessHistoryItem = _accessWrap[index];
|
||||||
return _accessHistoryCardMoleculeWidget(context, accessHistoryItem);
|
return _accessHistoryCardMoleculeWidget(context, accessHistoryItem);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -297,104 +395,3 @@ class _AccessHistoryScreenState extends State<AccessHistoryScreen> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AccessHistoryAppBar extends StatelessWidget {
|
|
||||||
AccessHistoryAppBar(this.model, this.selectedTypeSubject);
|
|
||||||
final AccessHistoryModel model;
|
|
||||||
final BehaviorSubject<Map<String, String>> selectedTypeSubject;
|
|
||||||
|
|
||||||
late final FlutterFlowTheme theme;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
theme = FlutterFlowTheme.of(context);
|
|
||||||
|
|
||||||
return AppBar(
|
|
||||||
backgroundColor: theme.primaryBackground,
|
|
||||||
automaticallyImplyLeading: false,
|
|
||||||
leading: _backButton(context, theme),
|
|
||||||
title: _title(context, theme),
|
|
||||||
centerTitle: true,
|
|
||||||
elevation: 0.0,
|
|
||||||
actions: [_filterButton(context)],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _backButton(BuildContext context, FlutterFlowTheme theme) {
|
|
||||||
return FlutterFlowIconButton(
|
|
||||||
borderColor: Colors.transparent,
|
|
||||||
borderRadius: 30.0,
|
|
||||||
borderWidth: 1.0,
|
|
||||||
buttonSize: 60.0,
|
|
||||||
icon: Icon(
|
|
||||||
Icons.keyboard_arrow_left,
|
|
||||||
color: theme.primaryText,
|
|
||||||
size: 30.0,
|
|
||||||
),
|
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _title(BuildContext context, FlutterFlowTheme theme) {
|
|
||||||
return Text(
|
|
||||||
FFLocalizations.of(context).getText('ch8qymga'),
|
|
||||||
style: theme.headlineMedium.override(
|
|
||||||
fontFamily: theme.headlineMediumFamily,
|
|
||||||
color: theme.primaryText,
|
|
||||||
fontSize: 16.0,
|
|
||||||
letterSpacing: 0.0,
|
|
||||||
useGoogleFonts:
|
|
||||||
GoogleFonts.asMap().containsKey(theme.headlineMediumFamily),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _filterButton(BuildContext context) {
|
|
||||||
return Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.fromLTRB(0, 0, 10, 0),
|
|
||||||
child: IconButton(
|
|
||||||
icon: const Icon(Icons.filter_list),
|
|
||||||
onPressed: () async {
|
|
||||||
final Map<String, String>? selectedFilter =
|
|
||||||
await showModalBottomSheet<Map<String, String>>(
|
|
||||||
isScrollControlled: true,
|
|
||||||
backgroundColor: Colors.transparent,
|
|
||||||
context: context,
|
|
||||||
builder: (context) {
|
|
||||||
return GestureDetector(
|
|
||||||
onTap: () => Navigator.of(context).pop(),
|
|
||||||
child: Container(
|
|
||||||
color: Colors.transparent,
|
|
||||||
child: GestureDetector(
|
|
||||||
onTap: () {},
|
|
||||||
child: OptModalWidget(
|
|
||||||
defaultPersonType:
|
|
||||||
selectedTypeSubject.value['personType'] ??
|
|
||||||
'.*',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (selectedFilter != null) {
|
|
||||||
_updateAccessHistoryAction(selectedFilter);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class AccessHistoryList extends StatelessWidget {
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
// TODO: implement build
|
|
||||||
throw UnimplementedError();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:hub/backend/api_requests/api_calls.dart';
|
import 'package:hub/backend/api_requests/api_calls.dart';
|
||||||
import 'package:hub/components/templates_components/card_item_template_component/card_item_template_component_widget.dart';
|
import 'package:hub/components/templates_components/card_item_template_component/card_item_template_component_widget.dart';
|
||||||
import 'package:hub/components/templates_components/details_component/details_component_action.dart';
|
|
||||||
import 'package:hub/flutter_flow/flutter_flow_theme.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_util.dart';
|
||||||
import 'package:hub/pages/liberation_history/liberation_history_model.dart';
|
import 'package:hub/pages/liberation_history/liberation_history_model.dart';
|
||||||
|
@ -263,7 +262,7 @@ class _PetsHistoryScreenState extends State<PetsHistoryScreen>
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return Dialog(
|
return Dialog(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: buildPetDetails(
|
child: widget.model.buildPetDetails(
|
||||||
item: uItem,
|
item: uItem,
|
||||||
context: context,
|
context: context,
|
||||||
devUUID: devUUID,
|
devUUID: devUUID,
|
||||||
|
|
|
@ -5,8 +5,12 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:http/http.dart';
|
import 'package:http/http.dart';
|
||||||
import 'package:hub/backend/api_requests/api_calls.dart';
|
import 'package:hub/backend/api_requests/api_calls.dart';
|
||||||
import 'package:hub/backend/api_requests/api_manager.dart';
|
import 'package:hub/backend/api_requests/api_manager.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_util.dart';
|
||||||
|
import 'package:hub/flutter_flow/flutter_flow_widgets.dart';
|
||||||
import 'package:hub/flutter_flow/form_field_controller.dart';
|
import 'package:hub/flutter_flow/form_field_controller.dart';
|
||||||
|
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||||
import 'package:hub/pages/pets_page/pets_page_widget.dart';
|
import 'package:hub/pages/pets_page/pets_page_widget.dart';
|
||||||
import 'package:hub/shared/helpers/db_helper.dart';
|
import 'package:hub/shared/helpers/db_helper.dart';
|
||||||
import 'package:hub/shared/utils/dialog_util.dart';
|
import 'package:hub/shared/utils/dialog_util.dart';
|
||||||
|
@ -388,4 +392,181 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
dropDownValueController1 = FormFieldController<String>(null);
|
dropDownValueController1 = FormFieldController<String>(null);
|
||||||
dropDownValueController2 = FormFieldController<String>(null);
|
dropDownValueController2 = FormFieldController<String>(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget buildPetDetails({
|
||||||
|
required dynamic item,
|
||||||
|
required BuildContext context,
|
||||||
|
required String devUUID,
|
||||||
|
required String userUUID,
|
||||||
|
required String cliUUID,
|
||||||
|
required String cliName,
|
||||||
|
required PetsPageModel model,
|
||||||
|
}) {
|
||||||
|
return DetailsComponentWidget(
|
||||||
|
buttons: [
|
||||||
|
// EDIT ACTION
|
||||||
|
FFButtonWidget(
|
||||||
|
text: FFLocalizations.of(context).getVariableText(
|
||||||
|
ptText: 'Editar',
|
||||||
|
enText: 'Edit',
|
||||||
|
),
|
||||||
|
icon: const Icon(Icons.edit),
|
||||||
|
onPressed: () async {
|
||||||
|
context.pop();
|
||||||
|
|
||||||
|
model.isEditing = true;
|
||||||
|
model.item = item;
|
||||||
|
model.switchTab(0);
|
||||||
|
model.setEditForm();
|
||||||
|
// model.safeSetState!();
|
||||||
|
},
|
||||||
|
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,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
// DELETE ACTION
|
||||||
|
FFButtonWidget(
|
||||||
|
text: FFLocalizations.of(context).getVariableText(
|
||||||
|
ptText: 'Excluir',
|
||||||
|
enText: 'Delete',
|
||||||
|
),
|
||||||
|
icon: const Icon(Icons.close),
|
||||||
|
onPressed: () async {
|
||||||
|
showAlertDialog(
|
||||||
|
context,
|
||||||
|
FFLocalizations.of(context).getVariableText(
|
||||||
|
ptText: 'Excluir Pet',
|
||||||
|
enText: 'Delete Pet',
|
||||||
|
),
|
||||||
|
FFLocalizations.of(context).getVariableText(
|
||||||
|
ptText: 'Você tem certeza que deseja excluir esse pet?',
|
||||||
|
enText: 'Are you sure you want to delete this pet?',
|
||||||
|
), () async {
|
||||||
|
int id = item['id'];
|
||||||
|
await PhpGroup.deletePet
|
||||||
|
.call(
|
||||||
|
petID: id,
|
||||||
|
)
|
||||||
|
.then((value) {
|
||||||
|
// Navigator.pop(context, value);
|
||||||
|
context.pop(value);
|
||||||
|
context.pop(value);
|
||||||
|
|
||||||
|
if (value == false) {
|
||||||
|
showSnackbar(
|
||||||
|
context,
|
||||||
|
FFLocalizations.of(context).getVariableText(
|
||||||
|
ptText: 'Erro ao excluir pet',
|
||||||
|
enText: 'Error deleting pet',
|
||||||
|
),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
} else if (value == true) {
|
||||||
|
showSnackbar(
|
||||||
|
context,
|
||||||
|
FFLocalizations.of(context).getVariableText(
|
||||||
|
enText: 'Success deleting pet',
|
||||||
|
ptText: 'Succeso ao excluir pet',
|
||||||
|
),
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}).catchError((err, stack) {
|
||||||
|
context.pop();
|
||||||
|
showSnackbar(
|
||||||
|
context,
|
||||||
|
FFLocalizations.of(context).getVariableText(
|
||||||
|
enText: 'Error deleting pet',
|
||||||
|
ptText: 'Erro ao excluir pet',
|
||||||
|
),
|
||||||
|
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,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
// 'MIN', 'PEQ', 'MED', 'GRA', 'GIG'
|
||||||
|
labelsHashMap: Map<String, String>.from({
|
||||||
|
if (item['species'] != null && item['species'] != '')
|
||||||
|
'${FFLocalizations.of(context).getVariableText(ptText: "Espécie", enText: "Species")}:':
|
||||||
|
item['species'].toString().toUpperCase(),
|
||||||
|
if (item['breed'] != null && item['breed'] != '')
|
||||||
|
'${FFLocalizations.of(context).getVariableText(ptText: "Raça", enText: "Breed")}:':
|
||||||
|
item['breed'].toString().toUpperCase(),
|
||||||
|
if (item['color'] != null && item['color'] != '')
|
||||||
|
'${FFLocalizations.of(context).getVariableText(ptText: "Cor", enText: "Color")}:':
|
||||||
|
item['color'].toString().toUpperCase(),
|
||||||
|
if (item['birthdayDate'] != null && item['birthdayDate'] != '')
|
||||||
|
'${FFLocalizations.of(context).getVariableText(ptText: "Data de Nascimento", enText: "Date of Birth")}:':
|
||||||
|
ValidatorUtil.formatDateTimePicker(item['birthdayDate']),
|
||||||
|
if (item['gender'] != null && item['gender'] != '')
|
||||||
|
'${FFLocalizations.of(context).getVariableText(ptText: "Gênero", enText: "Gender")}:':
|
||||||
|
item['gender'] == 'MAC'
|
||||||
|
? FFLocalizations.of(context)
|
||||||
|
.getVariableText(ptText: 'MACHO', enText: 'MALE')
|
||||||
|
: FFLocalizations.of(context)
|
||||||
|
.getVariableText(enText: 'FEMALE', ptText: 'FÊMEA'),
|
||||||
|
if (item['size'] != null && item['size'] != '')
|
||||||
|
'${FFLocalizations.of(context).getVariableText(ptText: "Porte", enText: "Size")}:':
|
||||||
|
item['size'] == 'MIN'
|
||||||
|
? FFLocalizations.of(context)
|
||||||
|
.getVariableText(ptText: 'MINI', enText: 'MINI')
|
||||||
|
: item['size'] == 'PEQ'
|
||||||
|
? FFLocalizations.of(context)
|
||||||
|
.getVariableText(ptText: 'PEQUENO', enText: 'SMALL')
|
||||||
|
: item['size'] == 'MED'
|
||||||
|
? FFLocalizations.of(context).getVariableText(
|
||||||
|
ptText: 'MÉDIO', enText: 'MEDIUM')
|
||||||
|
: item['size'] == 'GRD'
|
||||||
|
? FFLocalizations.of(context).getVariableText(
|
||||||
|
ptText: 'GRANDE', enText: 'LARGE')
|
||||||
|
: item['size'] == 'GIG'
|
||||||
|
? FFLocalizations.of(context).getVariableText(
|
||||||
|
ptText: 'GIGANTE', enText: 'GIANT')
|
||||||
|
: '',
|
||||||
|
if (item['notes'] != null && item['notes'] != '')
|
||||||
|
'${FFLocalizations.of(context).getVariableText(ptText: "Observação", enText: "Notes")}:':
|
||||||
|
item['notes'] ?? '',
|
||||||
|
}),
|
||||||
|
imagePath:
|
||||||
|
'https://freaccess.com.br/freaccess/getImage.php?devUUID=${devUUID}&userUUID=${userUUID}&cliID=${cliUUID}&atividade=consultaFotoPet&petId=${item['id'] ?? ''}',
|
||||||
|
statusHashMap: [
|
||||||
|
if (item['gender'] == "MAC")
|
||||||
|
Map<String, Color>.from({
|
||||||
|
item['name']: Color(0xFF094CB0),
|
||||||
|
}),
|
||||||
|
if (item['gender'] == "FEM")
|
||||||
|
Map<String, Color>.from({
|
||||||
|
item['name']: Color(0xFFE463E7),
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +1,43 @@
|
||||||
|
import 'dart:ffi';
|
||||||
|
|
||||||
import 'package:hub/backend/api_requests/api_calls.dart';
|
import 'package:hub/backend/api_requests/api_calls.dart';
|
||||||
import 'package:hub/backend/api_requests/api_manager.dart';
|
import 'package:hub/backend/api_requests/api_manager.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_model.dart';
|
|
||||||
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
||||||
|
import 'package:hub/flutter_flow/flutter_flow_widgets.dart';
|
||||||
import 'package:hub/flutter_flow/form_field_controller.dart';
|
import 'package:hub/flutter_flow/form_field_controller.dart';
|
||||||
import 'package:hub/flutter_flow/internationalization.dart';
|
import 'package:hub/flutter_flow/internationalization.dart';
|
||||||
|
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||||
import 'package:hub/flutter_flow/request_manager.dart';
|
import 'package:hub/flutter_flow/request_manager.dart';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:hub/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart';
|
import 'package:hub/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart';
|
||||||
|
import 'package:hub/pages/schedule_complete_visit_page/visit_history_page_widget.dart';
|
||||||
import 'package:hub/shared/helpers/db_helper.dart';
|
import 'package:hub/shared/helpers/db_helper.dart';
|
||||||
|
import 'package:hub/shared/mixins/status_mixin.dart';
|
||||||
|
import 'package:hub/shared/utils/validator_util.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:share_plus/share_plus.dart';
|
||||||
|
|
||||||
class ScheduleCompleteVisitPageModel
|
class ScheduleCompleteVisitPageModel
|
||||||
extends FlutterFlowModel<ScheduleCompleteVisitPageWidget> {
|
extends FlutterFlowModel<ScheduleComplete> {
|
||||||
|
late VoidCallback safeSetState;
|
||||||
|
late Function(Function) updateState;
|
||||||
final _visitHistoryManager = FutureRequestManager<ApiCallResponse>();
|
final _visitHistoryManager = FutureRequestManager<ApiCallResponse>();
|
||||||
final DatabaseHelper db = DatabaseHelper();
|
final DatabaseHelper db = DatabaseHelper();
|
||||||
late final String devUUID;
|
late final String devUUID;
|
||||||
late final String cliUUID;
|
late final String cliUUID;
|
||||||
late final String userUUID;
|
late final String userUUID;
|
||||||
|
|
||||||
|
late final String? dropdownValue1;
|
||||||
|
late final String? dropdownValue2;
|
||||||
|
bool? dropDownValidator1;
|
||||||
|
bool? dropDownValidator2;
|
||||||
|
List<dynamic> visitorJsonList = [];
|
||||||
|
String visitorStrList = '0';
|
||||||
|
|
||||||
Future<ApiCallResponse> visitHistory({
|
Future<ApiCallResponse> visitHistory({
|
||||||
String? uniqueQueryKey,
|
String? uniqueQueryKey,
|
||||||
bool? overrideCache,
|
bool? overrideCache,
|
||||||
|
@ -34,34 +52,25 @@ class ScheduleCompleteVisitPageModel
|
||||||
void clearVisitHistoryCacheKey(String? uniqueKey) =>
|
void clearVisitHistoryCacheKey(String? uniqueKey) =>
|
||||||
_visitHistoryManager.clearRequest(uniqueKey);
|
_visitHistoryManager.clearRequest(uniqueKey);
|
||||||
|
|
||||||
/// Local state fields for this page.
|
|
||||||
|
|
||||||
String convertDateFormat(String dateStr) {
|
String convertDateFormat(String dateStr) {
|
||||||
try {
|
try {
|
||||||
// Formato original
|
|
||||||
DateFormat originalFormat = DateFormat('dd/MM/yyyy HH:mm:ss');
|
DateFormat originalFormat = DateFormat('dd/MM/yyyy HH:mm:ss');
|
||||||
// Novo formato
|
|
||||||
DateFormat newFormat = DateFormat('y-M-d H:mm:ss');
|
DateFormat newFormat = DateFormat('y-M-d H:mm:ss');
|
||||||
|
|
||||||
// Validate the input string format
|
|
||||||
if (!RegExp(r'^\d{1,2}/\d{1,2}/\d{4} \d{1,2}:\d{2}:\d{2}$')
|
if (!RegExp(r'^\d{1,2}/\d{1,2}/\d{4} \d{1,2}:\d{2}:\d{2}$')
|
||||||
.hasMatch(dateStr)) {
|
.hasMatch(dateStr)) {
|
||||||
return 'Invalid date format';
|
return 'Invalid date format';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Converte a string para DateTime
|
|
||||||
DateTime dateTime = originalFormat.parse(dateStr);
|
DateTime dateTime = originalFormat.parse(dateStr);
|
||||||
|
|
||||||
// Converte DateTime para a nova string formatada
|
|
||||||
String formattedDate = newFormat.format(dateTime);
|
String formattedDate = newFormat.format(dateTime);
|
||||||
return formattedDate;
|
return formattedDate;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle the exception by returning an error message or a default value
|
|
||||||
return 'Invalid date format';
|
return 'Invalid date format';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<dynamic> visitorJsonList = [];
|
|
||||||
void addToVisitorJsonList(dynamic item) => visitorJsonList.add(item);
|
void addToVisitorJsonList(dynamic item) => visitorJsonList.add(item);
|
||||||
void removeFromVisitorJsonList(dynamic item) => visitorJsonList.remove(item);
|
void removeFromVisitorJsonList(dynamic item) => visitorJsonList.remove(item);
|
||||||
void removeAtIndexFromVisitorJsonList(int index) =>
|
void removeAtIndexFromVisitorJsonList(int index) =>
|
||||||
|
@ -71,10 +80,6 @@ class ScheduleCompleteVisitPageModel
|
||||||
void updateVisitorJsonListAtIndex(int index, Function(dynamic) updateFn) =>
|
void updateVisitorJsonListAtIndex(int index, Function(dynamic) updateFn) =>
|
||||||
visitorJsonList[index] = updateFn(visitorJsonList[index]);
|
visitorJsonList[index] = updateFn(visitorJsonList[index]);
|
||||||
|
|
||||||
String visitorStrList = '0';
|
|
||||||
bool? dropDownValidator1;
|
|
||||||
bool? dropDownValidator2;
|
|
||||||
|
|
||||||
bool isValid() {
|
bool isValid() {
|
||||||
if ((textController1!.text != '') &&
|
if ((textController1!.text != '') &&
|
||||||
(textController2!.text != '') &&
|
(textController2!.text != '') &&
|
||||||
|
@ -85,15 +90,11 @@ class ScheduleCompleteVisitPageModel
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// State fields for stateful widgets in this page.
|
|
||||||
|
|
||||||
final unfocusNode = FocusNode();
|
final unfocusNode = FocusNode();
|
||||||
// State field(s) for TabBar widget.
|
|
||||||
TabController? tabBarController;
|
TabController? tabBarController;
|
||||||
int get tabBarCurrentIndex =>
|
int get tabBarCurrentIndex =>
|
||||||
tabBarController != null ? tabBarController!.index : 0;
|
tabBarController != null ? tabBarController!.index : 0;
|
||||||
|
|
||||||
// State field(s) for TextField widget.
|
|
||||||
FocusNode? textFieldFocusNode1;
|
FocusNode? textFieldFocusNode1;
|
||||||
TextEditingController? textController1;
|
TextEditingController? textController1;
|
||||||
String? Function(BuildContext, String?)? textController1Validator;
|
String? Function(BuildContext, String?)? textController1Validator;
|
||||||
|
@ -131,7 +132,6 @@ class ScheduleCompleteVisitPageModel
|
||||||
}
|
}
|
||||||
|
|
||||||
DateTime? datePicked1;
|
DateTime? datePicked1;
|
||||||
// State field(s) for TextField widget.
|
|
||||||
FocusNode? textFieldFocusNode2;
|
FocusNode? textFieldFocusNode2;
|
||||||
TextEditingController? textController2;
|
TextEditingController? textController2;
|
||||||
String? Function(BuildContext, String?)? textController2Validator;
|
String? Function(BuildContext, String?)? textController2Validator;
|
||||||
|
@ -170,26 +170,16 @@ class ScheduleCompleteVisitPageModel
|
||||||
}
|
}
|
||||||
|
|
||||||
DateTime? datePicked2;
|
DateTime? datePicked2;
|
||||||
// State field(s) for DropDown widget.
|
|
||||||
String? dropDownValue1;
|
String? dropDownValue1;
|
||||||
FormFieldController<String>? dropDownValueController1;
|
FormFieldController<String>? dropDownValueController1;
|
||||||
|
|
||||||
// State field(s) for DropDown widget.
|
|
||||||
String? dropDownValue2;
|
String? dropDownValue2;
|
||||||
FormFieldController<String>? dropDownValueController2;
|
FormFieldController<String>? dropDownValueController2;
|
||||||
// State field(s) for Switch widget.
|
|
||||||
bool? switchValue;
|
bool? switchValue;
|
||||||
// State field(s) for TextField widget.
|
|
||||||
FocusNode? textFieldFocusNode3;
|
FocusNode? textFieldFocusNode3;
|
||||||
TextEditingController? textController3;
|
TextEditingController? textController3;
|
||||||
String? Function(BuildContext, String?)? textController3Validator;
|
String? Function(BuildContext, String?)? textController3Validator;
|
||||||
String? _textController3Validator(BuildContext context, String? val) {
|
String? _textController3Validator(BuildContext context, String? val) {
|
||||||
// if (val == null || val.isEmpty) {
|
|
||||||
// return FFLocalizations.of(context).getVariableText(
|
|
||||||
// enText: 'This field is required.',
|
|
||||||
// ptText: 'Este campo é obrigatório.',
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,8 +207,7 @@ class ScheduleCompleteVisitPageModel
|
||||||
textController1 = TextEditingController(
|
textController1 = TextEditingController(
|
||||||
text: dateTimeFormat(
|
text: dateTimeFormat(
|
||||||
'dd/MM/yyyy HH:mm:ss',
|
'dd/MM/yyyy HH:mm:ss',
|
||||||
DateTime.now().add(const Duration(minutes: 10)),
|
DateTime.now().add(const Duration(minutes: 0)),
|
||||||
// locale: FFLocalizations.of(context).languageCode,
|
|
||||||
));
|
));
|
||||||
textController1Validator = _textController1Validator;
|
textController1Validator = _textController1Validator;
|
||||||
|
|
||||||
|
@ -227,13 +216,59 @@ class ScheduleCompleteVisitPageModel
|
||||||
text: dateTimeFormat(
|
text: dateTimeFormat(
|
||||||
'dd/MM/yyyy HH:mm:ss',
|
'dd/MM/yyyy HH:mm:ss',
|
||||||
DateTime.now().add(const Duration(days: 1)),
|
DateTime.now().add(const Duration(days: 1)),
|
||||||
// locale: FFLocalizations.of(context).languageCode,
|
|
||||||
));
|
));
|
||||||
textController2Validator = _textController2Validator;
|
textController2Validator = _textController2Validator;
|
||||||
|
|
||||||
textFieldFocusNode3 = FocusNode();
|
textFieldFocusNode3 = FocusNode();
|
||||||
textController3 = TextEditingController();
|
textController3 = TextEditingController();
|
||||||
textController3Validator = _textController3Validator;
|
textController3Validator = _textController3Validator;
|
||||||
|
|
||||||
|
dropDownValueController1 ??=
|
||||||
|
FormFieldController<String>(dropDownValue1 ??= '');
|
||||||
|
dropDownValueController2 ??=
|
||||||
|
FormFieldController<String>(dropDownValue2 ??= '');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Updated variables for dropdowns
|
||||||
|
late final List<String> reasonsDropDown1 = [];
|
||||||
|
late final List<String> labelsDropDown1 = [];
|
||||||
|
late final List<String> optionsDropdown1 = [];
|
||||||
|
|
||||||
|
late final List<String> lavelsDropDown2 = [];
|
||||||
|
late final List<String> labelsDropDown2 = [];
|
||||||
|
late final List<String> optionsDropdown2 = [];
|
||||||
|
|
||||||
|
// Methods to process dropdown values
|
||||||
|
void processDropDown1(List<dynamic> reasonsJsonList) {
|
||||||
|
if (dropDownValue1 != null && dropDownValue1!.isNotEmpty) {
|
||||||
|
String value = dropDownValue1!;
|
||||||
|
if (!(value.contains('{') &&
|
||||||
|
value.contains('}') &&
|
||||||
|
value.contains(':'))) {
|
||||||
|
var item = reasonsJsonList.where((reason) =>
|
||||||
|
reason['MOT_DESCRICAO'].toString().contains(dropDownValue1!));
|
||||||
|
dropDownValue1 = item.firstOrNull?.toString() ?? '';
|
||||||
|
dropDownValueController1?.value = dropDownValue1!;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
reasonsDropDown1.clear();
|
||||||
|
reasonsDropDown1.addAll(reasonsJsonList.map((e) => e.toString()).toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
void processDropDown2(List<dynamic> lavelList) {
|
||||||
|
if (dropDownValue2 != null && dropDownValue2!.isNotEmpty) {
|
||||||
|
String value = dropDownValue2!;
|
||||||
|
if (!(value.contains('{') &&
|
||||||
|
value.contains('}') &&
|
||||||
|
value.contains(':'))) {
|
||||||
|
var item = lavelList.where((level) =>
|
||||||
|
level['NAC_DESCRICAO'].toString().contains(dropDownValue2!));
|
||||||
|
dropDownValue2 = item.firstOrNull?.toString() ?? '';
|
||||||
|
dropDownValueController2?.value = dropDownValue2!;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lavelsDropDown2.clear();
|
||||||
|
lavelsDropDown2.addAll(lavelList.map((e) => e.toString()).toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -252,7 +287,55 @@ class ScheduleCompleteVisitPageModel
|
||||||
clearVisitHistoryCache();
|
clearVisitHistoryCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Action blocks.
|
Future changeStatusAction(
|
||||||
|
BuildContext context,
|
||||||
|
int idDestino,
|
||||||
|
int idVisita,
|
||||||
|
String accessKey,
|
||||||
|
String email,
|
||||||
|
) async {
|
||||||
|
// Navigator.pop(context, true);
|
||||||
|
context.pop(true);
|
||||||
|
|
||||||
|
bool? blockVisitRequest;
|
||||||
|
blockVisitRequest = await visitCancelAction(
|
||||||
|
context,
|
||||||
|
accessKey: accessKey,
|
||||||
|
idDestino: idDestino,
|
||||||
|
idVisita: idVisita,
|
||||||
|
email: email,
|
||||||
|
);
|
||||||
|
if (!context.mounted) return;
|
||||||
|
if (blockVisitRequest == true) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> visitCancelAction(BuildContext context,
|
||||||
|
{required int? idDestino,
|
||||||
|
required int? idVisita,
|
||||||
|
required String? accessKey,
|
||||||
|
required String? email}) async {
|
||||||
|
final ApiCallResponse? response;
|
||||||
|
final CancelaVisita callback = PhpGroup.cancelaVisita;
|
||||||
|
|
||||||
|
response = await callback.call(
|
||||||
|
idDestino: idDestino,
|
||||||
|
idVisita: idVisita,
|
||||||
|
AccessKey: accessKey,
|
||||||
|
UsuEmail: email,
|
||||||
|
DevDesc: '',
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
return !response.jsonBody['error'];
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future getVisitorsActionPage(
|
Future getVisitorsActionPage(
|
||||||
BuildContext context, {
|
BuildContext context, {
|
||||||
List<dynamic>? visitorsJsonList,
|
List<dynamic>? visitorsJsonList,
|
||||||
|
@ -270,4 +353,258 @@ class ScheduleCompleteVisitPageModel
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void switchTab(int index) {
|
||||||
|
tabBarController?.animateTo(index);
|
||||||
|
|
||||||
|
safeSetState.call();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setFormField() {
|
||||||
|
// if ((visitorStrList != null && visitorStrList != '') &&
|
||||||
|
// ((visitorJsonList != null && (visitorJsonList)!.isNotEmpty) != null)) {
|
||||||
|
// visitorJsonList = visitorJsonList!
|
||||||
|
// .where((e) =>
|
||||||
|
// visitorStrList ==
|
||||||
|
// getJsonField(
|
||||||
|
// e,
|
||||||
|
// r'''$.VTE_DOCUMENTO''',
|
||||||
|
// ).toString().toString())
|
||||||
|
// .toList()
|
||||||
|
// .toList()
|
||||||
|
// .cast<dynamic>();
|
||||||
|
// visitorStrList = visitorStrList!;
|
||||||
|
|
||||||
|
// safeSetState.call();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if ((dropdownValue1 != null && dropdownValue1 != '') &&
|
||||||
|
// (dropdownValue2 != null && dropdownValue2 != '')) {
|
||||||
|
// dropDownValue1 = dropdownValue1!;
|
||||||
|
// dropDownValue2 = dropdownValue2!;
|
||||||
|
// safeSetState.call();
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildVisitDetails({
|
||||||
|
required dynamic item,
|
||||||
|
required BuildContext context,
|
||||||
|
required Future<dynamic> Function(BuildContext, int, int, String, String)
|
||||||
|
changeStatusAction,
|
||||||
|
required String devUUID,
|
||||||
|
required String userUUID,
|
||||||
|
required String cliUUID,
|
||||||
|
required String cliName,
|
||||||
|
}) {
|
||||||
|
return DetailsComponentWidget(
|
||||||
|
buttons: [
|
||||||
|
if (Status.getStatus(item['VAW_STATUS']) ==
|
||||||
|
StatusEnum.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: 'Cancelar Visita',
|
||||||
|
enText: 'Cancel 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(item['VAW_DESTINO']),
|
||||||
|
int.parse(item['VAW_ID']),
|
||||||
|
item['VAW_CHAVE'] ?? '',
|
||||||
|
item['VTE_DOCUMENTO'] ?? '',
|
||||||
|
)
|
||||||
|
.then((value) {
|
||||||
|
// Navigator.pop(context, value);
|
||||||
|
context.pop(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) {
|
||||||
|
context.pop();
|
||||||
|
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 (Status.getStatus(item['VAW_STATUS']) !=
|
||||||
|
StatusEnum.active) // RECALL ACTION
|
||||||
|
FFButtonWidget(
|
||||||
|
text: FFLocalizations.of(context).getVariableText(
|
||||||
|
ptText: 'Reagendar',
|
||||||
|
enText: 'Reschedule',
|
||||||
|
),
|
||||||
|
icon: const Icon(Icons.refresh),
|
||||||
|
onPressed: () async {
|
||||||
|
context.pop();
|
||||||
|
|
||||||
|
dropDownValue1 = item['MOT_DESCRICAO'];
|
||||||
|
dropDownValue2 = item['NAC_DESCRICAO'];
|
||||||
|
|
||||||
|
visitorJsonList = [item];
|
||||||
|
visitorStrList = item['VTE_DOCUMENTO'];
|
||||||
|
|
||||||
|
switchTab(0);
|
||||||
|
},
|
||||||
|
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 (Status.getStatus(item['VAW_STATUS']) ==
|
||||||
|
StatusEnum.active) // SHARE ACTION
|
||||||
|
FFButtonWidget(
|
||||||
|
text: FFLocalizations.of(context).getVariableText(
|
||||||
|
ptText: 'Compartilhar',
|
||||||
|
enText: 'Share',
|
||||||
|
),
|
||||||
|
icon: const Icon(Icons.share),
|
||||||
|
onPressed: () async {
|
||||||
|
Share.share('''
|
||||||
|
Olá, \*${item['VTE_NOME']}\*! Você foi convidado para \*${cliName}\*.
|
||||||
|
|
||||||
|
\*Validade do Convite\*:
|
||||||
|
- Início: ${item['VAW_DTINICIO']}
|
||||||
|
- Fim: ${item['VAW_DTFIM']}
|
||||||
|
|
||||||
|
URL do Convite: https://visita.freaccess.com.br/${item['VAW_ID']}/${cliUUID}/${item['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")}:':
|
||||||
|
item['VTE_NOME'] ?? '',
|
||||||
|
'${FFLocalizations.of(context).getVariableText(ptText: "Inicio", enText: "Start")}:':
|
||||||
|
item['VAW_DTINICIO'] != '' && item['VAW_DTINICIO'] != null
|
||||||
|
? ValidatorUtil.toLocalDateTime(
|
||||||
|
'yyyy-MM-dd HH:mm:ss', item['VAW_DTINICIO'])
|
||||||
|
: '',
|
||||||
|
'${FFLocalizations.of(context).getVariableText(ptText: "Fim", enText: "End")}:':
|
||||||
|
item['VAW_DTFIM'] != '' && item['VAW_DTFIM'] != null
|
||||||
|
? ValidatorUtil.toLocalDateTime(
|
||||||
|
'yyyy-MM-dd HH:mm:ss', item['VAW_DTFIM'])
|
||||||
|
: '',
|
||||||
|
}),
|
||||||
|
imagePath:
|
||||||
|
'https://freaccess.com.br/freaccess/getImage.php?cliID=${cliUUID}&atividade=getFoto&Documento=${item['VTE_DOCUMENTO'] ?? ''}&tipo=E',
|
||||||
|
statusHashMap: [
|
||||||
|
if (Status.getStatus(item['VAW_STATUS']) == StatusEnum.active)
|
||||||
|
Map<String, Color>.from({
|
||||||
|
FFLocalizations.of(context).getVariableText(
|
||||||
|
ptText: 'Ativo',
|
||||||
|
enText: 'Active',
|
||||||
|
): FlutterFlowTheme.of(context).warning,
|
||||||
|
}),
|
||||||
|
if (Status.getStatus(item['VAW_STATUS']) == StatusEnum.unknown)
|
||||||
|
Map<String, Color>.from({
|
||||||
|
FFLocalizations.of(context).getVariableText(
|
||||||
|
ptText: 'Pendente',
|
||||||
|
enText: 'Pending',
|
||||||
|
): FlutterFlowTheme.of(context).alternate,
|
||||||
|
}),
|
||||||
|
if (Status.getStatus(item['VAW_STATUS']) == StatusEnum.canceled)
|
||||||
|
Map<String, Color>.from({
|
||||||
|
FFLocalizations.of(context).getVariableText(
|
||||||
|
ptText: 'Cancelado',
|
||||||
|
enText: 'Canceled',
|
||||||
|
): FlutterFlowTheme.of(context).error,
|
||||||
|
}),
|
||||||
|
if (Status.getStatus(item['VAW_STATUS']) == StatusEnum.finished)
|
||||||
|
Map<String, Color>.from({
|
||||||
|
FFLocalizations.of(context).getVariableText(
|
||||||
|
ptText: 'Finalizado',
|
||||||
|
enText: 'Finished',
|
||||||
|
): FlutterFlowTheme.of(context).success,
|
||||||
|
}),
|
||||||
|
if (Status.getStatus(item['VAW_STATUS']) == StatusEnum.blocked)
|
||||||
|
Map<String, Color>.from({
|
||||||
|
FFLocalizations.of(context).getVariableText(
|
||||||
|
ptText: 'Bloqueado',
|
||||||
|
enText: 'Blocked',
|
||||||
|
): FlutterFlowTheme.of(context).error,
|
||||||
|
}),
|
||||||
|
if (Status.getStatus(item['VAW_STATUS']) == StatusEnum.inactive)
|
||||||
|
Map<String, Color>.from({
|
||||||
|
FFLocalizations.of(context).getVariableText(
|
||||||
|
ptText: 'Inativo',
|
||||||
|
enText: 'Inactive',
|
||||||
|
): FlutterFlowTheme.of(context).warning,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:auto_size_text/auto_size_text.dart';
|
import 'package:auto_size_text/auto_size_text.dart';
|
||||||
import 'package:cached_network_image/cached_network_image.dart';
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
@ -18,24 +20,22 @@ import 'package:hub/flutter_flow/flutter_flow_widgets.dart';
|
||||||
import 'package:hub/flutter_flow/form_field_controller.dart';
|
import 'package:hub/flutter_flow/form_field_controller.dart';
|
||||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||||
import 'package:hub/pages/schedule_complete_visit_page/schedule_complete_visit_page_model.dart';
|
import 'package:hub/pages/schedule_complete_visit_page/schedule_complete_visit_page_model.dart';
|
||||||
import 'package:hub/pages/visit_history_page/visit_history_page_widget.dart';
|
import 'package:hub/pages/schedule_complete_visit_page/visit_history_page_widget.dart';
|
||||||
import 'package:hub/shared/utils/dialog_util.dart';
|
import 'package:hub/shared/utils/dialog_util.dart';
|
||||||
import 'package:hub/shared/utils/share_util.dart';
|
import 'package:hub/shared/utils/share_util.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class ScheduleCompleteVisitPageWidget extends StatefulWidget {
|
class ScheduleComplete extends StatefulWidget {
|
||||||
const ScheduleCompleteVisitPageWidget({
|
const ScheduleComplete({Key? key}) : super(key: key);
|
||||||
super.key,
|
|
||||||
this.dropdownValue1,
|
|
||||||
this.dropdownValue2,
|
|
||||||
this.visitorStrList,
|
|
||||||
this.visitorJsonList,
|
|
||||||
});
|
|
||||||
|
|
||||||
final String? dropdownValue1;
|
@override
|
||||||
final String? dropdownValue2;
|
State<StatefulWidget> createState() {
|
||||||
final String? visitorStrList;
|
throw UnimplementedError();
|
||||||
final List<dynamic>? visitorJsonList;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ScheduleCompleteVisitPageWidget extends ScheduleComplete {
|
||||||
|
const ScheduleCompleteVisitPageWidget();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ScheduleCompleteVisitPageWidget> createState() =>
|
State<ScheduleCompleteVisitPageWidget> createState() =>
|
||||||
|
@ -57,39 +57,9 @@ class _ScheduleCompleteVisitPageWidgetState
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_model = createModel(context, () => ScheduleCompleteVisitPageModel());
|
_model = createModel(context, () => ScheduleCompleteVisitPageModel());
|
||||||
|
_model.safeSetState = () => safeSetState(() {});
|
||||||
|
_model.updateState = (Function fn) => safeSetState(fn());
|
||||||
|
|
||||||
// On page load action.
|
|
||||||
SchedulerBinding.instance.addPostFrameCallback((_) async {
|
|
||||||
if ((widget.visitorStrList != null && widget.visitorStrList != '') &&
|
|
||||||
((widget.visitorJsonList != null &&
|
|
||||||
(widget.visitorJsonList)!.isNotEmpty) !=
|
|
||||||
null)) {
|
|
||||||
_model.visitorJsonList = widget.visitorJsonList!
|
|
||||||
.where((e) =>
|
|
||||||
widget.visitorStrList ==
|
|
||||||
getJsonField(
|
|
||||||
e,
|
|
||||||
r'''$.VTE_DOCUMENTO''',
|
|
||||||
).toString().toString())
|
|
||||||
.toList()
|
|
||||||
.toList()
|
|
||||||
.cast<dynamic>();
|
|
||||||
_model.visitorStrList = widget.visitorStrList!;
|
|
||||||
|
|
||||||
safeSetState(() {});
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((widget.dropdownValue1 != null && widget.dropdownValue1 != '') &&
|
|
||||||
(widget.dropdownValue2 != null && widget.dropdownValue2 != '')) {
|
|
||||||
_model.dropDownValue1 = widget.dropdownValue1!;
|
|
||||||
_model.dropDownValue2 = widget.dropdownValue2!;
|
|
||||||
safeSetState(() {});
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
_model.tabBarController = TabController(
|
_model.tabBarController = TabController(
|
||||||
vsync: this,
|
vsync: this,
|
||||||
length: 2,
|
length: 2,
|
||||||
|
@ -107,21 +77,15 @@ class _ScheduleCompleteVisitPageWidgetState
|
||||||
}
|
}
|
||||||
|
|
||||||
void _loadMoreVisitHistory() async {
|
void _loadMoreVisitHistory() async {
|
||||||
// Simulate fetching data from an API or database
|
|
||||||
Future<List<String>> fetchVisitHistory(int start, int limit) async {
|
Future<List<String>> fetchVisitHistory(int start, int limit) async {
|
||||||
// Simulate network delay
|
|
||||||
await Future.delayed(const Duration(seconds: 1));
|
await Future.delayed(const Duration(seconds: 1));
|
||||||
// Generate a list of visit history items
|
|
||||||
return List.generate(limit, (index) => "Item ${start + index}");
|
return List.generate(limit, (index) => "Item ${start + index}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate the start index for the next batch of items to load
|
|
||||||
final int start = _visitHistoryLoadingIdx * _visitHistoryLoadingCount;
|
final int start = _visitHistoryLoadingIdx * _visitHistoryLoadingCount;
|
||||||
// Fetch the next batch of items
|
|
||||||
final List<String> newItems =
|
final List<String> newItems =
|
||||||
await fetchVisitHistory(start, _visitHistoryLoadingCount);
|
await fetchVisitHistory(start, _visitHistoryLoadingCount);
|
||||||
|
|
||||||
// If new items were fetched, add them to the list and update the index
|
|
||||||
if (newItems.isNotEmpty) {
|
if (newItems.isNotEmpty) {
|
||||||
_visitHistoryList.addAll(newItems);
|
_visitHistoryList.addAll(newItems);
|
||||||
_visitHistoryLoadingIdx++;
|
_visitHistoryLoadingIdx++;
|
||||||
|
@ -183,7 +147,7 @@ PreferredSizeWidget appBarScheduleCompleteVisit(BuildContext context) {
|
||||||
),
|
),
|
||||||
title: Text(
|
title: Text(
|
||||||
FFLocalizations.of(context).getText(
|
FFLocalizations.of(context).getText(
|
||||||
'61lcxdgm' /* Agendar Visita */,
|
'61lcxdgm',
|
||||||
),
|
),
|
||||||
style: FlutterFlowTheme.of(context).headlineMedium.override(
|
style: FlutterFlowTheme.of(context).headlineMedium.override(
|
||||||
fontFamily: 'Nunito',
|
fontFamily: 'Nunito',
|
||||||
|
@ -223,12 +187,12 @@ Widget bodyScheduleCompleteVisit(BuildContext context,
|
||||||
tabs: [
|
tabs: [
|
||||||
Tab(
|
Tab(
|
||||||
text: FFLocalizations.of(context).getText(
|
text: FFLocalizations.of(context).getText(
|
||||||
'ueth1f4g' /* Cadastrar Visita */,
|
'ueth1f4g',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Tab(
|
Tab(
|
||||||
text: FFLocalizations.of(context).getText(
|
text: FFLocalizations.of(context).getText(
|
||||||
'k4uraqam' /* Histórico de Visitas */,
|
'k4uraqam',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -278,7 +242,7 @@ Widget scheduleVisit(BuildContext context,
|
||||||
20.0, 30.0, 0.0, 24.0),
|
20.0, 30.0, 0.0, 24.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
FFLocalizations.of(context).getText(
|
FFLocalizations.of(context).getText(
|
||||||
'98evnbbe' /* Qual o período de validade da ... */,
|
'98evnbbe',
|
||||||
),
|
),
|
||||||
textAlign: TextAlign.start,
|
textAlign: TextAlign.start,
|
||||||
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
||||||
|
@ -298,7 +262,6 @@ Widget scheduleVisit(BuildContext context,
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: MediaQuery.of(context).size.width,
|
width: MediaQuery.of(context).size.width,
|
||||||
height: 60.0,
|
height: 60.0,
|
||||||
// decoration: const BoxDecoration(),
|
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
|
@ -328,7 +291,7 @@ Widget scheduleVisit(BuildContext context,
|
||||||
.labelMediumFamily),
|
.labelMediumFamily),
|
||||||
),
|
),
|
||||||
hintText: FFLocalizations.of(context).getText(
|
hintText: FFLocalizations.of(context).getText(
|
||||||
'53cbwqh9' /* Quando você inicia a visita? */,
|
'53cbwqh9',
|
||||||
),
|
),
|
||||||
hintStyle: FlutterFlowTheme.of(context)
|
hintStyle: FlutterFlowTheme.of(context)
|
||||||
.labelMedium
|
.labelMedium
|
||||||
|
@ -549,7 +512,6 @@ Widget scheduleVisit(BuildContext context,
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: MediaQuery.of(context).size.width,
|
width: MediaQuery.of(context).size.width,
|
||||||
height: 60.0,
|
height: 60.0,
|
||||||
// decoration: const BoxDecoration(),
|
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
|
@ -579,7 +541,7 @@ Widget scheduleVisit(BuildContext context,
|
||||||
.labelMediumFamily),
|
.labelMediumFamily),
|
||||||
),
|
),
|
||||||
hintText: FFLocalizations.of(context).getText(
|
hintText: FFLocalizations.of(context).getText(
|
||||||
'xpgc5e8d' /* Quando a visita terminá? */,
|
'xpgc5e8d',
|
||||||
),
|
),
|
||||||
hintStyle: FlutterFlowTheme.of(context)
|
hintStyle: FlutterFlowTheme.of(context)
|
||||||
.labelMedium
|
.labelMedium
|
||||||
|
@ -793,9 +755,7 @@ Widget scheduleVisit(BuildContext context,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
]
|
]),
|
||||||
// .divide(const SizedBox(height: 0.0)),
|
|
||||||
),
|
|
||||||
Column(
|
Column(
|
||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
children: [
|
children: [
|
||||||
|
@ -806,7 +766,7 @@ Widget scheduleVisit(BuildContext context,
|
||||||
20.0, 24.0, 0.0, 30.0),
|
20.0, 24.0, 0.0, 30.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
FFLocalizations.of(context).getText(
|
FFLocalizations.of(context).getText(
|
||||||
'u0jocx7e' /* Quais visitantes você deseja c... */,
|
'u0jocx7e',
|
||||||
),
|
),
|
||||||
textAlign: TextAlign.start,
|
textAlign: TextAlign.start,
|
||||||
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
||||||
|
@ -1018,7 +978,7 @@ Widget scheduleVisit(BuildContext context,
|
||||||
alignment: const AlignmentDirectional(0.0, 0.0),
|
alignment: const AlignmentDirectional(0.0, 0.0),
|
||||||
child: AutoSizeText(
|
child: AutoSizeText(
|
||||||
FFLocalizations.of(context).getText(
|
FFLocalizations.of(context).getText(
|
||||||
'r8soavtz' /* Clique para adicionar um visit... */,
|
'r8soavtz',
|
||||||
),
|
),
|
||||||
style: FlutterFlowTheme.of(context)
|
style: FlutterFlowTheme.of(context)
|
||||||
.bodyMedium
|
.bodyMedium
|
||||||
|
@ -1052,7 +1012,7 @@ Widget scheduleVisit(BuildContext context,
|
||||||
20.0, 24.0, 0.0, 24.0),
|
20.0, 24.0, 0.0, 24.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
FFLocalizations.of(context).getText(
|
FFLocalizations.of(context).getText(
|
||||||
'0meymh6u' /* Quais são os motivos da visita... */,
|
'0meymh6u',
|
||||||
),
|
),
|
||||||
textAlign: TextAlign.start,
|
textAlign: TextAlign.start,
|
||||||
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
||||||
|
@ -1097,54 +1057,23 @@ Widget scheduleVisit(BuildContext context,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final dropDownGetDadosResponse =
|
|
||||||
snapshot.data!;
|
|
||||||
final reasonsJsonList =
|
final reasonsJsonList =
|
||||||
PhpGroup.getDadosCall.reasonsJsonList(
|
PhpGroup.getDadosCall.reasonsJsonList(
|
||||||
dropDownGetDadosResponse.jsonBody);
|
snapshot.data!.jsonBody);
|
||||||
|
final reasonsOptionLabels = PhpGroup
|
||||||
|
.getDadosCall
|
||||||
|
.reasonsMotDescStrList(
|
||||||
|
snapshot.data!.jsonBody);
|
||||||
|
|
||||||
if (_model.dropDownValue1 != '' &&
|
_model.processDropDown1(reasonsJsonList!);
|
||||||
_model.dropDownValue1 != null) {
|
|
||||||
String value =
|
|
||||||
_model.dropDownValue1.toString() ??
|
|
||||||
'';
|
|
||||||
|
|
||||||
if (value.contains('{') &&
|
|
||||||
value.contains('}') &&
|
|
||||||
value.contains(':')) {
|
|
||||||
} else {
|
|
||||||
if (reasonsJsonList != null &&
|
|
||||||
reasonsJsonList.isNotEmpty) {
|
|
||||||
var item = reasonsJsonList.where(
|
|
||||||
(reason) =>
|
|
||||||
reason['MOT_DESCRICAO']
|
|
||||||
.toString()
|
|
||||||
.contains(_model
|
|
||||||
.dropDownValue1 ??
|
|
||||||
''));
|
|
||||||
_model.dropDownValue1 =
|
|
||||||
item.firstOrNull.toString() ?? '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return FlutterFlowDropDown<String>(
|
return FlutterFlowDropDown<String>(
|
||||||
fillColor: FlutterFlowTheme.of(context)
|
fillColor: FlutterFlowTheme.of(context)
|
||||||
.primaryBackground,
|
.primaryBackground,
|
||||||
controller:
|
controller:
|
||||||
_model.dropDownValueController1 ??=
|
_model.dropDownValueController1,
|
||||||
FormFieldController<String>(
|
options: _model.reasonsDropDown1,
|
||||||
_model.dropDownValue1 ??= ''),
|
optionLabels: reasonsOptionLabels,
|
||||||
options: reasonsJsonList != null &&
|
|
||||||
reasonsJsonList != []
|
|
||||||
? reasonsJsonList
|
|
||||||
.map((e) => e.toString())
|
|
||||||
.toList()
|
|
||||||
: [],
|
|
||||||
optionLabels: PhpGroup.getDadosCall
|
|
||||||
.reasonsMotDescStrList(
|
|
||||||
dropDownGetDadosResponse
|
|
||||||
.jsonBody),
|
|
||||||
onChanged: (val) => safeSetState(
|
onChanged: (val) => safeSetState(
|
||||||
() => _model.dropDownValue1 = val),
|
() => _model.dropDownValue1 = val),
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
|
@ -1163,7 +1092,7 @@ Widget scheduleVisit(BuildContext context,
|
||||||
),
|
),
|
||||||
hintText:
|
hintText:
|
||||||
FFLocalizations.of(context).getText(
|
FFLocalizations.of(context).getText(
|
||||||
'6p3e0bzr' /* Escolha um motivo aqui */,
|
'6p3e0bzr',
|
||||||
),
|
),
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
Icons.keyboard_arrow_down_rounded,
|
Icons.keyboard_arrow_down_rounded,
|
||||||
|
@ -1229,7 +1158,6 @@ Widget scheduleVisit(BuildContext context,
|
||||||
child: FutureBuilder<ApiCallResponse>(
|
child: FutureBuilder<ApiCallResponse>(
|
||||||
future: PhpGroup.getDadosCall.call(),
|
future: PhpGroup.getDadosCall.call(),
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
// Customize what your widget looks like when it's loading.
|
|
||||||
if (!snapshot.hasData) {
|
if (!snapshot.hasData) {
|
||||||
return Center(
|
return Center(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
|
@ -1244,53 +1172,19 @@ Widget scheduleVisit(BuildContext context,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final dropDownGetDadosResponse =
|
final lavelsJsonList = PhpGroup.getDadosCall
|
||||||
snapshot.data!;
|
.levelJsonList(snapshot.data!.jsonBody);
|
||||||
final lavelList = PhpGroup.getDadosCall
|
final lavelsOptionLabels = PhpGroup
|
||||||
.levelJsonList(
|
.getDadosCall
|
||||||
dropDownGetDadosResponse.jsonBody);
|
.levelNACDescricaoStrList(
|
||||||
|
snapshot.data!.jsonBody);
|
||||||
if (_model.dropDownValue2 != '' &&
|
_model.processDropDown2(lavelsJsonList!);
|
||||||
_model.dropDownValue2 != null) {
|
|
||||||
String value =
|
|
||||||
_model.dropDownValue2.toString() ??
|
|
||||||
'';
|
|
||||||
|
|
||||||
if (value.contains('{') &&
|
|
||||||
value.contains('}') &&
|
|
||||||
value.contains(':')) {
|
|
||||||
// log("Valor e um Objeto | Usuário Escolheu o Nivel ${_model.dropDownValue2}");
|
|
||||||
} else {
|
|
||||||
// log("Valor e uma String | Usuário Escolheu o Nivel ${_model.dropDownValue2}");
|
|
||||||
if (lavelList != null &&
|
|
||||||
lavelList.isNotEmpty) {
|
|
||||||
var item = lavelList.where((level) =>
|
|
||||||
level['NAC_DESCRICAO']
|
|
||||||
.toString()
|
|
||||||
.contains(
|
|
||||||
_model.dropDownValue2 ??
|
|
||||||
''));
|
|
||||||
_model.dropDownValue2 =
|
|
||||||
item.firstOrNull.toString() ?? '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return FlutterFlowDropDown<String>(
|
return FlutterFlowDropDown<String>(
|
||||||
controller:
|
controller:
|
||||||
_model.dropDownValueController2 ??=
|
_model.dropDownValueController2,
|
||||||
FormFieldController<String>(
|
options: _model.lavelsDropDown2,
|
||||||
_model.dropDownValue2 ??= ''),
|
optionLabels: lavelsOptionLabels,
|
||||||
options:
|
|
||||||
lavelList != null && lavelList != []
|
|
||||||
? lavelList
|
|
||||||
.map((e) => e.toString())
|
|
||||||
.toList()
|
|
||||||
: [],
|
|
||||||
optionLabels: PhpGroup.getDadosCall
|
|
||||||
.levelNACDescricaoStrList(
|
|
||||||
dropDownGetDadosResponse
|
|
||||||
.jsonBody),
|
|
||||||
onChanged: (val) => safeSetState(
|
onChanged: (val) => safeSetState(
|
||||||
() => _model.dropDownValue2 = val),
|
() => _model.dropDownValue2 = val),
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
|
@ -1309,7 +1203,7 @@ Widget scheduleVisit(BuildContext context,
|
||||||
),
|
),
|
||||||
hintText:
|
hintText:
|
||||||
FFLocalizations.of(context).getText(
|
FFLocalizations.of(context).getText(
|
||||||
'2wun8p6c' /* Escolha um nível de acesso aqu... */,
|
'2wun8p6c',
|
||||||
),
|
),
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
Icons.keyboard_arrow_down_rounded,
|
Icons.keyboard_arrow_down_rounded,
|
||||||
|
@ -1373,7 +1267,7 @@ Widget scheduleVisit(BuildContext context,
|
||||||
20.0, 24.0, 0.0, 24.0),
|
20.0, 24.0, 0.0, 24.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
FFLocalizations.of(context).getText(
|
FFLocalizations.of(context).getText(
|
||||||
'8rk26eg1' /* Visita se encerra após o prime... */,
|
'8rk26eg1',
|
||||||
),
|
),
|
||||||
textAlign: TextAlign.start,
|
textAlign: TextAlign.start,
|
||||||
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
||||||
|
@ -1402,7 +1296,7 @@ Widget scheduleVisit(BuildContext context,
|
||||||
0.0, 0.0, 130.0, 0.0),
|
0.0, 0.0, 130.0, 0.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
FFLocalizations.of(context).getText(
|
FFLocalizations.of(context).getText(
|
||||||
'lgv0q5ht' /* Visita única */,
|
'lgv0q5ht',
|
||||||
),
|
),
|
||||||
textAlign: TextAlign.start,
|
textAlign: TextAlign.start,
|
||||||
style: FlutterFlowTheme.of(context)
|
style: FlutterFlowTheme.of(context)
|
||||||
|
@ -1476,7 +1370,7 @@ Widget scheduleVisit(BuildContext context,
|
||||||
20.0, 0.0, 0.0, 24.0),
|
20.0, 0.0, 0.0, 24.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
FFLocalizations.of(context).getText(
|
FFLocalizations.of(context).getText(
|
||||||
'eftcs67c' /* Você tem alguma observação sob... */,
|
'eftcs67c',
|
||||||
),
|
),
|
||||||
textAlign: TextAlign.start,
|
textAlign: TextAlign.start,
|
||||||
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
||||||
|
@ -1506,7 +1400,7 @@ Widget scheduleVisit(BuildContext context,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
isDense: false,
|
isDense: false,
|
||||||
labelText: FFLocalizations.of(context).getText(
|
labelText: FFLocalizations.of(context).getText(
|
||||||
't0q2vuup' /* Observações da Visita */,
|
't0q2vuup',
|
||||||
),
|
),
|
||||||
labelStyle: FlutterFlowTheme.of(context)
|
labelStyle: FlutterFlowTheme.of(context)
|
||||||
.labelMedium
|
.labelMedium
|
||||||
|
@ -1520,7 +1414,7 @@ Widget scheduleVisit(BuildContext context,
|
||||||
.labelMediumFamily),
|
.labelMediumFamily),
|
||||||
),
|
),
|
||||||
hintText: FFLocalizations.of(context).getText(
|
hintText: FFLocalizations.of(context).getText(
|
||||||
'w18iztdm' /* Escreva as suas observações aq... */,
|
'w18iztdm',
|
||||||
),
|
),
|
||||||
hintStyle: FlutterFlowTheme.of(context)
|
hintStyle: FlutterFlowTheme.of(context)
|
||||||
.labelMedium
|
.labelMedium
|
||||||
|
@ -1623,7 +1517,6 @@ Widget scheduleVisit(BuildContext context,
|
||||||
false) {
|
false) {
|
||||||
context.pop();
|
context.pop();
|
||||||
|
|
||||||
//MILESTONE
|
|
||||||
_model.dropDownValue1 = null;
|
_model.dropDownValue1 = null;
|
||||||
_model.dropDownValue2 = null;
|
_model.dropDownValue2 = null;
|
||||||
_model.dropDownValueController1 =
|
_model.dropDownValueController1 =
|
||||||
|
@ -1701,7 +1594,6 @@ Widget scheduleVisit(BuildContext context,
|
||||||
.primaryBackground,
|
.primaryBackground,
|
||||||
width: 1,
|
width: 1,
|
||||||
),
|
),
|
||||||
// borderRadius: 12,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,19 +1,18 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:hub/backend/api_requests/api_calls.dart';
|
import 'package:hub/backend/api_requests/api_calls.dart';
|
||||||
import 'package:hub/components/templates_components/card_item_template_component/card_item_template_component_widget.dart';
|
import 'package:hub/components/templates_components/card_item_template_component/card_item_template_component_widget.dart';
|
||||||
import 'package:hub/components/templates_components/details_component/details_component_action.dart';
|
|
||||||
import 'package:hub/flutter_flow/flutter_flow_theme.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_util.dart';
|
||||||
import 'package:hub/pages/schedule_complete_visit_page/schedule_complete_visit_page_model.dart';
|
import 'package:hub/pages/schedule_complete_visit_page/schedule_complete_visit_page_model.dart';
|
||||||
import 'package:hub/pages/visit_history_page/visit_history_page_model.dart';
|
import 'package:hub/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart';
|
||||||
import 'package:hub/shared/helpers/db_helper.dart';
|
import 'package:hub/shared/helpers/db_helper.dart';
|
||||||
import 'package:hub/shared/mixins/status_mixin.dart';
|
import 'package:hub/shared/mixins/status_mixin.dart';
|
||||||
import 'package:hub/shared/utils/dialog_util.dart';
|
import 'package:hub/shared/utils/dialog_util.dart';
|
||||||
import 'package:hub/shared/utils/log_util.dart';
|
import 'package:hub/shared/utils/log_util.dart';
|
||||||
import 'package:hub/shared/utils/validator_util.dart';
|
import 'package:hub/shared/utils/validator_util.dart';
|
||||||
|
|
||||||
class VisitHistoryWidget extends StatefulWidget {
|
class VisitHistoryWidget extends ScheduleComplete {
|
||||||
VisitHistoryWidget({Key? key}) : super(key: key);
|
const VisitHistoryWidget();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_VisitHistoryWidgetState createState() => _VisitHistoryWidgetState();
|
_VisitHistoryWidgetState createState() => _VisitHistoryWidgetState();
|
||||||
|
@ -30,7 +29,7 @@ class _VisitHistoryWidgetState extends State<VisitHistoryWidget>
|
||||||
final int _pageSize = 10;
|
final int _pageSize = 10;
|
||||||
bool _hasData = false;
|
bool _hasData = false;
|
||||||
bool _loading = false;
|
bool _loading = false;
|
||||||
late VisitHistoryModel _model;
|
late ScheduleCompleteVisitPageModel _model;
|
||||||
|
|
||||||
late Future<void> _visitFuture;
|
late Future<void> _visitFuture;
|
||||||
List<dynamic> _visitWrap = [];
|
List<dynamic> _visitWrap = [];
|
||||||
|
@ -51,7 +50,7 @@ class _VisitHistoryWidgetState extends State<VisitHistoryWidget>
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
_model = createModel(context, () => VisitHistoryModel());
|
_model = createModel(context, () => ScheduleCompleteVisitPageModel());
|
||||||
_initVariables();
|
_initVariables();
|
||||||
_visitFuture = _fetchVisits();
|
_visitFuture = _fetchVisits();
|
||||||
|
|
||||||
|
@ -272,7 +271,7 @@ class _VisitHistoryWidgetState extends State<VisitHistoryWidget>
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return Dialog(
|
return Dialog(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: buildVisitDetails(
|
child: _model.buildVisitDetails(
|
||||||
item: visitaWrapItem,
|
item: visitaWrapItem,
|
||||||
context: context,
|
context: context,
|
||||||
changeStatusAction: _model.changeStatusAction,
|
changeStatusAction: _model.changeStatusAction,
|
|
@ -1,67 +0,0 @@
|
||||||
import 'package:flutter/src/widgets/framework.dart';
|
|
||||||
import 'package:hub/backend/api_requests/api_calls.dart';
|
|
||||||
import 'package:hub/backend/api_requests/api_manager.dart';
|
|
||||||
import 'package:hub/flutter_flow/flutter_flow_model.dart';
|
|
||||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
|
||||||
import 'package:hub/pages/visit_history_page/visit_history_page_widget.dart';
|
|
||||||
|
|
||||||
class VisitHistoryModel extends FlutterFlowModel<VisitHistoryWidget> {
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
// TODO: implement dispose
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState(BuildContext context) {
|
|
||||||
// TODO: implement initState
|
|
||||||
}
|
|
||||||
|
|
||||||
Future changeStatusAction(
|
|
||||||
BuildContext context,
|
|
||||||
int idDestino,
|
|
||||||
int idVisita,
|
|
||||||
String accessKey,
|
|
||||||
String email,
|
|
||||||
) async {
|
|
||||||
// Navigator.pop(context, true);
|
|
||||||
context.pop(true);
|
|
||||||
|
|
||||||
bool? blockVisitRequest;
|
|
||||||
blockVisitRequest = await visitCancelAction(
|
|
||||||
context,
|
|
||||||
accessKey: accessKey,
|
|
||||||
idDestino: idDestino,
|
|
||||||
idVisita: idVisita,
|
|
||||||
email: email,
|
|
||||||
);
|
|
||||||
if (!context.mounted) return;
|
|
||||||
if (blockVisitRequest == true) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<bool> visitCancelAction(BuildContext context,
|
|
||||||
{required int? idDestino,
|
|
||||||
required int? idVisita,
|
|
||||||
required String? accessKey,
|
|
||||||
required String? email}) async {
|
|
||||||
final ApiCallResponse? response;
|
|
||||||
final CancelaVisita callback = PhpGroup.cancelaVisita;
|
|
||||||
|
|
||||||
response = await callback.call(
|
|
||||||
idDestino: idDestino,
|
|
||||||
idVisita: idVisita,
|
|
||||||
AccessKey: accessKey,
|
|
||||||
UsuEmail: email,
|
|
||||||
DevDesc: '',
|
|
||||||
);
|
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
|
||||||
return !response.jsonBody['error'];
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue