checkpoint
This commit is contained in:
parent
268c4c897b
commit
1cc481a83e
|
@ -1,4 +1,5 @@
|
|||
import 'dart:collection';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
@ -68,9 +69,10 @@ class CardItemTemplateComponentWidget extends StatefulWidget {
|
|||
super.key,
|
||||
required this.labelsHashMap,
|
||||
required this.statusHashMap,
|
||||
this.imagePath,
|
||||
this.icon,
|
||||
this.pin,
|
||||
this.imagePath,
|
||||
this.icon,
|
||||
this.pin,
|
||||
this.itemWidthFactor = 0.25,
|
||||
required this.onTapCardItemAction,
|
||||
});
|
||||
|
||||
|
@ -79,6 +81,7 @@ class CardItemTemplateComponentWidget extends StatefulWidget {
|
|||
final String? imagePath;
|
||||
final FreCardIcon? icon;
|
||||
final FreCardPin? pin;
|
||||
final double itemWidthFactor;
|
||||
final Future Function()? onTapCardItemAction;
|
||||
|
||||
@override
|
||||
|
@ -195,19 +198,22 @@ class _CardItemTemplateComponentWidgetState
|
|||
|
||||
List<Widget> _generateStatus() {
|
||||
double limitedBodyTextSize = LimitedFontSizeUtil.getBodyFontSize(context);
|
||||
int statusCount = statusLinkedHashMap.length;
|
||||
double itemWidthFactor = statusCount == 1 ? 0.5 : 0.25;
|
||||
|
||||
|
||||
return statusLinkedHashMap.expand((statusLinked) {
|
||||
|
||||
log('statusHashMap: ${statusLinked.length}');
|
||||
|
||||
return statusLinked.entries.map((entry) {
|
||||
final text = entry.key;
|
||||
final color = entry.value;
|
||||
|
||||
|
||||
|
||||
return Tooltip(
|
||||
message: text,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(5),
|
||||
width: MediaQuery.of(context).size.width * itemWidthFactor,
|
||||
width: MediaQuery.of(context).size.width * widget.itemWidthFactor,
|
||||
decoration: BoxDecoration(
|
||||
color: color,
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
|
|
|
@ -91,57 +91,64 @@ class _VehicleHistoryScreenState extends State<VehicleHistoryScreen> {
|
|||
'${FFLocalizations.of(context).getVariableText(ptText: "Tag", enText: "Tag")}:':
|
||||
uItem['tag'] ?? '',
|
||||
};
|
||||
final List<Map<String, Color>?> statusHashMap = [
|
||||
await widget.model.generateStatusColorMap(uItem, 2)
|
||||
];
|
||||
Future<Future Function()?> onTapCardItemAction() async {
|
||||
await showDialog(
|
||||
useSafeArea: true,
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return Dialog(
|
||||
alignment: Alignment.center,
|
||||
child: FutureBuilder<Widget>(
|
||||
future: widget.model.buildVehicleDetails(
|
||||
icon: isOwner is bool ? cardIcon : null,
|
||||
item: uItem,
|
||||
context: context,
|
||||
model: widget.model,
|
||||
),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
return snapshot.data ?? Container();
|
||||
} else {
|
||||
return Center(child: CircularProgressIndicator());
|
||||
}
|
||||
},
|
||||
));
|
||||
},
|
||||
).whenComplete(() {
|
||||
safeSetState(() {
|
||||
_pageNumber = 1;
|
||||
_wrap = [];
|
||||
_future =
|
||||
_fetchVisits().then((value) => value!.jsonBody['vehicles'] ?? []);
|
||||
});
|
||||
}).catchError((e, s) {
|
||||
DialogUtil.errorDefault(context);
|
||||
LogUtil.requestAPIFailed(
|
||||
"proccessRequest.php", "", "Consulta de Veículos", e, s);
|
||||
safeSetState(() {
|
||||
_hasData = false;
|
||||
_loading = false;
|
||||
});
|
||||
});
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
final Map<String, Color>? statusHashMap = await widget.model.generateStatusColorMap(uItem, 2);
|
||||
final List<Map<String, Color>?> statusHashMapList = [await widget.model.generateStatusColorMap(uItem, 2)];
|
||||
Future<void> onTapCardItemAction() async {
|
||||
final widgetFuture = widget.model.buildVehicleDetails(
|
||||
icon: isOwner is bool ? cardIcon : null,
|
||||
item: uItem,
|
||||
context: context,
|
||||
model: widget.model,
|
||||
);
|
||||
|
||||
final dialogContent = await widgetFuture;
|
||||
|
||||
await showDialog(
|
||||
useSafeArea: true,
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return Dialog(
|
||||
alignment: Alignment.center,
|
||||
child: dialogContent,
|
||||
);
|
||||
},
|
||||
).whenComplete(() {
|
||||
safeSetState(() {
|
||||
_pageNumber = 1;
|
||||
_wrap = [];
|
||||
_future = _fetchVisits();
|
||||
});
|
||||
}).catchError((e, s) {
|
||||
DialogUtil.errorDefault(context);
|
||||
LogUtil.requestAPIFailed(
|
||||
"proccessRequest.php", "", "Consulta de Veículos", e, s);
|
||||
safeSetState(() {
|
||||
_hasData = false;
|
||||
_loading = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
final statusLinkedHashMap = statusHashMapList
|
||||
.map((map) => LinkedHashMap<String, Color>.from(map ?? {}))
|
||||
.toList();
|
||||
print('CardItemTemplateComponentWidget: ${statusLinkedHashMap}');
|
||||
return CardItemTemplateComponentWidget(
|
||||
icon: cardIcon,
|
||||
labelsHashMap: labelsHashMap,
|
||||
statusHashMap: statusHashMap,
|
||||
onTapCardItemAction: onTapCardItemAction);
|
||||
statusHashMap: statusHashMapList,
|
||||
onTapCardItemAction: onTapCardItemAction,
|
||||
itemWidthFactor: statusLinkedHashMap!.length == 1 ? 0.25 : 0.50
|
||||
);
|
||||
// double itemWidthFactor = statusHashMap.length == 1 ? 0.5 : 0.5;
|
||||
// double itemWidthFactor;
|
||||
// if (statusCount >= 3 && statusCount % 3 != 0) {
|
||||
// itemWidthFactor = (index % 3 == 2) ? 0.5 : 0.25;
|
||||
// } else if (statusCount == 3) {
|
||||
// itemWidthFactor = (index == 2) ? 0.52 : 0.25;
|
||||
// } else {
|
||||
// itemWidthFactor = statusCount == 1 ? 0.5 : 0.25;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
Future<ApiCallResponse?> _fetchVisits() async {
|
||||
|
|
|
@ -251,23 +251,14 @@ mixin _VehicleHistoryScreenModel on _BaseVehiclePage {
|
|||
byLanguage(en, pt) => localization.getVariableText(enText: en, ptText: pt);
|
||||
|
||||
|
||||
final preFixStatusMap = {
|
||||
"ATI": {
|
||||
"text": '',
|
||||
"color": theme.success,
|
||||
},
|
||||
"INA": {
|
||||
"text": '',
|
||||
"color": theme.accent2,
|
||||
},
|
||||
|
||||
final preFixStatusMap = {
|
||||
"APR_CREATE": {
|
||||
"text": byLanguage('Awaiting', 'Aguardando'),
|
||||
"color": theme.success,
|
||||
"color": theme.warning,
|
||||
},
|
||||
"APR_DELETE": {
|
||||
"text": byLanguage('Awaiting', 'Aguardando'),
|
||||
"color": theme.error,
|
||||
"color": theme.warning,
|
||||
},
|
||||
"APR_UPDATE": {
|
||||
"text": byLanguage('Awaiting', 'Aguardando'),
|
||||
|
@ -294,7 +285,7 @@ mixin _VehicleHistoryScreenModel on _BaseVehiclePage {
|
|||
},
|
||||
"APR_DELETE": {
|
||||
"text": byLanguage('Deletion', 'Exclusão'),
|
||||
"color": theme.error,
|
||||
"color": theme.warning,
|
||||
},
|
||||
"APR_UPDATE": {
|
||||
"text": byLanguage('Update', 'Atualização'),
|
||||
|
@ -321,12 +312,16 @@ mixin _VehicleHistoryScreenModel on _BaseVehiclePage {
|
|||
|
||||
if (vehicleStatusMap.containsKey(status)) {
|
||||
if(count > 1) return {
|
||||
if (preFixStatusMap.containsKey(status))
|
||||
preFixStatusMap[status]!['text'] as String: preFixStatusMap[status]!['color'] as Color,
|
||||
vehicleStatusMap[status]!['text'] as String: vehicleStatusMap[status]!['color'] as Color,
|
||||
// if (ownerStatusMap.containsKey(isOwner))
|
||||
// if (ownerStatusMap.containsKey(isOwner) && (status != 'ATI' || status != 'INA'))
|
||||
// ownerStatusMap[isOwner]!['text'] as String: ownerStatusMap[isOwner]!['color'] as Color
|
||||
};
|
||||
else return {
|
||||
if(status == 'ATI' || status == 'INA') return {
|
||||
vehicleStatusMap[status]!['text'] as String: vehicleStatusMap[status]!['color'] as Color,
|
||||
};
|
||||
return {
|
||||
"${preFixStatusMap[status]!['text']} ${vehicleStatusMap[status]!['text']}": vehicleStatusMap[status]!['color'] as Color
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue