milestone
This commit is contained in:
parent
1cc481a83e
commit
a07edd0c21
|
@ -74,9 +74,12 @@ class _VehicleHistoryScreenState extends State<VehicleHistoryScreen> {
|
||||||
late final IconData? iconData;
|
late final IconData? iconData;
|
||||||
late final FreCardIcon? cardIcon;
|
late final FreCardIcon? cardIcon;
|
||||||
|
|
||||||
if(isOwner is bool) {
|
if (isOwner is bool) {
|
||||||
iconData = isOwner ? Symbols.no_crash :Symbols.directions_car;
|
iconData = isOwner ? Symbols.no_crash : Symbols.directions_car;
|
||||||
cardIcon = FreCardIcon(height: 50, width: 100, icon: Icon(iconData, size: 80, opticalSize: 10));
|
cardIcon = FreCardIcon(
|
||||||
|
height: 50,
|
||||||
|
width: 100,
|
||||||
|
icon: Icon(iconData, size: 80, opticalSize: 10));
|
||||||
}
|
}
|
||||||
final String? tag = uItem['tag'];
|
final String? tag = uItem['tag'];
|
||||||
final bool containTag = tag.isNotNullAndEmpty;
|
final bool containTag = tag.isNotNullAndEmpty;
|
||||||
|
@ -91,64 +94,68 @@ class _VehicleHistoryScreenState extends State<VehicleHistoryScreen> {
|
||||||
'${FFLocalizations.of(context).getVariableText(ptText: "Tag", enText: "Tag")}:':
|
'${FFLocalizations.of(context).getVariableText(ptText: "Tag", enText: "Tag")}:':
|
||||||
uItem['tag'] ?? '',
|
uItem['tag'] ?? '',
|
||||||
};
|
};
|
||||||
final Map<String, Color>? statusHashMap = await widget.model.generateStatusColorMap(uItem, 2);
|
final Map<String, Color>? statusHashMap =
|
||||||
final List<Map<String, Color>?> statusHashMapList = [await widget.model.generateStatusColorMap(uItem, 2)];
|
await widget.model.generateStatusColorMap(uItem, 2);
|
||||||
|
final List<Map<String, Color>?> statusHashMapList = [
|
||||||
|
await widget.model.generateStatusColorMap(uItem, 2)
|
||||||
|
];
|
||||||
Future<void> onTapCardItemAction() async {
|
Future<void> onTapCardItemAction() async {
|
||||||
final widgetFuture = widget.model.buildVehicleDetails(
|
final widgetFuture = widget.model.buildVehicleDetails(
|
||||||
icon: isOwner is bool ? cardIcon : null,
|
icon: isOwner is bool ? cardIcon : null,
|
||||||
item: uItem,
|
item: uItem,
|
||||||
context: context,
|
context: context,
|
||||||
model: widget.model,
|
model: widget.model,
|
||||||
);
|
);
|
||||||
|
|
||||||
final dialogContent = await widgetFuture;
|
final dialogContent = await widgetFuture;
|
||||||
|
|
||||||
await showDialog(
|
await showDialog(
|
||||||
useSafeArea: true,
|
useSafeArea: true,
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return Dialog(
|
return Dialog(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: dialogContent,
|
child: dialogContent,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
).whenComplete(() {
|
).whenComplete(() {
|
||||||
safeSetState(() {
|
safeSetState(() {
|
||||||
_pageNumber = 1;
|
_pageNumber = 1;
|
||||||
_wrap = [];
|
_wrap = [];
|
||||||
_future = _fetchVisits();
|
_future = _fetchVisits();
|
||||||
});
|
});
|
||||||
}).catchError((e, s) {
|
}).catchError((e, s) {
|
||||||
DialogUtil.errorDefault(context);
|
DialogUtil.errorDefault(context);
|
||||||
LogUtil.requestAPIFailed(
|
LogUtil.requestAPIFailed(
|
||||||
"proccessRequest.php", "", "Consulta de Veículos", e, s);
|
"proccessRequest.php", "", "Consulta de Veículos", e, s);
|
||||||
safeSetState(() {
|
safeSetState(() {
|
||||||
_hasData = false;
|
_hasData = false;
|
||||||
_loading = false;
|
_loading = false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
final statusLinkedHashMap = statusHashMapList
|
|
||||||
|
final statusLinkedHashMap = statusHashMapList
|
||||||
.map((map) => LinkedHashMap<String, Color>.from(map ?? {}))
|
.map((map) => LinkedHashMap<String, Color>.from(map ?? {}))
|
||||||
.toList();
|
.toList();
|
||||||
print('CardItemTemplateComponentWidget: ${statusLinkedHashMap}');
|
final length = statusLinkedHashMap.expand((e) => [e.length]);
|
||||||
|
print('CardItemTemplateComponentWidget: ${length}');
|
||||||
return CardItemTemplateComponentWidget(
|
return CardItemTemplateComponentWidget(
|
||||||
icon: cardIcon,
|
icon: cardIcon,
|
||||||
labelsHashMap: labelsHashMap,
|
labelsHashMap: labelsHashMap,
|
||||||
statusHashMap: statusHashMapList,
|
statusHashMap: statusHashMapList,
|
||||||
onTapCardItemAction: onTapCardItemAction,
|
onTapCardItemAction: onTapCardItemAction,
|
||||||
itemWidthFactor: statusLinkedHashMap!.length == 1 ? 0.25 : 0.50
|
itemWidthFactor: length == 1 ? 0.25 : 0.50,
|
||||||
);
|
);
|
||||||
// double itemWidthFactor = statusHashMap.length == 1 ? 0.5 : 0.5;
|
// double itemWidthFactor = statusHashMap.length == 1 ? 0.5 : 0.5;
|
||||||
// double itemWidthFactor;
|
// double itemWidthFactor;
|
||||||
// if (statusCount >= 3 && statusCount % 3 != 0) {
|
// if (statusCount >= 3 && statusCount % 3 != 0) {
|
||||||
// itemWidthFactor = (index % 3 == 2) ? 0.5 : 0.25;
|
// itemWidthFactor = (index % 3 == 2) ? 0.5 : 0.25;
|
||||||
// } else if (statusCount == 3) {
|
// } else if (statusCount == 3) {
|
||||||
// itemWidthFactor = (index == 2) ? 0.52 : 0.25;
|
// itemWidthFactor = (index == 2) ? 0.52 : 0.25;
|
||||||
// } else {
|
// } else {
|
||||||
// itemWidthFactor = statusCount == 1 ? 0.5 : 0.25;
|
// itemWidthFactor = statusCount == 1 ? 0.5 : 0.25;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<ApiCallResponse?> _fetchVisits() async {
|
Future<ApiCallResponse?> _fetchVisits() async {
|
||||||
|
|
|
@ -61,8 +61,8 @@ class VehicleModel extends FlutterFlowModel<VehiclePage>
|
||||||
final GlobalKey<FormState> updateFormKey = GlobalKey<FormState>();
|
final GlobalKey<FormState> updateFormKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
Future<void> initAsync() async {
|
Future<void> initAsync() async {
|
||||||
|
amountRegister =
|
||||||
amountRegister = await StorageHelper().get(LocalsStorageKey.vehicleAmountRegister.key);
|
await StorageHelper().get(LocalsStorageKey.vehicleAmountRegister.key);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isFormValid(BuildContext context) {
|
bool isFormValid(BuildContext context) {
|
||||||
|
@ -171,7 +171,6 @@ mixin class _BaseVehiclePage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// [_VehicleRegisterScreenModel] is a mixin that contains the business logic of the vehicle register page.
|
/// [_VehicleRegisterScreenModel] is a mixin that contains the business logic of the vehicle register page.
|
||||||
mixin _VehicleRegisterScreenModel on _BaseVehiclePage {
|
mixin _VehicleRegisterScreenModel on _BaseVehiclePage {
|
||||||
Future<void> registerVehicle() async {
|
Future<void> registerVehicle() async {
|
||||||
|
@ -239,18 +238,17 @@ mixin _VehicleUpdateScreenModel on _BaseVehiclePage {
|
||||||
|
|
||||||
/// [_VehicleHistoryScreenModel] is a mixin that contains the business logic of the vehicle history page.
|
/// [_VehicleHistoryScreenModel] is a mixin that contains the business logic of the vehicle history page.
|
||||||
mixin _VehicleHistoryScreenModel on _BaseVehiclePage {
|
mixin _VehicleHistoryScreenModel on _BaseVehiclePage {
|
||||||
|
Future<Map<String, Color>?> generateStatusColorMap(
|
||||||
Future<Map<String, Color>?> generateStatusColorMap(dynamic uItem, int count) async {
|
dynamic uItem, int count) async {
|
||||||
final autoApproval = await StorageHelper().get(LocalsStorageKey.vehicleAutoApproval.key);
|
final autoApproval =
|
||||||
if(autoApproval.toBoolean == true) return null;
|
await StorageHelper().get(LocalsStorageKey.vehicleAutoApproval.key);
|
||||||
|
if (autoApproval.toBoolean == true) return null;
|
||||||
|
|
||||||
final theme = FlutterFlowTheme.of(context);
|
final theme = FlutterFlowTheme.of(context);
|
||||||
final localization = FFLocalizations.of(context);
|
final localization = FFLocalizations.of(context);
|
||||||
|
|
||||||
|
|
||||||
byLanguage(en, pt) => localization.getVariableText(enText: en, ptText: pt);
|
byLanguage(en, pt) => localization.getVariableText(enText: en, ptText: pt);
|
||||||
|
|
||||||
|
|
||||||
final preFixStatusMap = {
|
final preFixStatusMap = {
|
||||||
"APR_CREATE": {
|
"APR_CREATE": {
|
||||||
"text": byLanguage('Awaiting', 'Aguardando'),
|
"text": byLanguage('Awaiting', 'Aguardando'),
|
||||||
|
@ -278,13 +276,12 @@ mixin _VehicleHistoryScreenModel on _BaseVehiclePage {
|
||||||
"text": byLanguage('Inactive', 'Inativo'),
|
"text": byLanguage('Inactive', 'Inativo'),
|
||||||
"color": theme.accent2,
|
"color": theme.accent2,
|
||||||
},
|
},
|
||||||
|
|
||||||
"APR_CREATE": {
|
"APR_CREATE": {
|
||||||
"text": byLanguage('Creation', 'Criação'),
|
"text": byLanguage('Creation', 'Criação'),
|
||||||
"color": theme.success,
|
"color": theme.success,
|
||||||
},
|
},
|
||||||
"APR_DELETE": {
|
"APR_DELETE": {
|
||||||
"text": byLanguage('Deletion', 'Exclusão'),
|
"text": byLanguage('Awaiting Deletion', 'Exclusão'),
|
||||||
"color": theme.warning,
|
"color": theme.warning,
|
||||||
},
|
},
|
||||||
"APR_UPDATE": {
|
"APR_UPDATE": {
|
||||||
|
@ -301,28 +298,31 @@ mixin _VehicleHistoryScreenModel on _BaseVehiclePage {
|
||||||
"text": byLanguage('My Vehicle', 'Meu Veículo'),
|
"text": byLanguage('My Vehicle', 'Meu Veículo'),
|
||||||
"color": theme.primaryText,
|
"color": theme.primaryText,
|
||||||
},
|
},
|
||||||
false: {
|
|
||||||
"text": byLanguage('', ''),
|
|
||||||
"color": theme.accent2,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
final status = uItem['status'];
|
final status = uItem['status'];
|
||||||
final isOwner = uItem['isOwnerVehicle'];
|
final isOwner = uItem['isOwnerVehicle'];
|
||||||
|
|
||||||
if (vehicleStatusMap.containsKey(status)) {
|
if (vehicleStatusMap.containsKey(status)) {
|
||||||
if(count > 1) return {
|
if (count > 1)
|
||||||
if (preFixStatusMap.containsKey(status))
|
return {
|
||||||
preFixStatusMap[status]!['text'] as String: preFixStatusMap[status]!['color'] as Color,
|
// if (preFixStatusMap.containsKey(status))
|
||||||
vehicleStatusMap[status]!['text'] as String: vehicleStatusMap[status]!['color'] as Color,
|
// preFixStatusMap[status]!['text'] as String: preFixStatusMap[status]!['color'] as Color,
|
||||||
// if (ownerStatusMap.containsKey(isOwner) && (status != 'ATI' || status != 'INA'))
|
vehicleStatusMap[status]!['text'] as String:
|
||||||
// ownerStatusMap[isOwner]!['text'] as String: ownerStatusMap[isOwner]!['color'] as Color
|
vehicleStatusMap[status]!['color'] as Color,
|
||||||
};
|
if (ownerStatusMap.containsKey(isOwner) &&
|
||||||
if(status == 'ATI' || status == 'INA') return {
|
(status != 'ATI' || status != 'INA'))
|
||||||
vehicleStatusMap[status]!['text'] as String: vehicleStatusMap[status]!['color'] as Color,
|
ownerStatusMap[isOwner]!['text'] as String:
|
||||||
};
|
ownerStatusMap[isOwner]!['color'] as Color
|
||||||
|
};
|
||||||
|
if (status == 'ATI' || status == 'INA')
|
||||||
|
return {
|
||||||
|
vehicleStatusMap[status]!['text'] as String:
|
||||||
|
vehicleStatusMap[status]!['color'] as Color,
|
||||||
|
};
|
||||||
return {
|
return {
|
||||||
"${preFixStatusMap[status]!['text']} ${vehicleStatusMap[status]!['text']}": vehicleStatusMap[status]!['color'] as Color
|
"${preFixStatusMap[status]!['text']} ${vehicleStatusMap[status]!['text']}":
|
||||||
|
vehicleStatusMap[status]!['color'] as Color
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
|
@ -361,17 +361,16 @@ mixin _VehicleHistoryScreenModel on _BaseVehiclePage {
|
||||||
final cancelIcon = Icon(Icons.close, color: iconButtonColor);
|
final cancelIcon = Icon(Icons.close, color: iconButtonColor);
|
||||||
Future cancelOnPressed() async {
|
Future cancelOnPressed() async {
|
||||||
showAlertDialog(
|
showAlertDialog(
|
||||||
context,
|
context,
|
||||||
FFLocalizations.of(context).getVariableText(
|
FFLocalizations.of(context).getVariableText(
|
||||||
ptText: 'Cancelar Solicitação',
|
ptText: 'Cancelar Solicitação',
|
||||||
enText: 'Cancel Request',
|
enText: 'Cancel Request',
|
||||||
),
|
),
|
||||||
FFLocalizations.of(context).getVariableText(
|
FFLocalizations.of(context).getVariableText(
|
||||||
ptText: 'Você tem certeza que deseja cancelar essa solicitação?',
|
ptText: 'Você tem certeza que deseja cancelar essa solicitação?',
|
||||||
enText: 'Are you sure you want to delete this request?',
|
enText: 'Are you sure you want to delete this request?',
|
||||||
),
|
),
|
||||||
() async => await processCancelRequest(item['status'], item)
|
() async => await processCancelRequest(item['status'], item));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final deleteText = FFLocalizations.of(context)
|
final deleteText = FFLocalizations.of(context)
|
||||||
|
@ -398,14 +397,15 @@ mixin _VehicleHistoryScreenModel on _BaseVehiclePage {
|
||||||
final bool isAPR = item['status'].contains('APR');
|
final bool isAPR = item['status'].contains('APR');
|
||||||
final bool isATI = item['status'].contains('ATI');
|
final bool isATI = item['status'].contains('ATI');
|
||||||
|
|
||||||
if(containStatus) return [
|
if (containStatus)
|
||||||
|
return [
|
||||||
FFButtonWidget(
|
FFButtonWidget(
|
||||||
text: deleteText,
|
text: deleteText,
|
||||||
icon: deleteIcon,
|
icon: deleteIcon,
|
||||||
onPressed: deleteOnPressed,
|
onPressed: deleteOnPressed,
|
||||||
options: buttonOptions,
|
options: buttonOptions,
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
return [
|
return [
|
||||||
if (isAGU && isOwnerVehicle)
|
if (isAGU && isOwnerVehicle)
|
||||||
|
@ -434,15 +434,14 @@ mixin _VehicleHistoryScreenModel on _BaseVehiclePage {
|
||||||
|
|
||||||
Future<void> processDeleteRequest(dynamic item) async {
|
Future<void> processDeleteRequest(dynamic item) async {
|
||||||
log('processDeleteRequest -> item[$item]');
|
log('processDeleteRequest -> item[$item]');
|
||||||
return await PhpGroup.deleteVehicle.call(
|
return await PhpGroup.deleteVehicle
|
||||||
|
.call(
|
||||||
vehicleId: item['vehicleId'],
|
vehicleId: item['vehicleId'],
|
||||||
licensePlate: item['licensePlate'],
|
licensePlate: item['licensePlate'],
|
||||||
model: item['model'],
|
model: item['model'],
|
||||||
color: item['color'],
|
color: item['color'],
|
||||||
)
|
)
|
||||||
.then((value) {
|
.then((value) {
|
||||||
|
|
||||||
|
|
||||||
context.pop(value);
|
context.pop(value);
|
||||||
context.pop(value);
|
context.pop(value);
|
||||||
|
|
||||||
|
@ -460,14 +459,13 @@ mixin _VehicleHistoryScreenModel on _BaseVehiclePage {
|
||||||
// ignore: unrelated_type_equality_checks
|
// ignore: unrelated_type_equality_checks
|
||||||
}
|
}
|
||||||
return showSnackbar(
|
return showSnackbar(
|
||||||
context,
|
context,
|
||||||
FFLocalizations.of(context).getVariableText(
|
FFLocalizations.of(context).getVariableText(
|
||||||
enText: 'Success deleting vehicle',
|
enText: 'Success deleting vehicle',
|
||||||
ptText: 'Succeso ao excluir veículo',
|
ptText: 'Succeso ao excluir veículo',
|
||||||
),
|
),
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
}).catchError((err, stack) {
|
}).catchError((err, stack) {
|
||||||
context.pop();
|
context.pop();
|
||||||
return showSnackbar(
|
return showSnackbar(
|
||||||
|
@ -502,7 +500,7 @@ mixin _VehicleHistoryScreenModel on _BaseVehiclePage {
|
||||||
context.pop(value);
|
context.pop(value);
|
||||||
|
|
||||||
if (value.jsonBody['error'] == true) {
|
if (value.jsonBody['error'] == true) {
|
||||||
final String errorMsg = value.jsonBody['error_msg'] ;
|
final String errorMsg = value.jsonBody['error_msg'];
|
||||||
return showSnackbar(
|
return showSnackbar(
|
||||||
context,
|
context,
|
||||||
FFLocalizations.of(context).getVariableText(
|
FFLocalizations.of(context).getVariableText(
|
||||||
|
@ -512,15 +510,14 @@ mixin _VehicleHistoryScreenModel on _BaseVehiclePage {
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return showSnackbar(
|
return showSnackbar(
|
||||||
context,
|
context,
|
||||||
FFLocalizations.of(context).getVariableText(
|
FFLocalizations.of(context).getVariableText(
|
||||||
enText: 'Success canceling request',
|
enText: 'Success canceling request',
|
||||||
ptText: 'Succeso ao cancelar solicitação',
|
ptText: 'Succeso ao cancelar solicitação',
|
||||||
),
|
),
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
context.pop();
|
context.pop();
|
||||||
return showSnackbar(
|
return showSnackbar(
|
||||||
|
@ -540,17 +537,16 @@ mixin _VehicleHistoryScreenModel on _BaseVehiclePage {
|
||||||
licensePlate: item['licensePlate'],
|
licensePlate: item['licensePlate'],
|
||||||
model: item['model'],
|
model: item['model'],
|
||||||
color: item['color'],
|
color: item['color'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<ApiCallResponse> processCancelUpdateRequest(dynamic item) async {
|
Future<ApiCallResponse> processCancelUpdateRequest(dynamic item) async {
|
||||||
return await PhpGroup.deleteVehicle.call(
|
return await PhpGroup.deleteVehicle.call(
|
||||||
vehicleId: item['vehicleId'],
|
vehicleId: item['vehicleId'],
|
||||||
licensePlate: item['licensePlate'],
|
licensePlate: item['licensePlate'],
|
||||||
model: item['model'],
|
model: item['model'],
|
||||||
color: item['color'],
|
color: item['color'],
|
||||||
|
);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<ApiCallResponse> processCancelCreateRequest(dynamic item) async {
|
Future<ApiCallResponse> processCancelCreateRequest(dynamic item) async {
|
||||||
|
@ -559,7 +555,7 @@ mixin _VehicleHistoryScreenModel on _BaseVehiclePage {
|
||||||
licensePlate: item['licensePlate'],
|
licensePlate: item['licensePlate'],
|
||||||
model: item['model'],
|
model: item['model'],
|
||||||
color: item['color'],
|
color: item['color'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<String, String>> generateLabelsHashMap(dynamic item) async {
|
Future<Map<String, String>> generateLabelsHashMap(dynamic item) async {
|
||||||
|
@ -588,7 +584,6 @@ mixin _VehicleHistoryScreenModel on _BaseVehiclePage {
|
||||||
required VehicleModel model,
|
required VehicleModel model,
|
||||||
required FreCardIcon? icon,
|
required FreCardIcon? icon,
|
||||||
}) async {
|
}) async {
|
||||||
|
|
||||||
final status = await generateStatusColorMap(item, 1);
|
final status = await generateStatusColorMap(item, 1);
|
||||||
final buttons = await generateActionButtons(item);
|
final buttons = await generateActionButtons(item);
|
||||||
final labels = await generateLabelsHashMap(item);
|
final labels = await generateLabelsHashMap(item);
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
|
|
||||||
|
import 'dart:collection';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import 'package:hub/components/atomic_components/shared_components_atoms/custom_input.dart';
|
import 'package:hub/components/atomic_components/shared_components_atoms/custom_input.dart';
|
||||||
|
|
Loading…
Reference in New Issue