FIX: adicionei o modal de detalhes para visita em aberto
This commit is contained in:
parent
294fe2ffa2
commit
5b1a122f62
|
@ -0,0 +1,50 @@
|
||||||
|
import 'package:flutter/material.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_model.dart';
|
||||||
|
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
||||||
|
import 'package:hub/flutter_flow/internationalization.dart';
|
||||||
|
import 'package:hub/pages/vehicles_on_the_property/vehicles_on_the_property.dart';
|
||||||
|
import 'package:hub/shared/utils/storage_util.dart';
|
||||||
|
|
||||||
|
class VisitsModel extends FlutterFlowModel<VehicleOnTheProperty> {
|
||||||
|
static VisitsModel? _instance = VisitsModel._internal();
|
||||||
|
VisitsModel._internal();
|
||||||
|
factory VisitsModel() => _instance ?? VisitsModel._internal();
|
||||||
|
static void resetInstance() => _instance = null;
|
||||||
|
|
||||||
|
dynamic item;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState(BuildContext context) {
|
||||||
|
resetInstance();
|
||||||
|
|
||||||
|
initAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {}
|
||||||
|
|
||||||
|
Future<void> initAsync() async {}
|
||||||
|
|
||||||
|
Widget buildVisitDetails({
|
||||||
|
required dynamic item,
|
||||||
|
required BuildContext context,
|
||||||
|
required VisitsModel model,
|
||||||
|
}) {
|
||||||
|
return DetailsComponentWidget(
|
||||||
|
buttons: [],
|
||||||
|
labelsHashMap: Map<String, String>.from({
|
||||||
|
if (item['VTA_VALIDADE'] != null && item['VTA_VALIDADE'] != '') '${FFLocalizations.of(context).getVariableText(ptText: "Validade", enText: "Validity")}:': item['VTA_VALIDADE'].toString().toUpperCase(),
|
||||||
|
if (item['VTA_DTFIM'] != null && item['VTA_DTFIM'] != '') '${FFLocalizations.of(context).getVariableText(ptText: "Data de Fim", enText: "End Date")}:': item['VTA_DTFIM'].toString().toUpperCase(),
|
||||||
|
if (item['VTA_DTINICIO'] != null && item['VTA_DTINICIO'] != '') '${FFLocalizations.of(context).getVariableText(ptText: "Data de Início", enText: "Start Date")}:': item['VTA_DTINICIO'].toString().toUpperCase(),
|
||||||
|
if (item['VTA_NOME'] != null && item['VTA_NOME'] != '') '${FFLocalizations.of(context).getVariableText(ptText: "Nome", enText: "Name")}:': item['VTA_NOME'].toString().toUpperCase(),
|
||||||
|
if (item['VTA_UNICA'] != null && item['VTA_UNICA'] != '') '${FFLocalizations.of(context).getVariableText(ptText: "Única", enText: "Unique")}:': item['VTA_UNICA'].toString().toUpperCase(),
|
||||||
|
}),
|
||||||
|
imagePath: 'https://freaccess.com.br/freaccess/Images/Clients/${StorageUtil().cliUUID}.png',
|
||||||
|
statusHashMap: [
|
||||||
|
if (item['MOT_DESCRICAO'] != null) Map<String, Color>.from({item['MOT_DESCRICAO'].toString().toUpperCase(): FlutterFlowTheme.of(context).primary}),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,7 +5,7 @@ import 'package:hub/components/templates_components/card_item_template_component
|
||||||
import 'package:hub/flutter_flow/flutter_flow_icon_button.dart';
|
import 'package:hub/flutter_flow/flutter_flow_icon_button.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/vehicles_on_the_property/vehicle_model.dart';
|
import 'package:hub/pages/visits_on_the_property/model.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/storage_util.dart';
|
import 'package:hub/shared/utils/storage_util.dart';
|
||||||
|
@ -24,7 +24,7 @@ class _VisitsOnThePropertyState extends State<VisitsOnTheProperty> with TickerPr
|
||||||
bool _hasData = false;
|
bool _hasData = false;
|
||||||
bool _loading = false;
|
bool _loading = false;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
late final VehicleModel model;
|
late final VisitsModel model;
|
||||||
|
|
||||||
late Future<void> _visitsFuture;
|
late Future<void> _visitsFuture;
|
||||||
List<dynamic> _visitsList = [];
|
List<dynamic> _visitsList = [];
|
||||||
|
@ -32,7 +32,7 @@ class _VisitsOnThePropertyState extends State<VisitsOnTheProperty> with TickerPr
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
model = createModel(context, () => VehicleModel());
|
model = createModel(context, () => VisitsModel());
|
||||||
_visitsFuture = _fetchVisits();
|
_visitsFuture = _fetchVisits();
|
||||||
|
|
||||||
_scrollController = ScrollController()
|
_scrollController = ScrollController()
|
||||||
|
@ -209,7 +209,7 @@ class _VisitsOnThePropertyState extends State<VisitsOnTheProperty> with TickerPr
|
||||||
labelsHashMap: {
|
labelsHashMap: {
|
||||||
'${FFLocalizations.of(context).getVariableText(ptText: "Nome", enText: "Name")}:': uItem['VTA_NOME'] ?? '',
|
'${FFLocalizations.of(context).getVariableText(ptText: "Nome", enText: "Name")}:': uItem['VTA_NOME'] ?? '',
|
||||||
'${FFLocalizations.of(context).getVariableText(ptText: "Validade", enText: "Valids")}:': uItem['VTA_VALIDADE'] ?? '',
|
'${FFLocalizations.of(context).getVariableText(ptText: "Validade", enText: "Valids")}:': uItem['VTA_VALIDADE'] ?? '',
|
||||||
'${FFLocalizations.of(context).getVariableText(ptText: "Entrada", enText: "Entrada")}:': uItem['VTA_DTINICIO'] ?? '',
|
'${FFLocalizations.of(context).getVariableText(ptText: "Motivo", enText: "Reason")}:': uItem['MOT_DESCRICAO'][0].toUpperCase() + uItem['MOT_DESCRICAO'].substring(1).toLowerCase(),
|
||||||
if (uItem['VTA_DTFIM'] != '') '${FFLocalizations.of(context).getVariableText(ptText: "Saída", enText: "Exit")}:': uItem['VTA_DTFIM'] ?? '',
|
if (uItem['VTA_DTFIM'] != '') '${FFLocalizations.of(context).getVariableText(ptText: "Saída", enText: "Exit")}:': uItem['VTA_DTFIM'] ?? '',
|
||||||
},
|
},
|
||||||
statusHashMap: [
|
statusHashMap: [
|
||||||
|
@ -242,7 +242,35 @@ class _VisitsOnThePropertyState extends State<VisitsOnTheProperty> with TickerPr
|
||||||
): FlutterFlowTheme.of(context).warning,
|
): FlutterFlowTheme.of(context).warning,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
onTapCardItemAction: () async {},
|
onTapCardItemAction: () async {
|
||||||
|
await showDialog(
|
||||||
|
useSafeArea: true,
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return Dialog(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: model.buildVisitDetails(
|
||||||
|
item: uItem,
|
||||||
|
context: context,
|
||||||
|
model: model,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
).whenComplete(() {
|
||||||
|
safeSetState(() {
|
||||||
|
_pageNumber = 1;
|
||||||
|
_visitsList = [];
|
||||||
|
_visitsFuture = _fetchVisits().then((value) => value!.jsonBody['pets'] ?? []);
|
||||||
|
});
|
||||||
|
}).catchError((e, s) {
|
||||||
|
DialogUtil.errorDefault(context);
|
||||||
|
LogUtil.requestAPIFailed("proccessRequest.php", "", "Consulta de Pets", e, s);
|
||||||
|
safeSetState(() {
|
||||||
|
_hasData = false;
|
||||||
|
_loading = false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue