|
|
|
|
@ -723,6 +723,7 @@ class AdVM extends BaseVM {
|
|
|
|
|
SelectionModel vehicleAdDurationId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
|
|
|
|
|
void updateVehicleAdDurationId(SelectionModel id) {
|
|
|
|
|
log("vehicleAdDurationId is updated: ${vehicleAdDurationId.selectedId}");
|
|
|
|
|
vehicleAdDurationId = id;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
@ -1026,7 +1027,7 @@ class AdVM extends BaseVM {
|
|
|
|
|
|
|
|
|
|
bool isAdDurationValidated() {
|
|
|
|
|
bool isValidated = true;
|
|
|
|
|
if (vehicleAdDurationId.selectedId == -1) {
|
|
|
|
|
if (AppState().userType != UserType.providerDealer && vehicleAdDurationId.selectedId == -1) {
|
|
|
|
|
vehicleAdDurationId.errorValue = LocaleKeys.vehicle_vehiclePart.tr();
|
|
|
|
|
isValidated = false;
|
|
|
|
|
} else {
|
|
|
|
|
@ -1252,6 +1253,11 @@ class AdVM extends BaseVM {
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void updateDamagePartDescription(int index, String value) {
|
|
|
|
|
vehicleDamageCards[index].damagePartDescription = value;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void removeDamageImageFromCard(int imageIndex, String filePath, int cardIndex) {
|
|
|
|
|
VehicleDamageCard card = vehicleDamageCards.elementAt(cardIndex);
|
|
|
|
|
if (card.partImages == null) return;
|
|
|
|
|
@ -1420,14 +1426,14 @@ class AdVM extends BaseVM {
|
|
|
|
|
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
if (genericRespModel.messageStatus != 1) {
|
|
|
|
|
Utils.showToast(LocaleKeys.error.tr() + ": ${genericRespModel.message}");
|
|
|
|
|
Utils.showToast("${LocaleKeys.error.tr()}: ${genericRespModel.message}");
|
|
|
|
|
} else {
|
|
|
|
|
resetSpecialServiceBottomSheet();
|
|
|
|
|
navigateWithName(context, AppRoutes.paymentMethodsView, arguments: PaymentTypes.ads);
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
Utils.showToast(LocaleKeys.error.tr() + ": ${e.toString()}");
|
|
|
|
|
Utils.showToast("${LocaleKeys.error.tr()}: ${e.toString()}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1440,7 +1446,7 @@ class AdVM extends BaseVM {
|
|
|
|
|
}
|
|
|
|
|
Ads ads = Ads(
|
|
|
|
|
id: isAdEditEnabled ? previousAdDetails!.id : null,
|
|
|
|
|
adsDurationID: vehicleAdDurationId.selectedId,
|
|
|
|
|
adsDurationID: vehicleAdDurationId.selectedId == -1 ? 0 : vehicleAdDurationId.selectedId,
|
|
|
|
|
startDate: selectionDurationStartDate,
|
|
|
|
|
countryId: vehicleCountryId.selectedId,
|
|
|
|
|
specialServiceIDs: adsSelectedServices,
|
|
|
|
|
@ -1459,6 +1465,7 @@ class AdVM extends BaseVM {
|
|
|
|
|
VehiclePostingDamageParts stringImage = await convertFileToVehiclePostingDamageParts(
|
|
|
|
|
imageModel: image,
|
|
|
|
|
damagePartId: card.partSelectedId!.selectedId,
|
|
|
|
|
commentParam: card.damagePartDescription ?? "",
|
|
|
|
|
);
|
|
|
|
|
vehicleDamageImages.add(stringImage);
|
|
|
|
|
}
|
|
|
|
|
@ -1523,7 +1530,7 @@ class AdVM extends BaseVM {
|
|
|
|
|
return vehiclePostingImages;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<VehiclePostingDamageParts> convertFileToVehiclePostingDamageParts({required ImageModel imageModel, required int damagePartId}) async {
|
|
|
|
|
Future<VehiclePostingDamageParts> convertFileToVehiclePostingDamageParts({required ImageModel imageModel, required int damagePartId, required String commentParam}) async {
|
|
|
|
|
VehiclePostingDamageParts vehiclePostingDamageParts;
|
|
|
|
|
|
|
|
|
|
if (imageModel.isFromNetwork ?? false) {
|
|
|
|
|
@ -1531,17 +1538,14 @@ class AdVM extends BaseVM {
|
|
|
|
|
id: imageModel.id,
|
|
|
|
|
vehicleDamagePartID: damagePartId,
|
|
|
|
|
imageUrl: imageModel.filePath,
|
|
|
|
|
comment: commentParam,
|
|
|
|
|
vehiclePostingID: isAdEditEnabled ? previousAdDetails!.vehiclePostingID : null,
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
File file = File(imageModel.filePath!);
|
|
|
|
|
List<int> imageBytes = await file.readAsBytes();
|
|
|
|
|
String image = base64Encode(imageBytes);
|
|
|
|
|
vehiclePostingDamageParts = VehiclePostingDamageParts(
|
|
|
|
|
vehicleImageBase64: image,
|
|
|
|
|
vehicleDamagePartID: damagePartId,
|
|
|
|
|
imageUrl: file.path,
|
|
|
|
|
);
|
|
|
|
|
vehiclePostingDamageParts = VehiclePostingDamageParts(vehicleImageBase64: image, vehicleDamagePartID: damagePartId, imageUrl: file.path, comment: commentParam);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return vehiclePostingDamageParts;
|
|
|
|
|
@ -1775,7 +1779,6 @@ class AdVM extends BaseVM {
|
|
|
|
|
Utils.showToast(e.toString());
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void autoFillSelectedVehicleType() async {
|
|
|
|
|
@ -1806,7 +1809,7 @@ class AdVM extends BaseVM {
|
|
|
|
|
SelectionModel(
|
|
|
|
|
selectedId: vehicleAdsDurations[index].id ?? 0,
|
|
|
|
|
selectedOption: "${vehicleAdsDurations[index].days} Days",
|
|
|
|
|
itemPrice: vehicleAdsDurations[index].price!.toInt().toString(),
|
|
|
|
|
itemPrice: vehicleAdsDurations[index].price!.toString(),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
@ -1876,6 +1879,7 @@ class AdVM extends BaseVM {
|
|
|
|
|
selectedId: element.vehicleDamagePartID!,
|
|
|
|
|
selectedOption: element.partName ?? "",
|
|
|
|
|
),
|
|
|
|
|
damagePartDescription: "",
|
|
|
|
|
partImages: [imageModel],
|
|
|
|
|
);
|
|
|
|
|
addNewDamagePartCard(damageCard: vehicleDamageCard);
|
|
|
|
|
@ -1964,17 +1968,19 @@ class AdVM extends BaseVM {
|
|
|
|
|
class VehicleDamageCard {
|
|
|
|
|
List<ImageModel>? partImages;
|
|
|
|
|
SelectionModel? partSelectedId;
|
|
|
|
|
String? damagePartDescription;
|
|
|
|
|
String partImageErrorValue;
|
|
|
|
|
|
|
|
|
|
VehicleDamageCard({
|
|
|
|
|
this.partImages,
|
|
|
|
|
this.partSelectedId,
|
|
|
|
|
this.damagePartDescription,
|
|
|
|
|
this.partImageErrorValue = "",
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
String toString() {
|
|
|
|
|
return 'VehicleDamageCard{partImages: $partImages, partSelectedId: $partSelectedId, partImageErrorValue: $partImageErrorValue}';
|
|
|
|
|
return 'VehicleDamageCard{partImages: $partImages, partSelectedId: $partSelectedId,damagePartDescription: $damagePartDescription, partImageErrorValue: $partImageErrorValue}';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|