Merge branch 'develop' into fix/not_message

This commit is contained in:
Ivan Antunes 2024-08-14 09:41:22 -03:00
commit d851fd9661
8 changed files with 276 additions and 437 deletions

View File

@ -498,57 +498,17 @@ class NotificationHandler {
FlutterFlowIconButton(
icon: const Icon(Icons.close),
onPressed: () async {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(
showAlertDialog(
context,
FFLocalizations.of(context).getVariableText(
ptText: 'Bloquear Visita',
enText: 'Block Visit',
),
),
content: Text(
FFLocalizations.of(context).getVariableText(
ptText:
'Você tem certeza que deseja bloquear essa visita?',
enText:
'Are you sure you want to block this visit?',
),
),
backgroundColor:
FlutterFlowTheme.of(context).primaryBackground,
actions: [
FFButtonWidget(
text: FFLocalizations.of(context).getVariableText(
enText: 'No',
ptText: 'Não',
),
onPressed: () {
Navigator.pop(context);
},
options: FFButtonOptions(
width: 100,
height: 40,
color: FlutterFlowTheme.of(context)
.primaryBackground,
textStyle: TextStyle(
color: FlutterFlowTheme.of(context)
.primaryText,
),
borderSide: BorderSide(
color: FlutterFlowTheme.of(context)
.primaryBackground,
width: 1,
),
borderRadius: BorderRadius.circular(10)),
),
FFButtonWidget(
text: FFLocalizations.of(context).getVariableText(
enText: 'Yes',
ptText: 'Sim',
),
onPressed: () async {
enText: 'Are you sure you want to block this visit?',
), () async {
await answersRequest.call(
context,
message['referencia'].toString(),
@ -556,26 +516,6 @@ class NotificationHandler {
'Mensagem',
message['idVisitante'].toString(),
);
},
options: FFButtonOptions(
width: 100,
height: 40,
color: FlutterFlowTheme.of(context)
.primaryBackground,
textStyle: TextStyle(
color:
FlutterFlowTheme.of(context).primaryText,
),
borderSide: BorderSide(
color: FlutterFlowTheme.of(context)
.primaryBackground,
width: 1,
),
borderRadius: BorderRadius.circular(10),
),
),
],
);
});
},
),

View File

@ -1,4 +1,4 @@
import 'dart:math';
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:hub/actions/actions.dart';
@ -10,6 +10,7 @@ import 'package:hub/flutter_flow/flutter_flow_util.dart';
import 'package:hub/flutter_flow/flutter_flow_widgets.dart';
import 'package:hub/flutter_flow/internationalization.dart';
import 'package:hub/flutter_flow/nav/nav.dart';
import 'package:hub/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart';
import 'package:rxdart/rxdart.dart';
import 'package:share_plus/share_plus.dart';
@ -22,7 +23,11 @@ Widget buildDetails(
buttons: [
if (getStatus(visitaWrapItem['VAW_STATUS']) ==
status.active) // REJECT ACTION
FlutterFlowIconButton(
FFButtonWidget(
text: FFLocalizations.of(context).getVariableText(
ptText: 'Cancelar',
enText: 'Cancel',
),
icon: const Icon(Icons.close),
onPressed: () async {
showAlertDialog(
@ -77,6 +82,20 @@ Widget buildDetails(
});
});
},
options: FFButtonOptions(
width: 130,
height: 40,
color: FlutterFlowTheme.of(context).primaryBackground,
elevation: 0,
textStyle: TextStyle(
color: FlutterFlowTheme.of(context).primaryText,
),
borderSide: BorderSide(
color: FlutterFlowTheme.of(context).primaryBackground,
width: 1,
),
// borderRadius: 12,
),
),
if (getStatus(visitaWrapItem['VAW_STATUS']) !=
status.active) // RECALL ACTION
@ -89,19 +108,17 @@ Widget buildDetails(
onPressed: () async {
Navigator.pop(context);
Navigator.pop(context);
context.pushNamed(
'scheduleCompleteVisitPage',
queryParameters: {
'visitorStrList': serializeParam(
visitaWrapItem['VTE_DOCUMENTO'],
ParamType.String,
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ScheduleCompleteVisitPageWidget(
dropdownValue1: visitaWrapItem['MOT_DESCRICAO'],
dropdownValue2: visitaWrapItem['NAC_DESCRICAO'],
visitorJsonList: [visitaWrapItem],
visitorStrList: visitaWrapItem['VTE_DOCUMENTO'],
)
),
'visitorJsonList': serializeParam(
[visitaWrapItem],
ParamType.JSON,
isList: true,
),
}.withoutNulls,
);
},
options: FFButtonOptions(
@ -121,7 +138,11 @@ Widget buildDetails(
),
if (getStatus(visitaWrapItem['VAW_STATUS']) ==
status.active) // SHARE ACTION
FlutterFlowIconButton(
FFButtonWidget(
text: FFLocalizations.of(context).getVariableText(
ptText: 'Compartilhar',
enText: 'Share',
),
icon: const Icon(Icons.share),
onPressed: () async {
Share.share('''
@ -134,6 +155,20 @@ Olá, \*${visitaWrapItem['VTE_NOME']}\*! Você foi convidado para \*${visitaWrap
URL do Convite: https://visita.freaccess.com.br/${visitaWrapItem['VAW_ID']}/${visitaWrapItem['CLI_ID']}/${visitaWrapItem['VAW_CHAVE']}
''');
},
options: FFButtonOptions(
width: 130,
height: 40,
color: FlutterFlowTheme.of(context).primaryBackground,
elevation: 0,
textStyle: TextStyle(
color: FlutterFlowTheme.of(context).primaryText,
),
borderSide: BorderSide(
color: FlutterFlowTheme.of(context).primaryBackground,
width: 1,
),
// borderRadius: 12,
),
),
],
labelsHashMap: Map<String, String>.from({

View File

@ -237,10 +237,8 @@ class _RegisiterVistorTemplateComponentWidgetState
),
onChanged: (value) {
_model.debounce(() async {
log('data');
var data = await _model.getVisitanteByDocument(
value, context);
log('data: $data');
setState(() {
_isVisitorRegistered = data;
});

View File

@ -37,7 +37,7 @@ class _VisitorSearchModalTemplateComponentWidgetState
late VisitorSearchModalTemplateComponentModel _model;
@override
void setState(VoidCallback callback) {
safeSetState(VoidCallback callback) {
super.setState(callback);
_model.onUpdate();
}
@ -88,7 +88,7 @@ class _VisitorSearchModalTemplateComponentWidgetState
focusNode: _model.textFieldFocusNode,
onFieldSubmitted: (_) async {
await addVisitor(context);
setState(() {});
safeSetState(() {});
},
autofocus: false,
textInputAction: TextInputAction.done,
@ -356,7 +356,7 @@ class _VisitorSearchModalTemplateComponentWidgetState
onPressed: () async {
_model.removeFromVisitors(
visitorItem);
setState(() {});
safeSetState(() {});
},
),
],
@ -391,7 +391,7 @@ class _VisitorSearchModalTemplateComponentWidgetState
? () async {
await addVisitor(context);
setState(() {});
safeSetState(() {});
}
: () async {
await sendVisitors(context);
@ -437,7 +437,7 @@ class _VisitorSearchModalTemplateComponentWidgetState
],
),
const SizedBox(
height: 10.0,
height: 20.0,
)
],
),
@ -456,7 +456,7 @@ class _VisitorSearchModalTemplateComponentWidgetState
}
Future<void> addVisitor(BuildContext context) async {
setState(() {
safeSetState(() {
_model.textController?.text = _model.textController.text;
_model.textController?.selection =
TextSelection.collapsed(offset: _model.textController!.text.length);
@ -472,13 +472,19 @@ class _VisitorSearchModalTemplateComponentWidgetState
if (PhpGroup.getVisitorByDocCall.vistanteId(
(_model.getVisitorByDoc?.jsonBody ?? ''),
) !=
'0') {
'0' &&
PhpGroup.getVisitorByDocCall
.error((_model.getVisitorByDoc?.jsonBody ?? '')) ==
false &&
PhpGroup.getVisitorByDocCall
.vistanteId((_model.getVisitorByDoc?.jsonBody ?? '')) !=
null) {
_model.addToVisitors(PhpGroup.getVisitorByDocCall.visitante(
(_model.getVisitorByDoc?.jsonBody ?? ''),
));
setState(() {});
safeSetState(() {});
_model.addToDocs(_model.textController.text);
setState(() {});
safeSetState(() {});
} else {
await showAdaptiveDialog(
useSafeArea: true,
@ -491,7 +497,6 @@ class _VisitorSearchModalTemplateComponentWidgetState
);
},
).then((value) => safeSetState(() {
log('value: $value');
if (value != null) {
addVisitor(context);
}

View File

@ -53,7 +53,7 @@ class _LiberationHistoryWidgetState extends State<LiberationHistoryWidget> {
void onUpdate(BuildContext context) {
_model.clearGetLiberationsCache();
setState(() {});
safeSetState(() {});
}
@override
@ -364,181 +364,31 @@ Widget liberationHistoryItemCard(
FlutterFlowIconButton(
icon: const Icon(Icons.done),
onPressed: () async {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(
FFLocalizations.of(context).getVariableText(
ptText: 'Aprovar Visita',
enText: 'Approve Visit',
),
),
content: Text(
FFLocalizations.of(context).getVariableText(
ptText:
'Você tem certeza que deseja aprovar essa visita?',
enText:
'Are you sure you want to approve this visit?',
),
),
backgroundColor: FlutterFlowTheme.of(context)
.primaryBackground,
actions: [
FFButtonWidget(
text: FFLocalizations.of(context)
.getVariableText(
enText: 'No',
ptText: 'Não',
),
onPressed: () {
Navigator.pop(context);
},
options: FFButtonOptions(
width: 100,
height: 40,
color: FlutterFlowTheme.of(context)
.primaryBackground,
textStyle: TextStyle(
color: FlutterFlowTheme.of(context)
.primaryText,
),
borderSide: BorderSide(
color: FlutterFlowTheme.of(context)
.primaryBackground,
width: 1,
),
borderRadius: BorderRadius.circular(10)),
),
FFButtonWidget(
text: FFLocalizations.of(context)
.getVariableText(
enText: 'Yes',
ptText: 'Sim',
),
onPressed: () async {
Navigator.pop(context);
Navigator.pop(context);
await answersRequest
.call(
context,
liberationHistoryItem['NOT_ID']
.toString(),
liberationHistoryItem['NOT_ID'].toString(),
'L',
'Mensagem',
liberationHistoryItem['VTE_ID']
.toString(),
liberationHistoryItem['VTE_ID'].toString(),
)
.then((value) {});
},
options: FFButtonOptions(
width: 100,
height: 40,
color: FlutterFlowTheme.of(context)
.primaryBackground,
textStyle: TextStyle(
color: FlutterFlowTheme.of(context)
.primaryText,
),
borderSide: BorderSide(
color: FlutterFlowTheme.of(context)
.primaryBackground,
width: 1,
),
borderRadius: BorderRadius.circular(10),
),
),
],
);
});
},
),
if (liberationHistoryItem['NOT_STATUS'] == 'S')
FlutterFlowIconButton(
icon: const Icon(Icons.close),
onPressed: () async {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(
FFLocalizations.of(context).getVariableText(
ptText: 'Bloquear Visita',
enText: 'Block Visit',
),
),
content: Text(
FFLocalizations.of(context).getVariableText(
ptText:
'Você tem certeza que deseja bloquear essa visita?',
enText:
'Are you sure you want to block this visit?',
),
),
backgroundColor: FlutterFlowTheme.of(context)
.primaryBackground,
actions: [
FFButtonWidget(
text: FFLocalizations.of(context)
.getVariableText(
enText: 'No',
ptText: 'Não',
),
onPressed: () {
Navigator.pop(context);
},
options: FFButtonOptions(
width: 100,
height: 40,
color: FlutterFlowTheme.of(context)
.primaryBackground,
textStyle: TextStyle(
color: FlutterFlowTheme.of(context)
.primaryText,
),
borderSide: BorderSide(
color: FlutterFlowTheme.of(context)
.primaryBackground,
width: 1,
),
borderRadius: BorderRadius.circular(10)),
),
FFButtonWidget(
text: FFLocalizations.of(context)
.getVariableText(
enText: 'Yes',
ptText: 'Sim',
),
onPressed: () async {
await answersRequest.call(
.then((value) {
if (value) {
return showSnackbar(
context,
liberationHistoryItem['NOT_ID']
.toString(),
'B',
'Mensagem',
liberationHistoryItem['VTE_ID']
.toString(),
);
},
options: FFButtonOptions(
width: 100,
height: 40,
color: FlutterFlowTheme.of(context)
.primaryBackground,
textStyle: TextStyle(
color: FlutterFlowTheme.of(context)
.primaryText,
),
borderSide: BorderSide(
color: FlutterFlowTheme.of(context)
.primaryBackground,
width: 1,
),
borderRadius: BorderRadius.circular(10),
),
),
],
);
FFLocalizations.of(context).getVariableText(
enText: 'Successfully resolved visit',
ptText: 'Visita resolvida com sucesso'),
false);
} else {
return showSnackbar(
context,
FFLocalizations.of(context).getVariableText(
enText: 'Error resolving visit',
ptText: 'Erro ao resolver visita'),
true);
}
});
},
),
@ -567,9 +417,6 @@ Widget liberationHistoryItemCard(
],
imagePath:
'https://freaccess.com.br/freaccess/getImage.php?cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=${liberationHistoryItem['VTE_ID'] ?? ''}&tipo=E',
// changeStatusAction: answersRequest,
// vteDocument: liberationHistoryItem['VTE_DOCUMENTO'],
),
);
},
@ -580,7 +427,12 @@ Widget liberationHistoryItemCard(
_pushNotificationService.onMessageReceived.listen((received) {
if (received.data['click_action'] == 'cancel_request') {
_pushNotificationService.dispose();
snackbar(context, opt: true);
showSnackbar(
context,
FFLocalizations.of(context).getVariableText(
enText: 'Successfully resolved visit',
ptText: 'Visita resolvida com sucesso'),
false);
context.pushReplacementNamed(
'liberationHistory',
extra: <String, dynamic>{

View File

@ -20,10 +20,12 @@ class MessageHistoryPageWidget extends StatefulWidget {
const MessageHistoryPageWidget({super.key});
@override
State<MessageHistoryPageWidget> createState() => _MessageHistoryPageWidgetState();
State<MessageHistoryPageWidget> createState() =>
_MessageHistoryPageWidgetState();
}
class _MessageHistoryPageWidgetState extends State<MessageHistoryPageWidget> with TickerProviderStateMixin {
class _MessageHistoryPageWidgetState extends State<MessageHistoryPageWidget>
with TickerProviderStateMixin {
late MessageHistoryPageModel _model;
final scaffoldKey = GlobalKey<ScaffoldState>();
@ -47,13 +49,17 @@ class _MessageHistoryPageWidgetState extends State<MessageHistoryPageWidget> wit
_messageFuture = fetchMessage();
_scrollController = ScrollController()..addListener(() {
if (_scrollController.position.atEdge && _scrollController.position.pixels != 0) {
_scrollController = ScrollController()
..addListener(() {
if (_scrollController.position.atEdge &&
_scrollController.position.pixels != 0) {
_loadMore();
}
});
_model.tabBarController = TabController(vsync: this, length: 3, initialIndex: 0)..addListener(() {
_model.tabBarController =
TabController(vsync: this, length: 3, initialIndex: 0)
..addListener(() {
if (_model.tabBarController?.index == 0) {
_destinyType = "P";
} else if (_model.tabBarController?.index == 1) {
@ -80,7 +86,7 @@ class _MessageHistoryPageWidgetState extends State<MessageHistoryPageWidget> wit
void onUpdate(BuildContext context) {
_model.clearGetLiberationsCache();
setState(() {});
safeSetState(() {});
}
@override
@ -129,7 +135,8 @@ class _MessageHistoryPageWidgetState extends State<MessageHistoryPageWidget> wit
return null;
} catch (e, s) {
DialogUtil.errorDefault(context);
LogUtil.requestAPIFailed("proccessRequest.php", "", "Consulta de Mensagems", e, s);
LogUtil.requestAPIFailed(
"proccessRequest.php", "", "Consulta de Mensagems", e, s);
setState(() {
_hasData = false;
_loading = false;
@ -232,12 +239,9 @@ class _MessageHistoryPageWidgetState extends State<MessageHistoryPageWidget> wit
mainAxisSize: MainAxisSize.max,
children: [
Center(
child: Text(
FFLocalizations.of(context).getVariableText(
child: Text(FFLocalizations.of(context).getVariableText(
ptText: "Nenhuma mensagem encontrada!",
enText: "No message found"
)
),
enText: "No message found")),
)
],
),
@ -255,8 +259,7 @@ class _MessageHistoryPageWidgetState extends State<MessageHistoryPageWidget> wit
itemBuilder: (context, index) {
final item = _messageWrap[index];
return _item(context, item);
}
);
});
},
),
),
@ -280,7 +283,8 @@ class _MessageHistoryPageWidgetState extends State<MessageHistoryPageWidget> wit
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
FFLocalizations.of(context).getVariableText(ptText: "Não há mais dados.", enText: "No more data."),
FFLocalizations.of(context).getVariableText(
ptText: "Não há mais dados.", enText: "No more data."),
),
duration: const Duration(seconds: 3),
backgroundColor: FlutterFlowTheme.of(context).primary,
@ -288,7 +292,6 @@ class _MessageHistoryPageWidgetState extends State<MessageHistoryPageWidget> wit
);
}
Widget _item(BuildContext context, dynamic jsonBody) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 15),
@ -340,7 +343,8 @@ class _MessageHistoryPageWidgetState extends State<MessageHistoryPageWidget> wit
padding: const EdgeInsets.only(left: 5),
child: Icon(
Icons.history,
color: FlutterFlowTheme.of(context).customColor6,
color:
FlutterFlowTheme.of(context).customColor6,
size: 15,
),
),
@ -366,7 +370,8 @@ class _MessageHistoryPageWidgetState extends State<MessageHistoryPageWidget> wit
padding: const EdgeInsets.only(left: 5),
child: Icon(
Icons.message,
color: FlutterFlowTheme.of(context).customColor6,
color:
FlutterFlowTheme.of(context).customColor6,
size: 15,
),
),
@ -388,7 +393,4 @@ class _MessageHistoryPageWidgetState extends State<MessageHistoryPageWidget> wit
),
));
}
}

View File

@ -30,10 +30,14 @@ import 'package:provider/provider.dart';
class ScheduleCompleteVisitPageWidget extends StatefulWidget {
const ScheduleCompleteVisitPageWidget({
super.key,
this.dropdownValue1,
this.dropdownValue2,
this.visitorStrList,
this.visitorJsonList,
});
final String? dropdownValue1;
final String? dropdownValue2;
final String? visitorStrList;
final List<dynamic>? visitorJsonList;
@ -60,10 +64,7 @@ class _ScheduleCompleteVisitPageWidgetState
// On page load action.
SchedulerBinding.instance.addPostFrameCallback((_) async {
if ((widget.visitorStrList != null && widget.visitorStrList != '') &&
((widget.visitorJsonList != null &&
(widget.visitorJsonList)!.isNotEmpty) !=
null)) {
if ((widget.visitorStrList != null && widget.visitorStrList != '') && ((widget.visitorJsonList != null && (widget.visitorJsonList)!.isNotEmpty) != null)) {
_model.visitorJsonList = widget.visitorJsonList!
.where((e) =>
widget.visitorStrList ==
@ -75,17 +76,25 @@ class _ScheduleCompleteVisitPageWidgetState
.toList()
.cast<dynamic>();
_model.visitorStrList = widget.visitorStrList!;
setState(() {});
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(
vsync: this,
length: 2,
initialIndex: 0,
)..addListener(() => setState(() {}));
)..addListener(() => safeSetState(() {}));
_model.textController1 ??= TextEditingController();
_model.textFieldFocusNode1 ??= FocusNode();
@ -116,7 +125,7 @@ class _ScheduleCompleteVisitPageWidgetState
if (newItems.isNotEmpty) {
_visitHistoryList.addAll(newItems);
_visitHistoryLoadingIdx++;
setState(() {});
safeSetState(() {});
}
}
@ -146,8 +155,7 @@ class _ScheduleCompleteVisitPageWidgetState
key: scaffoldKey,
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
appBar: appBarScheduleCompleteVisit(context),
body:
bodyScheduleCompleteVisit(context, _model, setState, safeSetState),
body: bodyScheduleCompleteVisit(context, _model, safeSetState),
),
);
}
@ -191,11 +199,8 @@ PreferredSizeWidget appBarScheduleCompleteVisit(BuildContext context) {
);
}
Widget bodyScheduleCompleteVisit(
BuildContext context,
ScheduleCompleteVisitPageModel _model,
Function setState,
Function safeSetState) {
Widget bodyScheduleCompleteVisit(BuildContext context,
ScheduleCompleteVisitPageModel _model, Function safeSetState) {
return SafeArea(
top: true,
child: Column(
@ -237,12 +242,12 @@ Widget bodyScheduleCompleteVisit(
child: TabBarView(
controller: _model.tabBarController,
children: [
scheduleVisit(context, _model, setState, safeSetState),
scheduleVisit(context, _model, safeSetState),
wrapWithModel(
model: _model,
child: VisitHistoryWidget(),
updateCallback: () {
setState(() {});
safeSetState(() {});
},
updateOnChange: true),
],
@ -253,11 +258,8 @@ Widget bodyScheduleCompleteVisit(
);
}
Widget scheduleVisit(
BuildContext context,
ScheduleCompleteVisitPageModel _model,
Function setState,
Function safeSetState) {
Widget scheduleVisit(BuildContext context,
ScheduleCompleteVisitPageModel _model, Function safeSetState) {
return SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.max,
@ -512,7 +514,7 @@ Widget scheduleVisit(
);
});
}
setState(() {
safeSetState(() {
_model.textController1?.text = dateTimeFormat(
'd/M/y H:mm:ss',
_model.datePicked1,
@ -760,7 +762,7 @@ Widget scheduleVisit(
);
});
}
setState(() {
safeSetState(() {
_model.textController2?.text = dateTimeFormat(
'd/M/y H:mm:ss',
_model.datePicked2,
@ -896,7 +898,7 @@ Widget scheduleVisit(
onPressed: () async {
_model.removeFromVisitorJsonList(
visitorListViewItem);
setState(() {});
safeSetState(() {});
},
icon: const Icon(Icons.close),
),
@ -946,13 +948,13 @@ Widget scheduleVisit(
visitorsParam!
.toList()
.cast<dynamic>();
setState(() {});
safeSetState(() {});
},
getDocs: (docsParam) async {
_model.visitorStrList =
strListToStr(
docsParam!.toList());
setState(() {});
safeSetState(() {});
},
),
),
@ -1082,7 +1084,6 @@ Widget scheduleVisit(
atividade: 'getDados',
),
builder: (context, snapshot) {
// Customize what your widget looks like when it's loading.
if (!snapshot.hasData) {
return Center(
child: SizedBox(
@ -1096,37 +1097,30 @@ Widget scheduleVisit(
),
);
}
final dropDownGetDadosResponse =
snapshot.data!;
final reasonsJsonList =
PhpGroup.getDadosCall.reasonsJsonList(
dropDownGetDadosResponse.jsonBody,
);
final dropDownGetDadosResponse = snapshot.data!;
final reasonsJsonList = PhpGroup.getDadosCall.reasonsJsonList(dropDownGetDadosResponse.jsonBody);
if (_model.dropDownValue1 != '' && _model.dropDownValue1 != null) {
String value = _model.dropDownValue1.toString() ?? '';
if (value.contains('{') && value.contains('}') && value.contains(':')) {
// log("Valor e um Objeto | Usuário Escolheu o Motivo ${_model.dropDownValue1}");
} else {
// log("Valor e uma String | Usuário Escolheu o Motivo ${_model.dropDownValue1}");
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>(
fillColor: FlutterFlowTheme.of(context)
.primaryBackground,
controller:
_model.dropDownValueController1 ??=
FormFieldController<String>(
_model.dropDownValue1 ??= '',
),
options: reasonsJsonList != null &&
reasonsJsonList != []
? List<String>.from(
PhpGroup.getDadosCall
.reasonsJsonList(
dropDownGetDadosResponse
.jsonBody,
)!
.map((e) => e.toString())
.toList())
: [],
optionLabels: PhpGroup.getDadosCall
.reasonsMotDescStrList(
dropDownGetDadosResponse.jsonBody,
),
onChanged: (val) => setState(
() => _model.dropDownValue1 = val),
fillColor: FlutterFlowTheme.of(context).primaryBackground,
controller: _model.dropDownValueController1 ??= FormFieldController<String>(_model.dropDownValue1 ??= ''),
options: reasonsJsonList != null && reasonsJsonList != [] ? reasonsJsonList.map((e) => e.toString()).toList() : [],
optionLabels: PhpGroup.getDadosCall.reasonsMotDescStrList(dropDownGetDadosResponse.jsonBody),
onChanged: (val) => safeSetState(() => _model.dropDownValue1 = val),
width: double.infinity,
height: double.infinity,
textStyle: FlutterFlowTheme.of(context)
@ -1228,30 +1222,29 @@ Widget scheduleVisit(
),
);
}
final dropDownGetDadosResponse =
snapshot.data!;
final lavelList =
PhpGroup.getDadosCall.levelJsonList(
dropDownGetDadosResponse.jsonBody,
);
final dropDownGetDadosResponse = snapshot.data!;
final lavelList = PhpGroup.getDadosCall.levelJsonList(dropDownGetDadosResponse.jsonBody);
if (_model.dropDownValue2 != '' && _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>(
controller:
_model.dropDownValueController2 ??=
FormFieldController<String>(
_model.dropDownValue2 ??= '',
),
options:
lavelList != null && lavelList != []
? List<String>.from(lavelList!
.map((e) => e.toString())
.toList())
: [],
optionLabels: PhpGroup.getDadosCall
.levelNACDescricaoStrList(
dropDownGetDadosResponse.jsonBody,
),
onChanged: (val) => setState(
() => _model.dropDownValue2 = val),
controller: _model.dropDownValueController2 ??= FormFieldController<String>(_model.dropDownValue2 ??= ''),
options: lavelList != null && lavelList != [] ? lavelList.map((e) => e.toString()).toList() : [],
optionLabels: PhpGroup.getDadosCall.levelNACDescricaoStrList(dropDownGetDadosResponse.jsonBody),
onChanged: (val) => safeSetState(() => _model.dropDownValue2 = val),
width: double.infinity,
height: double.infinity,
textStyle: FlutterFlowTheme.of(context)
@ -1298,7 +1291,7 @@ Widget scheduleVisit(
),
],
),
if (_model.dropDownValue1 == '')
if (_model.dropDownValue2 == '')
Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.start,
@ -1381,7 +1374,7 @@ Widget scheduleVisit(
Switch.adaptive(
value: _model.switchValue!,
onChanged: (newValue) async {
setState(() => _model.switchValue = newValue);
safeSetState(() => _model.switchValue = newValue);
},
applyCupertinoTheme: false,
focusColor: FlutterFlowTheme.of(context).primary,
@ -1559,7 +1552,6 @@ Widget scheduleVisit(
),
onPressed: _model.isValid()
? () async {
log(_model.dropDownValue1.toString());
await showDialog(
context: context,
@ -1589,10 +1581,14 @@ Widget scheduleVisit(
// ),
child: DetailsComponentWidget(
buttons: [
FlutterFlowIconButton(
FFButtonWidget(
text: FFLocalizations.of(context)
.getVariableText(
enText: 'Done',
ptText: 'Confirmar',
),
icon: const Icon(Icons.done),
onPressed: () async {
log('visitorStrList ${_model.visitorStrList}');
showAlertDialog(
context,
FFLocalizations.of(context)
@ -1657,9 +1653,26 @@ Widget scheduleVisit(
}
});
setState(() {});
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,
),
),
],
imagePath:

View File

@ -45,12 +45,10 @@ class _VisitHistoryWidgetState extends State<VisitHistoryWidget> {
),
);
log('API response: ${response.jsonBody}');
var newVisits = response.jsonBody['visitas']
as List<dynamic>?; // Ajuste conforme a estrutura da resposta
if (newVisits != null && newVisits.isNotEmpty) {
setState(() {
safeSetState(() {
visitaWrap.addAll(newVisits);
});
return response;
@ -95,8 +93,6 @@ class _VisitHistoryWidgetState extends State<VisitHistoryWidget> {
);
}
log('[A] - ${visitaWrap.length.toString()}');
return ListView.builder(
itemCount: visitaWrap.length + 1,
shrinkWrap: true,
@ -114,7 +110,6 @@ class _VisitHistoryWidgetState extends State<VisitHistoryWidget> {
}
final visitaWrapItem = visitaWrap[index];
log('[B] - ${visitaWrap.length.toString()}');
return CardItemTemplateComponentWidget(
imagePath:
@ -183,7 +178,6 @@ class _VisitHistoryWidgetState extends State<VisitHistoryWidget> {
);
},
).whenComplete(() {
log('Dialog closed');
// updateVisitFuture();
_fetchVisits().then((response) {
safeSetState(() {