checkpoint
This commit is contained in:
parent
268c4c897b
commit
1cc481a83e
|
@ -1,4 +1,5 @@
|
||||||
import 'dart:collection';
|
import 'dart:collection';
|
||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
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';
|
||||||
|
@ -71,6 +72,7 @@ class CardItemTemplateComponentWidget extends StatefulWidget {
|
||||||
this.imagePath,
|
this.imagePath,
|
||||||
this.icon,
|
this.icon,
|
||||||
this.pin,
|
this.pin,
|
||||||
|
this.itemWidthFactor = 0.25,
|
||||||
required this.onTapCardItemAction,
|
required this.onTapCardItemAction,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -79,6 +81,7 @@ class CardItemTemplateComponentWidget extends StatefulWidget {
|
||||||
final String? imagePath;
|
final String? imagePath;
|
||||||
final FreCardIcon? icon;
|
final FreCardIcon? icon;
|
||||||
final FreCardPin? pin;
|
final FreCardPin? pin;
|
||||||
|
final double itemWidthFactor;
|
||||||
final Future Function()? onTapCardItemAction;
|
final Future Function()? onTapCardItemAction;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -195,19 +198,22 @@ class _CardItemTemplateComponentWidgetState
|
||||||
|
|
||||||
List<Widget> _generateStatus() {
|
List<Widget> _generateStatus() {
|
||||||
double limitedBodyTextSize = LimitedFontSizeUtil.getBodyFontSize(context);
|
double limitedBodyTextSize = LimitedFontSizeUtil.getBodyFontSize(context);
|
||||||
int statusCount = statusLinkedHashMap.length;
|
|
||||||
double itemWidthFactor = statusCount == 1 ? 0.5 : 0.25;
|
|
||||||
|
|
||||||
return statusLinkedHashMap.expand((statusLinked) {
|
return statusLinkedHashMap.expand((statusLinked) {
|
||||||
|
|
||||||
|
log('statusHashMap: ${statusLinked.length}');
|
||||||
|
|
||||||
return statusLinked.entries.map((entry) {
|
return statusLinked.entries.map((entry) {
|
||||||
final text = entry.key;
|
final text = entry.key;
|
||||||
final color = entry.value;
|
final color = entry.value;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return Tooltip(
|
return Tooltip(
|
||||||
message: text,
|
message: text,
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.all(5),
|
padding: const EdgeInsets.all(5),
|
||||||
width: MediaQuery.of(context).size.width * itemWidthFactor,
|
width: MediaQuery.of(context).size.width * widget.itemWidthFactor,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: color,
|
color: color,
|
||||||
borderRadius: BorderRadius.circular(5),
|
borderRadius: BorderRadius.circular(5),
|
||||||
|
|
|
@ -91,38 +91,32 @@ 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 List<Map<String, Color>?> statusHashMap = [
|
final Map<String, Color>? statusHashMap = 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<Future Function()?> 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(
|
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: FutureBuilder<Widget>(
|
child: dialogContent,
|
||||||
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(() {
|
).whenComplete(() {
|
||||||
safeSetState(() {
|
safeSetState(() {
|
||||||
_pageNumber = 1;
|
_pageNumber = 1;
|
||||||
_wrap = [];
|
_wrap = [];
|
||||||
_future =
|
_future = _fetchVisits();
|
||||||
_fetchVisits().then((value) => value!.jsonBody['vehicles'] ?? []);
|
|
||||||
});
|
});
|
||||||
}).catchError((e, s) {
|
}).catchError((e, s) {
|
||||||
DialogUtil.errorDefault(context);
|
DialogUtil.errorDefault(context);
|
||||||
|
@ -133,15 +127,28 @@ class _VehicleHistoryScreenState extends State<VehicleHistoryScreen> {
|
||||||
_loading = false;
|
_loading = false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return null;
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
final statusLinkedHashMap = statusHashMapList
|
||||||
|
.map((map) => LinkedHashMap<String, Color>.from(map ?? {}))
|
||||||
|
.toList();
|
||||||
|
print('CardItemTemplateComponentWidget: ${statusLinkedHashMap}');
|
||||||
return CardItemTemplateComponentWidget(
|
return CardItemTemplateComponentWidget(
|
||||||
icon: cardIcon,
|
icon: cardIcon,
|
||||||
labelsHashMap: labelsHashMap,
|
labelsHashMap: labelsHashMap,
|
||||||
statusHashMap: statusHashMap,
|
statusHashMap: statusHashMapList,
|
||||||
onTapCardItemAction: onTapCardItemAction);
|
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 {
|
Future<ApiCallResponse?> _fetchVisits() async {
|
||||||
|
|
|
@ -252,22 +252,13 @@ mixin _VehicleHistoryScreenModel on _BaseVehiclePage {
|
||||||
|
|
||||||
|
|
||||||
final preFixStatusMap = {
|
final preFixStatusMap = {
|
||||||
"ATI": {
|
|
||||||
"text": '',
|
|
||||||
"color": theme.success,
|
|
||||||
},
|
|
||||||
"INA": {
|
|
||||||
"text": '',
|
|
||||||
"color": theme.accent2,
|
|
||||||
},
|
|
||||||
|
|
||||||
"APR_CREATE": {
|
"APR_CREATE": {
|
||||||
"text": byLanguage('Awaiting', 'Aguardando'),
|
"text": byLanguage('Awaiting', 'Aguardando'),
|
||||||
"color": theme.success,
|
"color": theme.warning,
|
||||||
},
|
},
|
||||||
"APR_DELETE": {
|
"APR_DELETE": {
|
||||||
"text": byLanguage('Awaiting', 'Aguardando'),
|
"text": byLanguage('Awaiting', 'Aguardando'),
|
||||||
"color": theme.error,
|
"color": theme.warning,
|
||||||
},
|
},
|
||||||
"APR_UPDATE": {
|
"APR_UPDATE": {
|
||||||
"text": byLanguage('Awaiting', 'Aguardando'),
|
"text": byLanguage('Awaiting', 'Aguardando'),
|
||||||
|
@ -294,7 +285,7 @@ mixin _VehicleHistoryScreenModel on _BaseVehiclePage {
|
||||||
},
|
},
|
||||||
"APR_DELETE": {
|
"APR_DELETE": {
|
||||||
"text": byLanguage('Deletion', 'Exclusão'),
|
"text": byLanguage('Deletion', 'Exclusão'),
|
||||||
"color": theme.error,
|
"color": theme.warning,
|
||||||
},
|
},
|
||||||
"APR_UPDATE": {
|
"APR_UPDATE": {
|
||||||
"text": byLanguage('Update', 'Atualização'),
|
"text": byLanguage('Update', 'Atualização'),
|
||||||
|
@ -321,12 +312,16 @@ mixin _VehicleHistoryScreenModel on _BaseVehiclePage {
|
||||||
|
|
||||||
if (vehicleStatusMap.containsKey(status)) {
|
if (vehicleStatusMap.containsKey(status)) {
|
||||||
if(count > 1) return {
|
if(count > 1) return {
|
||||||
|
if (preFixStatusMap.containsKey(status))
|
||||||
preFixStatusMap[status]!['text'] as String: preFixStatusMap[status]!['color'] as Color,
|
preFixStatusMap[status]!['text'] as String: preFixStatusMap[status]!['color'] as Color,
|
||||||
vehicleStatusMap[status]!['text'] as String: vehicleStatusMap[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
|
// 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
|
"${preFixStatusMap[status]!['text']} ${vehicleStatusMap[status]!['text']}": vehicleStatusMap[status]!['color'] as Color
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue