|
|
|
|
@ -80,9 +80,11 @@ class AdVM extends BaseVM {
|
|
|
|
|
String adPhoneNumberError = "";
|
|
|
|
|
|
|
|
|
|
// Edit Variables Amir
|
|
|
|
|
bool isExtendAdEditEnabled = false;
|
|
|
|
|
bool isAdEditEnabled = false;
|
|
|
|
|
AdDetailsModel? previousAdDetails;
|
|
|
|
|
|
|
|
|
|
List<AdDetailsModel> myDraftAds = [];
|
|
|
|
|
List<AdDetailsModel> exploreAds = [];
|
|
|
|
|
List<AdDetailsModel> exploreAdsFilteredList = [];
|
|
|
|
|
List<AdDetailsModel> myAdsFilteredList = [];
|
|
|
|
|
@ -179,6 +181,7 @@ class AdVM extends BaseVM {
|
|
|
|
|
if (myAdsStatusEnums.isEmpty) {
|
|
|
|
|
myAdsStatusEnums = await commonRepo.getEnumTypeValues(enumTypeID: AppEnums.myAdsFilterEnumId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (vehicleBrandsForFilters.isEmpty) {
|
|
|
|
|
vehicleBrandsForFilters = await commonRepo.getVehicleBrands(vehicleTypeId: -1); // to get all the brands
|
|
|
|
|
}
|
|
|
|
|
@ -340,6 +343,44 @@ class AdVM extends BaseVM {
|
|
|
|
|
setState(ViewState.idle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool hasMoreDataForMyDraftsAds = false;
|
|
|
|
|
int pageIndexForMyDrafts = 1;
|
|
|
|
|
|
|
|
|
|
Future<void> getMyDraftAds() async {
|
|
|
|
|
pageIndexForMyAds = 1;
|
|
|
|
|
hasMoreDataForMyAds = true;
|
|
|
|
|
setState(ViewState.busy);
|
|
|
|
|
myDraftAds = await adsRepo.getMyDraftAds();
|
|
|
|
|
notifyListeners();
|
|
|
|
|
setState(ViewState.idle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> fetchMoreDraftAds({required AdPostStatus adsStatus}) async {
|
|
|
|
|
if (isLoadingMore) return;
|
|
|
|
|
hasMoreDataForMyDraftsAds = true;
|
|
|
|
|
isLoadingMore = true;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
try {
|
|
|
|
|
final List<AdDetailsModel> newAds = await adsRepo.getMyDraftAds(page: pageIndexForMyDrafts);
|
|
|
|
|
if (newAds.isEmpty) {
|
|
|
|
|
hasMoreDataForMyDraftsAds = false;
|
|
|
|
|
} else {
|
|
|
|
|
myDraftAds.addAll(newAds);
|
|
|
|
|
pageIndexForMyDrafts++;
|
|
|
|
|
if (myDraftAds.length < myDraftAds.last.totalItemsCount!) {
|
|
|
|
|
hasMoreDataForMyDraftsAds = true;
|
|
|
|
|
} else {
|
|
|
|
|
hasMoreDataForMyDraftsAds = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
isLoadingMore = false;
|
|
|
|
|
Utils.showToast(error.toString());
|
|
|
|
|
}
|
|
|
|
|
isLoadingMore = false;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> getMyAds() async {
|
|
|
|
|
pageIndexForMyAds = 1;
|
|
|
|
|
hasMoreDataForMyAds = true;
|
|
|
|
|
@ -418,7 +459,7 @@ class AdVM extends BaseVM {
|
|
|
|
|
Utils.showToast(respModel.message ?? LocaleKeys.adMarkedAsSold.tr());
|
|
|
|
|
updateIsExploreAds(false);
|
|
|
|
|
applyFilterOnMyAds(adPostStatusEnum: AdPostStatus.sold); //pending for review
|
|
|
|
|
navigateReplaceWithName(context, AppRoutes.dashboard);
|
|
|
|
|
navigateReplaceWithName(context, AppRoutes.dashboard, arguments: DashboardRouteEnum.fromAdsSubmit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> deleteMyAd(BuildContext context, {required int adId}) async {
|
|
|
|
|
@ -431,10 +472,10 @@ class AdVM extends BaseVM {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
Utils.showToast(LocaleKeys.AdDeletedSuccessfully.tr());
|
|
|
|
|
Utils.showToast(LocaleKeys.adDeletedSuccessfully.tr());
|
|
|
|
|
updateIsExploreAds(false);
|
|
|
|
|
applyFilterOnMyAds(adPostStatusEnum: AdPostStatus.active); //pending for review
|
|
|
|
|
navigateReplaceWithName(context, AppRoutes.dashboard);
|
|
|
|
|
navigateReplaceWithName(context, AppRoutes.dashboard, arguments: DashboardRouteEnum.fromAdsSubmit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> cancelMyAdReservation(BuildContext context, {required int adId, required String reason}) async {
|
|
|
|
|
@ -450,7 +491,7 @@ class AdVM extends BaseVM {
|
|
|
|
|
Utils.showToast(LocaleKeys.yourReservationCancelled.tr());
|
|
|
|
|
updateIsExploreAds(false);
|
|
|
|
|
applyFilterOnMyAds(adPostStatusEnum: AdPostStatus.active); //pending for review
|
|
|
|
|
navigateReplaceWithName(context, AppRoutes.dashboard);
|
|
|
|
|
navigateReplaceWithName(context, AppRoutes.dashboard, arguments: DashboardRouteEnum.fromAdsSubmit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> deactivateTheAd(BuildContext context, {required int adId, String? comment}) async {
|
|
|
|
|
@ -467,7 +508,7 @@ class AdVM extends BaseVM {
|
|
|
|
|
updateDeactivateAdReasonDescription('');
|
|
|
|
|
updateIsExploreAds(false);
|
|
|
|
|
applyFilterOnMyAds(adPostStatusEnum: AdPostStatus.cancelled); //Cacncelled
|
|
|
|
|
navigateReplaceWithName(context, AppRoutes.dashboard);
|
|
|
|
|
navigateReplaceWithName(context, AppRoutes.dashboard, arguments: DashboardRouteEnum.fromAdsSubmit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool isFetchingLists = false;
|
|
|
|
|
@ -570,7 +611,16 @@ class AdVM extends BaseVM {
|
|
|
|
|
|
|
|
|
|
SelectionModel vehicleTypeId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
|
|
|
|
|
void updateSelectionVehicleTypeId(SelectionModel id) async {
|
|
|
|
|
void updateSelectionVehicleTypeId(SelectionModel id, {bool isForSearch = false}) async {
|
|
|
|
|
if (isForSearch) {
|
|
|
|
|
VehicleTypeModel vehicleTypeModel = vehicleTypesForFilters.firstWhere((element) => element.id == id.selectedId);
|
|
|
|
|
DropValue vehicleTypeVValue = DropValue(vehicleTypeModel.id ?? 0, vehicleTypeModel.vehicleTypeName ?? "", "");
|
|
|
|
|
if (!ifAlreadyExist(list: vehicleTypesAdSearchHistory, value: vehicleTypeVValue)) {
|
|
|
|
|
addToVehicleTypesAdSearchHistory(value: vehicleTypeVValue);
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
vehicleTypeId = id;
|
|
|
|
|
await getVehicleBrandsByVehicleTypeId();
|
|
|
|
|
notifyListeners();
|
|
|
|
|
@ -580,7 +630,7 @@ class AdVM extends BaseVM {
|
|
|
|
|
|
|
|
|
|
Future<void> updateSelectionVehicleBrandId(SelectionModel id, {bool isForSearch = false}) async {
|
|
|
|
|
if (isForSearch) {
|
|
|
|
|
VehicleBrandsModel brand = vehicleBrands.firstWhere((element) => element.id == id.selectedId);
|
|
|
|
|
VehicleBrandsModel brand = vehicleBrandsForFilters.firstWhere((element) => element.id == id.selectedId);
|
|
|
|
|
DropValue brandValue = DropValue(brand.id ?? 0, brand.vehicleBrandDescription ?? "", "");
|
|
|
|
|
if (!ifAlreadyExist(list: vehicleBrandsAdSearchHistory, value: brandValue)) {
|
|
|
|
|
addToVehicleBrandsAdSearchHistory(value: brandValue);
|
|
|
|
|
@ -1218,6 +1268,7 @@ class AdVM extends BaseVM {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
isAdEditEnabled = false;
|
|
|
|
|
isExtendAdEditEnabled = false;
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
currentProgressStep = AdCreationSteps.vehicleDetails;
|
|
|
|
|
resetValues();
|
|
|
|
|
@ -1544,6 +1595,7 @@ class AdVM extends BaseVM {
|
|
|
|
|
Utils.showToast("${LocaleKeys.error.tr()}: ${genericRespModel.message}");
|
|
|
|
|
} else {
|
|
|
|
|
resetSpecialServiceBottomSheet();
|
|
|
|
|
pop(context);
|
|
|
|
|
navigateWithName(context, AppRoutes.paymentMethodsView, arguments: PaymentTypes.ads);
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
@ -1559,18 +1611,19 @@ class AdVM extends BaseVM {
|
|
|
|
|
for (var value in specialServiceCards) {
|
|
|
|
|
adsSelectedServices.add(value.serviceSelectedId!.selectedId);
|
|
|
|
|
}
|
|
|
|
|
log("selectionDurationStartDate: $selectionDurationStartDate");
|
|
|
|
|
|
|
|
|
|
if (selectionDurationStartDate.isNotEmpty) {
|
|
|
|
|
// Define the format of the input string
|
|
|
|
|
DateTime startDate = DateTime.parse(
|
|
|
|
|
"${selectionDurationStartDate.split('-')[2]}-${selectionDurationStartDate.split('-')[1]}-${selectionDurationStartDate.split('-')[0]}",
|
|
|
|
|
);
|
|
|
|
|
DateTime startDate = DateHelper.parseStringToDate(selectionDurationStartDate);
|
|
|
|
|
DateTime currentDate = DateTime.now();
|
|
|
|
|
|
|
|
|
|
if (startDate.isBefore(currentDate)) {
|
|
|
|
|
selectionDurationStartDate = DateHelper.formatAsYearMonthDay(currentDate);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log("selectionDurationStartDate: $selectionDurationStartDate");
|
|
|
|
|
Ads ads = Ads(
|
|
|
|
|
id: isAdEditEnabled ? previousAdDetails!.id : null,
|
|
|
|
|
adsDurationID: vehicleAdDurationId.selectedId == -1 ? 0 : vehicleAdDurationId.selectedId,
|
|
|
|
|
@ -1629,7 +1682,8 @@ class AdVM extends BaseVM {
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
AdsCreationPayloadModel adsCreationPayloadModel = AdsCreationPayloadModel(ads: ads, vehiclePosting: vehiclePosting);
|
|
|
|
|
GenericRespModel respModel = await adsRepo.createOrUpdateAd(adsCreationPayloadModel: adsCreationPayloadModel, isCreateNew: !isAdEditEnabled);
|
|
|
|
|
|
|
|
|
|
GenericRespModel respModel = await adsRepo.createOrUpdateAd(adsCreationPayloadModel: adsCreationPayloadModel, isCreateNew: !isAdEditEnabled, isExtendAdEditEnabled: isExtendAdEditEnabled);
|
|
|
|
|
|
|
|
|
|
Utils.showToast(respModel.message.toString());
|
|
|
|
|
|
|
|
|
|
@ -1685,6 +1739,8 @@ class AdVM extends BaseVM {
|
|
|
|
|
List<EnumsModel> vehicleConditionsEnum = [];
|
|
|
|
|
List<EnumsModel> adOwnerEnumsFilter = [];
|
|
|
|
|
|
|
|
|
|
List<VehicleTypeModel> vehicleTypesForFilters = [];
|
|
|
|
|
|
|
|
|
|
Future<void> populateDataForAdFilter() async {
|
|
|
|
|
setState(ViewState.busy);
|
|
|
|
|
pageIndexForExploreAds = 1;
|
|
|
|
|
@ -1701,6 +1757,10 @@ class AdVM extends BaseVM {
|
|
|
|
|
vehicleConditionsEnum = await commonRepo.getEnumTypeValues(enumTypeID: AppEnums.conditionEnumId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (vehicleTypesForFilters.isEmpty) {
|
|
|
|
|
vehicleTypesForFilters = await commonRepo.getVehicleTypes();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (vehicleBrandsForFilters.isEmpty) {
|
|
|
|
|
vehicleBrandsForFilters = await commonRepo.getVehicleBrands(vehicleTypeId: -1); // to get all the brands
|
|
|
|
|
}
|
|
|
|
|
@ -1725,6 +1785,127 @@ class AdVM extends BaseVM {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ifAlreadyExistForStringValue({required List<String> list, required String value}) {
|
|
|
|
|
int index = list.indexWhere((element) {
|
|
|
|
|
return element == value;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (index != -1) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Ad Demand Price
|
|
|
|
|
|
|
|
|
|
String adFilterDemandStartPrice = "";
|
|
|
|
|
|
|
|
|
|
void updateAdFilterDemandStartPrice(String title) {
|
|
|
|
|
adFilterDemandStartPrice = title;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String adFilterDemandEndPrice = "";
|
|
|
|
|
|
|
|
|
|
void updateAdFilterDemandEndPrice(String title) {
|
|
|
|
|
adFilterDemandEndPrice = title;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Ads Mobile Number Filter
|
|
|
|
|
|
|
|
|
|
String currentAdMobilePhoneFilter = '';
|
|
|
|
|
|
|
|
|
|
void onCurrentAdMobilePhoneFilterChanged(var value) {
|
|
|
|
|
currentAdMobilePhoneFilter = value;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<String> adFilterMobilePhoneSearchHistory = [];
|
|
|
|
|
|
|
|
|
|
void removeAdFilterMobilePhoneSearchHistory({bool isClear = false, required int index}) {
|
|
|
|
|
if (isClear) {
|
|
|
|
|
adFilterMobilePhoneSearchHistory.clear();
|
|
|
|
|
notifyListeners();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
adFilterMobilePhoneSearchHistory.removeAt(index);
|
|
|
|
|
if (adFilterMobilePhoneSearchHistory.isEmpty) {
|
|
|
|
|
updateAdsFiltersCounter(adsFiltersCounter - 1);
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void addAdFilterMobilePhoneSearchHistory({required String value}) {
|
|
|
|
|
if (adFilterMobilePhoneSearchHistory.isEmpty) {
|
|
|
|
|
updateAdsFiltersCounter(adsFiltersCounter + 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!ifAlreadyExistForStringValue(list: adFilterMobilePhoneSearchHistory, value: value)) {
|
|
|
|
|
adFilterMobilePhoneSearchHistory.add(value);
|
|
|
|
|
currentAdMobilePhoneFilter = "";
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Ad ID
|
|
|
|
|
|
|
|
|
|
List<String> adsFilterAdIDSearchHistory = [];
|
|
|
|
|
String currentAdIDFilter = '';
|
|
|
|
|
|
|
|
|
|
void onCurrentAdIDFilterChanged(var value) {
|
|
|
|
|
currentAdIDFilter = value;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void removeAdFilterAdIDSearchHistory({bool isClear = false, required int index}) {
|
|
|
|
|
if (isClear) {
|
|
|
|
|
adsFilterAdIDSearchHistory.clear();
|
|
|
|
|
notifyListeners();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
adsFilterAdIDSearchHistory.removeAt(index);
|
|
|
|
|
if (adsFilterAdIDSearchHistory.isEmpty) {
|
|
|
|
|
updateAdsFiltersCounter(adsFiltersCounter - 1);
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void addAdFilterAdIDSearchHistory({required String value}) {
|
|
|
|
|
if (adsFilterAdIDSearchHistory.isEmpty) {
|
|
|
|
|
updateAdsFiltersCounter(adsFiltersCounter + 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!ifAlreadyExistForStringValue(list: adsFilterAdIDSearchHistory, value: value)) {
|
|
|
|
|
adsFilterAdIDSearchHistory.add(value);
|
|
|
|
|
currentAdIDFilter = "";
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//TYPES
|
|
|
|
|
List<DropValue> vehicleTypesAdSearchHistory = [];
|
|
|
|
|
|
|
|
|
|
void removeVehicleTypesAdSearchHistory({bool isClear = false, required int index}) {
|
|
|
|
|
if (isClear) {
|
|
|
|
|
vehicleTypesAdSearchHistory.clear();
|
|
|
|
|
notifyListeners();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
vehicleTypesAdSearchHistory.removeAt(index);
|
|
|
|
|
if (vehicleTypesAdSearchHistory.isEmpty) {
|
|
|
|
|
updateAdsFiltersCounter(adsFiltersCounter - 1);
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void addToVehicleTypesAdSearchHistory({required DropValue value}) {
|
|
|
|
|
if (vehicleTypesAdSearchHistory.isEmpty) {
|
|
|
|
|
updateAdsFiltersCounter(adsFiltersCounter + 1);
|
|
|
|
|
}
|
|
|
|
|
vehicleTypesAdSearchHistory.add(value);
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//BRANDS
|
|
|
|
|
List<DropValue> vehicleBrandsAdSearchHistory = [];
|
|
|
|
|
|
|
|
|
|
@ -1861,11 +2042,14 @@ class AdVM extends BaseVM {
|
|
|
|
|
if (vehicleAdCreatedDateSearchHistory.isEmpty) {
|
|
|
|
|
updateAdsFiltersCounter(adsFiltersCounter + 1);
|
|
|
|
|
}
|
|
|
|
|
if (vehicleAdCreatedDateSearchHistory.isEmpty) {
|
|
|
|
|
vehicleAdCreatedDateSearchHistory.add(value);
|
|
|
|
|
} else {
|
|
|
|
|
vehicleAdCreatedDateSearchHistory.first = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vehicleAdCreatedDateSearchHistory.add(value);
|
|
|
|
|
|
|
|
|
|
// if (vehicleAdCreatedDateSearchHistory.isEmpty) {
|
|
|
|
|
// vehicleAdCreatedDateSearchHistory.add(value);
|
|
|
|
|
// } else {
|
|
|
|
|
// vehicleAdCreatedDateSearchHistory.first = value;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
@ -1902,12 +2086,16 @@ class AdVM extends BaseVM {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void clearAdsFilters() {
|
|
|
|
|
vehicleBrandsAdSearchHistory.clear();
|
|
|
|
|
adsFilterAdIDSearchHistory.clear();
|
|
|
|
|
vehicleTypesAdSearchHistory.clear();
|
|
|
|
|
vehicleAdOwnerSearchHistory.clear();
|
|
|
|
|
vehicleLocationAdSearchHistory.clear();
|
|
|
|
|
vehicleYearAdSearchHistory.clear();
|
|
|
|
|
vehicleAdCreatedDateSearchHistory.clear();
|
|
|
|
|
vehicleAdConditionSearchHistory.clear();
|
|
|
|
|
adFilterMobilePhoneSearchHistory.clear();
|
|
|
|
|
adFilterDemandStartPrice = '';
|
|
|
|
|
adFilterDemandEndPrice = '';
|
|
|
|
|
adsFiltersCounter = 0;
|
|
|
|
|
getExploreAds();
|
|
|
|
|
notifyListeners();
|
|
|
|
|
@ -1928,12 +2116,25 @@ class AdVM extends BaseVM {
|
|
|
|
|
exploreAdsFilteredList.clear();
|
|
|
|
|
setState(ViewState.busy);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<String> adIdsList = [];
|
|
|
|
|
if (adsFilterAdIDSearchHistory.isNotEmpty) {
|
|
|
|
|
for (var element in adsFilterAdIDSearchHistory) {
|
|
|
|
|
adIdsList.add(element.toString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
List<String> cityIdsList = [];
|
|
|
|
|
if (vehicleLocationAdSearchHistory.isNotEmpty) {
|
|
|
|
|
for (var element in vehicleLocationAdSearchHistory) {
|
|
|
|
|
cityIdsList.add(element.id.toString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
List<String> typesIdsList = [];
|
|
|
|
|
if (vehicleTypesAdSearchHistory.isNotEmpty) {
|
|
|
|
|
for (var element in vehicleTypesAdSearchHistory) {
|
|
|
|
|
typesIdsList.add(element.id.toString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
List<String> brandsIdsList = [];
|
|
|
|
|
if (vehicleBrandsAdSearchHistory.isNotEmpty) {
|
|
|
|
|
for (var element in vehicleBrandsAdSearchHistory) {
|
|
|
|
|
@ -1969,13 +2170,43 @@ class AdVM extends BaseVM {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<String> phoneNumbersList = [];
|
|
|
|
|
if (adFilterMobilePhoneSearchHistory.isNotEmpty) {
|
|
|
|
|
for (var element in adFilterMobilePhoneSearchHistory) {
|
|
|
|
|
phoneNumbersList.add(element.toString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int? startPriceDemand;
|
|
|
|
|
int? endPriceDemand;
|
|
|
|
|
if (adFilterDemandStartPrice.isNotEmpty) {
|
|
|
|
|
try {
|
|
|
|
|
startPriceDemand = int.parse(adFilterDemandStartPrice);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
startPriceDemand = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (adFilterDemandEndPrice.isNotEmpty) {
|
|
|
|
|
try {
|
|
|
|
|
endPriceDemand = int.parse(adFilterDemandEndPrice);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
endPriceDemand = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<AdDetailsModel> list = await adsRepo.getExploreAdsBasedOnFilters(
|
|
|
|
|
adIdsList: adIdsList,
|
|
|
|
|
cityIdsList: cityIdsList,
|
|
|
|
|
createdByRolesIdsList: adOwnerIdsList,
|
|
|
|
|
vehicleTypeIdsList: typesIdsList,
|
|
|
|
|
vehicleBrandIdsList: brandsIdsList,
|
|
|
|
|
vehicleModelYearIdsList: vehicleYearIdsList,
|
|
|
|
|
vehicleAdConditionIdsList: conditionsIdsList,
|
|
|
|
|
vehicleAdCreatedDateList: createdDatesList,
|
|
|
|
|
mobileNumbersList: phoneNumbersList,
|
|
|
|
|
startPriceDemand: startPriceDemand,
|
|
|
|
|
endPriceDemand: endPriceDemand,
|
|
|
|
|
page: pageIndex,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
@ -1992,6 +2223,7 @@ class AdVM extends BaseVM {
|
|
|
|
|
|
|
|
|
|
void onEditUpdateAdPressed({required BuildContext context, required AdDetailsModel previousDetails, required bool isFromExtendAd}) {
|
|
|
|
|
isAdEditEnabled = true;
|
|
|
|
|
isExtendAdEditEnabled = isFromExtendAd;
|
|
|
|
|
previousAdDetails = previousDetails;
|
|
|
|
|
autoFillSelectedVehicleType();
|
|
|
|
|
autoFillSelectedVehicleAdsDuration();
|
|
|
|
|
@ -1999,22 +2231,25 @@ class AdVM extends BaseVM {
|
|
|
|
|
navigateWithName(context, AppRoutes.selectAdTypeView, arguments: [AppState().currentAppType == AppType.provider, isFromExtendAd, previousDetails.id]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<bool> createAdExtensionOrder(BuildContext context, {required int adId, required int adsDurationId}) async {
|
|
|
|
|
Future<List<bool>> createAdExtensionOrder(BuildContext context, {required int adId, required int adsDurationId}) async {
|
|
|
|
|
// [0] Means API response [1] means isPaymentRequired
|
|
|
|
|
try {
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
GenericRespModel respModel = await adsRepo.createAdExtensionOrder(adID: adId, adsDurationId: adsDurationId, specialServiceIds: []);
|
|
|
|
|
|
|
|
|
|
if (respModel.messageStatus != 1) {
|
|
|
|
|
if (respModel.messageStatus != 1 && respModel.data == null) {
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
Utils.showToast(respModel.message ?? LocaleKeys.somethingWrong.tr());
|
|
|
|
|
return false;
|
|
|
|
|
return [false, false]; // api fail response
|
|
|
|
|
}
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
return respModel.messageStatus == 1;
|
|
|
|
|
|
|
|
|
|
final AdExtensionOrderResponseModel adExtensionOrderResponseModel = AdExtensionOrderResponseModel.fromJson(respModel.data);
|
|
|
|
|
return [true, adExtensionOrderResponseModel.isPaymentRequired];
|
|
|
|
|
} catch (e) {
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
Utils.showToast(e.toString());
|
|
|
|
|
return false;
|
|
|
|
|
return [false, false]; // api fail response
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|