Request Module iAP

models_removal
Faiz Hashmi 2 years ago
parent 8a8efa37f2
commit b9a5429de5

@ -129,6 +129,7 @@ class ApiConsts {
//Requests //Requests
static String createRequest = "${baseUrlServices}api/RequestManagement/Request_Create"; static String createRequest = "${baseUrlServices}api/RequestManagement/Request_Create";
static String getRequest = "${baseUrlServices}api/RequestManagement/Request_Get"; static String getRequest = "${baseUrlServices}api/RequestManagement/Request_Get";
static String getRequestOffers = "${baseUrlServices}api/RequestManagement/ReqOffer_Get";
static List<String> closingUrls = ["PayFortResponse"]; static List<String> closingUrls = ["PayFortResponse"];
} }

@ -71,6 +71,10 @@ class AppRoutes {
static const String createRequestPage = "/createRequestPage"; static const String createRequestPage = "/createRequestPage";
static const String offersListPage = "/offersListPage"; static const String offersListPage = "/offersListPage";
//Chat
static const String chatView = "/chatView";
static const String initialRoute = splash; static const String initialRoute = splash;
static final Map<String, WidgetBuilder> routes = { static final Map<String, WidgetBuilder> routes = {

@ -198,7 +198,7 @@ extension AdPostEnum on int {
return AdPostStatus.buyingService; return AdPostStatus.buyingService;
} else if (this == 11) { } else if (this == 11) {
return AdPostStatus.reserveCancel; return AdPostStatus.reserveCancel;
} else if (this == -1) { } else if (this == 0) {
return AdPostStatus.allAds; return AdPostStatus.allAds;
} else { } else {
return AdPostStatus.pendingForPost; return AdPostStatus.pendingForPost;
@ -216,12 +216,25 @@ extension AppointmentEnum on int {
return AppointmentStatusEnum.arrived; return AppointmentStatusEnum.arrived;
} else if (this == 4) { } else if (this == 4) {
return AppointmentStatusEnum.cancelled; return AppointmentStatusEnum.cancelled;
} else if (this == 5) {
return AppointmentStatusEnum.rescheduled;
} else { } else {
return AppointmentStatusEnum.allAppointments; return AppointmentStatusEnum.allAppointments;
} }
} }
} }
extension RequestTypeTypeEnum on int {
RequestsTypeEnum toRequestTypeStatusEnum() {
if (this == 1) {
return RequestsTypeEnum.specialCarRequest;
} else if (this == 2) {
return RequestsTypeEnum.serviceRequest;
}
return RequestsTypeEnum.specialCarRequest;
}
}
extension AdPostStatusToInt on AdPostStatus { extension AdPostStatusToInt on AdPostStatus {
int getIdFromAdPostStatusEnum() { int getIdFromAdPostStatusEnum() {
switch (this) { switch (this) {
@ -257,7 +270,7 @@ extension AdPostStatusToInt on AdPostStatus {
case AdPostStatus.reserveCancel: case AdPostStatus.reserveCancel:
return 11; return 11;
default: default:
return -1; return 0;
} }
} }
} }
@ -291,6 +304,7 @@ extension AppointmentStatusToInt on AppointmentStatusEnum {
switch (this) { switch (this) {
case AppointmentStatusEnum.booked: case AppointmentStatusEnum.booked:
return 1; return 1;
case AppointmentStatusEnum.confirmed: case AppointmentStatusEnum.confirmed:
return 2; return 2;
@ -300,8 +314,26 @@ extension AppointmentStatusToInt on AppointmentStatusEnum {
case AppointmentStatusEnum.cancelled: case AppointmentStatusEnum.cancelled:
return 4; return 4;
case AppointmentStatusEnum.rescheduled:
return 5;
default: default:
return -1; return 0;
}
}
}
extension RequestTypeStatusToInt on RequestsTypeEnum {
int getIdFromRequestTypeStatusEnum() {
switch (this) {
case RequestsTypeEnum.specialCarRequest:
return 1;
case RequestsTypeEnum.serviceRequest:
return 2;
default:
return 0;
} }
} }
} }
@ -316,7 +348,7 @@ extension CreatedByRoleEnumToInt on CreatedByRoleEnum {
case CreatedByRoleEnum.provider: case CreatedByRoleEnum.provider:
return 3; return 3;
case CreatedByRoleEnum.allAds: case CreatedByRoleEnum.allAds:
return -1; return 0;
default: default:
return 1; return 1;
} }
@ -341,7 +373,7 @@ extension AdReserveStatusEnum on int {
extension AdOwnerEnum on int { extension AdOwnerEnum on int {
CreatedByRoleEnum toCreatedByRoleEnum() { CreatedByRoleEnum toCreatedByRoleEnum() {
if (this == -1) { if (this == 0) {
return CreatedByRoleEnum.allAds; return CreatedByRoleEnum.allAds;
} else if (this == 1) { } else if (this == 1) {
return CreatedByRoleEnum.admin; return CreatedByRoleEnum.admin;

@ -1,11 +1,11 @@
class Enums { class EnumsModel {
int id; int id;
int enumTypeId; int enumTypeId;
String enumValueStr; String enumValueStr;
int enumValue; int enumValue;
bool isActive; bool isActive;
Enums({ EnumsModel({
required this.id, required this.id,
required this.enumTypeId, required this.enumTypeId,
required this.enumValueStr, required this.enumValueStr,
@ -13,7 +13,7 @@ class Enums {
required this.isActive, required this.isActive,
}); });
factory Enums.fromJson(Map<String, dynamic> json) => Enums( factory EnumsModel.fromJson(Map<String, dynamic> json) => EnumsModel(
id: json["id"], id: json["id"],
enumTypeId: json["enumTypeID"], enumTypeId: json["enumTypeID"],
enumValueStr: json["enumValueStr"], enumValueStr: json["enumValueStr"],
@ -21,6 +21,11 @@ class Enums {
isActive: json["isActive"], isActive: json["isActive"],
); );
@override
String toString() {
return 'EnumsModel{id: $id, enumTypeId: $enumTypeId, enumValueStr: $enumValueStr, enumValue: $enumValue, isActive: $isActive}';
}
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
"id": id, "id": id,
"enumTypeID": enumTypeId, "enumTypeID": enumTypeId,

@ -279,6 +279,29 @@ class VehiclePostingImages {
} }
} }
class RequestPostingImages {
int? id;
String? requestImage;
int? requestID;
RequestPostingImages({this.id, this.requestImage, this.requestID});
RequestPostingImages.fromJson(Map<String, dynamic> json) {
id = json['id'];
requestImage = json['requestImage'];
requestID = json['requestID'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['requestImage'] = requestImage;
data['requestID'] = requestID;
return data;
}
}
class VehiclePostingDamageParts { class VehiclePostingDamageParts {
int? id; int? id;
String? comment; String? comment;

@ -0,0 +1,169 @@
class OffersModel {
int? id;
int? requestID;
int? serviceProviderID;
ServiceProvider? serviceProvider;
int? offerStatus;
String? offerStatusText;
String? comment;
double? price;
OffersModel(
{this.id,
this.requestID,
this.serviceProviderID,
this.serviceProvider,
this.offerStatus,
this.offerStatusText,
this.comment,
this.price});
OffersModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
requestID = json['requestID'];
serviceProviderID = json['serviceProviderID'];
serviceProvider = json['serviceProvider'] != null
? ServiceProvider.fromJson(json['serviceProvider'])
: null;
offerStatus = json['offerStatus'];
offerStatusText = json['offerStatusText'];
comment = json['comment'];
price = json['price'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['requestID'] = requestID;
data['serviceProviderID'] = serviceProviderID;
if (serviceProvider != null) {
data['serviceProvider'] = serviceProvider!.toJson();
}
data['offerStatus'] = offerStatus;
data['offerStatusText'] = offerStatusText;
data['comment'] = comment;
data['price'] = price;
return data;
}
}
class ServiceProvider {
int? providerId;
String? providerGUID;
String? firstName;
String? lastName;
String? name;
int? gender;
String? genderName;
String? mobileNo;
String? email;
bool? isEmailVerfied;
bool? isCompleted;
int? city;
String? cityName;
int? country;
String? countryName;
int? accountStatus;
String? accountStatusText;
int? activityStatus;
String? activityStatusText;
String? bankName;
String? iBanNo;
bool? isActive;
String? subscriptionDate;
String? companyName;
String? currency;
String? branch;
dynamic requestOffer;
ServiceProvider(
{this.providerId,
this.providerGUID,
this.firstName,
this.lastName,
this.name,
this.gender,
this.genderName,
this.mobileNo,
this.email,
this.isEmailVerfied,
this.isCompleted,
this.city,
this.cityName,
this.country,
this.countryName,
this.accountStatus,
this.accountStatusText,
this.activityStatus,
this.activityStatusText,
this.bankName,
this.iBanNo,
this.isActive,
this.subscriptionDate,
this.companyName,
this.currency,
this.branch,
this.requestOffer});
ServiceProvider.fromJson(Map<String, dynamic> json) {
providerId = json['providerId'];
providerGUID = json['providerGUID'];
firstName = json['firstName'];
lastName = json['lastName'];
name = json['name'];
gender = json['gender'];
genderName = json['genderName'];
mobileNo = json['mobileNo'];
email = json['email'];
isEmailVerfied = json['isEmailVerfied'];
isCompleted = json['isCompleted'];
city = json['city'];
cityName = json['cityName'];
country = json['country'];
countryName = json['countryName'];
accountStatus = json['accountStatus'];
accountStatusText = json['accountStatusText'];
activityStatus = json['activityStatus'];
activityStatusText = json['activityStatusText'];
bankName = json['bankName'];
iBanNo = json['iBanNo'];
isActive = json['isActive'];
subscriptionDate = json['subscriptionDate'];
companyName = json['companyName'];
currency = json['currency'];
branch = json['branch'];
requestOffer = json['requestOffer'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['providerId'] = providerId;
data['providerGUID'] = providerGUID;
data['firstName'] = firstName;
data['lastName'] = lastName;
data['name'] = name;
data['gender'] = gender;
data['genderName'] = genderName;
data['mobileNo'] = mobileNo;
data['email'] = email;
data['isEmailVerfied'] = isEmailVerfied;
data['isCompleted'] = isCompleted;
data['city'] = city;
data['cityName'] = cityName;
data['country'] = country;
data['countryName'] = countryName;
data['accountStatus'] = accountStatus;
data['accountStatusText'] = accountStatusText;
data['activityStatus'] = activityStatus;
data['activityStatusText'] = activityStatusText;
data['bankName'] = bankName;
data['iBanNo'] = iBanNo;
data['isActive'] = isActive;
data['subscriptionDate'] = subscriptionDate;
data['companyName'] = companyName;
data['currency'] = currency;
data['branch'] = branch;
data['requestOffer'] = requestOffer;
return data;
}
}

@ -11,7 +11,7 @@ import 'package:mc_common_app/models/user/country.dart';
import 'package:mc_common_app/models/user/role.dart'; import 'package:mc_common_app/models/user/role.dart';
import '../models/advertisment_models/vehicle_details_models.dart'; import '../models/advertisment_models/vehicle_details_models.dart';
import '../models/enums.dart'; import '../models/enums_model.dart';
abstract class CommonRepo { abstract class CommonRepo {
Future<Country> getAllCountries(); Future<Country> getAllCountries();
@ -38,7 +38,7 @@ abstract class CommonRepo {
//TODO: Needs to remove common methods from AD's repo and delete all repeated methods. //TODO: Needs to remove common methods from AD's repo and delete all repeated methods.
Future<VehicleDetailsModel> getVehicleDetails({int? vehicleTypeId, int? vehicleBrandId}); Future<VehicleDetailsModel> getVehicleDetails({int? vehicleTypeId, int? vehicleBrandId});
Future<List<Enums>> getEnumTypeValues({int? enumTypeID, String? enumTypeName}); Future<List<EnumsModel>> getEnumTypeValues({int? enumTypeID, String? enumTypeName});
} }
class CommonRepoImp implements CommonRepo { class CommonRepoImp implements CommonRepo {
@ -159,7 +159,7 @@ class CommonRepoImp implements CommonRepo {
} }
@override @override
Future<List<Enums>> getEnumTypeValues({int? enumTypeID, String? enumTypeName}) async { Future<List<EnumsModel>> getEnumTypeValues({int? enumTypeID, String? enumTypeName}) async {
var postParams = {"enumTypeID": (enumTypeID ?? 0).toString(), "enumTypeName": enumTypeName ?? ""}; var postParams = {"enumTypeID": (enumTypeID ?? 0).toString(), "enumTypeName": enumTypeName ?? ""};
GenericRespModel enumGenericModel = await apiClient.postJsonForObject( GenericRespModel enumGenericModel = await apiClient.postJsonForObject(
(json) => GenericRespModel.fromJson(json), (json) => GenericRespModel.fromJson(json),
@ -168,7 +168,7 @@ class CommonRepoImp implements CommonRepo {
token: appState.getUser.data!.accessToken, token: appState.getUser.data!.accessToken,
); );
List<Enums> vehicleCities = List.generate(enumGenericModel.data.length, (index) => Enums.fromJson(enumGenericModel.data[index])); List<EnumsModel> vehicleCities = List.generate(enumGenericModel.data.length, (index) => EnumsModel.fromJson(enumGenericModel.data[index]));
return vehicleCities; return vehicleCities;
} }
// //

@ -37,6 +37,7 @@ class MyColors {
static const Color green = Color(0xffffffff); static const Color green = Color(0xffffffff);
static const Color borderColor = Color(0xffE8E8E8); static const Color borderColor = Color(0xffE8E8E8);
static const Color greyAddBorderColor = Color(0xffEEEEEE); static const Color greyAddBorderColor = Color(0xffEEEEEE);
static const Color lightGreyBgColor = Color(0xffFDFDFD);
//AdStatusColors: //AdStatusColors:
static const Color adActiveStatusColor = Color(0xff5FC16A); static const Color adActiveStatusColor = Color(0xff5FC16A);

@ -147,5 +147,11 @@ enum AppointmentStatusEnum {
confirmed, confirmed,
arrived, arrived,
cancelled, cancelled,
rescheduled,
allAppointments, allAppointments,
} }
enum RequestsTypeEnum {
specialCarRequest,
serviceRequest,
}

@ -223,6 +223,33 @@ class Utils {
} }
} }
static Color getChipColorByRequestStatus(RequestStatus requestStatus) {
switch (requestStatus) {
case RequestStatus.pending:
return MyColors.adPendingStatusColor;
case RequestStatus.submitted:
return MyColors.lightTextColor;
case RequestStatus.inProgress:
return MyColors.lightTextColor;
case RequestStatus.completed:
return MyColors.greenColor;
case RequestStatus.cancelled:
return MyColors.redColor;
case RequestStatus.paid:
return MyColors.greenColor;
case RequestStatus.expired:
return MyColors.redColor;
case RequestStatus.shipping:
return MyColors.greenColor;
}
}
static statusContainerChip({required String text, EdgeInsetsGeometry padding = const EdgeInsets.symmetric(vertical: 3, horizontal: 6), Color chipColor = MyColors.greenColor}) { static statusContainerChip({required String text, EdgeInsetsGeometry padding = const EdgeInsets.symmetric(vertical: 3, horizontal: 6), Color chipColor = MyColors.greenColor}) {
return Container( return Container(
decoration: BoxDecoration( decoration: BoxDecoration(

@ -14,6 +14,7 @@ import 'package:mc_common_app/models/advertisment_models/special_service_model.d
import 'package:mc_common_app/models/advertisment_models/ss_car_check_schedule_model.dart'; import 'package:mc_common_app/models/advertisment_models/ss_car_check_schedule_model.dart';
import 'package:mc_common_app/models/advertisment_models/ss_photo_schedule_model.dart'; import 'package:mc_common_app/models/advertisment_models/ss_photo_schedule_model.dart';
import 'package:mc_common_app/models/advertisment_models/vehicle_details_models.dart'; import 'package:mc_common_app/models/advertisment_models/vehicle_details_models.dart';
import 'package:mc_common_app/models/enums_model.dart';
import 'package:mc_common_app/models/generic_resp_model.dart'; import 'package:mc_common_app/models/generic_resp_model.dart';
import 'package:mc_common_app/models/widgets_models.dart'; import 'package:mc_common_app/models/widgets_models.dart';
import 'package:mc_common_app/repositories/ads_repo.dart'; import 'package:mc_common_app/repositories/ads_repo.dart';
@ -150,30 +151,29 @@ class AdVM extends BaseVM {
notifyListeners(); notifyListeners();
} }
List<EnumsModel> exploreAdsEnums = [];
List<EnumsModel> myAdsEnums = [];
List<FilterListModel> exploreAdsFilterOptions = []; List<FilterListModel> exploreAdsFilterOptions = [];
List<FilterListModel> myAdsFilterOptions = []; List<FilterListModel> myAdsFilterOptions = [];
populateAdsFilterList() { populateAdsFilterList() async {
myAdsEnums = await commonRepo.getEnumTypeValues(enumTypeID: 18); //TODO: 18 is to get My Ad Filter Enums
exploreAdsEnums = await commonRepo.getEnumTypeValues(enumTypeID: 23); //TODO: 23 is to get Explore Ad Filter Enums
exploreAdsFilterOptions.clear(); exploreAdsFilterOptions.clear();
exploreAdsFilterOptions = [ myAdsFilterOptions.clear();
FilterListModel(title: "All Ads", isSelected: true, id: -1), for (int i = 0; i < myAdsEnums.length; i++) {
FilterListModel(title: "Mowater Ads", isSelected: false, id: 1), myAdsFilterOptions.add(FilterListModel(title: myAdsEnums[i].enumValueStr, isSelected: false, id: myAdsEnums[i].enumValue));
FilterListModel(title: "Customer Ads", isSelected: false, id: 2), }
FilterListModel(title: "Provider Ads", isSelected: false, id: 3), myAdsFilterOptions.insert(0, FilterListModel(title: "All Ads", isSelected: true, id: 0));
];
for (int i = 0; i < exploreAdsEnums.length; i++) {
myAdsFilterOptions = [ exploreAdsFilterOptions.add(FilterListModel(title: "${exploreAdsEnums[i].enumValueStr} Ads", isSelected: false, id: exploreAdsEnums[i].enumValue));
FilterListModel(title: "All Ads", isSelected: true, id: -1), }
FilterListModel(title: "Active", isSelected: false, id: 6), exploreAdsFilterOptions.insert(0, FilterListModel(title: "All Ads", isSelected: true, id: 0));
FilterListModel(title: "Pending For Review", isSelected: false, id: 1),
FilterListModel(title: "Pending For Payment", isSelected: false, id: 2),
FilterListModel(title: "Sold", isSelected: false, id: 8),
FilterListModel(title: "Deactivated", isSelected: false, id: 4),
FilterListModel(title: "Reserved", isSelected: false, id: 9),
FilterListModel(title: "Expired", isSelected: false, id: 7),
FilterListModel(title: "Rejected", isSelected: false, id: 3),
FilterListModel(title: "Pending For Post", isSelected: false, id: 5),
];
notifyListeners(); notifyListeners();
} }
@ -203,7 +203,7 @@ class AdVM extends BaseVM {
} }
myAdsFilterOptions[index].isSelected = true; myAdsFilterOptions[index].isSelected = true;
if (adPostStatusEnum.getIdFromAdPostStatusEnum() == -1) { if (adPostStatusEnum.getIdFromAdPostStatusEnum() == 0) {
myAdsFilteredList = myAds; myAdsFilteredList = myAds;
notifyListeners(); notifyListeners();
return; return;

@ -1,272 +1,272 @@
import 'dart:io'; // import 'dart:io';
//
import 'package:mc_common_app/classes/app_state.dart'; // import 'package:mc_common_app/classes/app_state.dart';
import 'package:mc_common_app/models/advertisment_models/vehicle_details_models.dart'; // import 'package:mc_common_app/models/advertisment_models/vehicle_details_models.dart';
import 'package:mc_common_app/models/enums.dart'; // import 'package:mc_common_app/models/enums_model.dart';
import 'package:mc_common_app/models/generic_resp_model.dart'; // import 'package:mc_common_app/models/generic_resp_model.dart';
import 'package:mc_common_app/models/requests/request_model.dart'; // import 'package:mc_common_app/models/requests/request_model.dart';
import 'package:mc_common_app/models/widgets_models.dart'; // import 'package:mc_common_app/models/widgets_models.dart';
import 'package:mc_common_app/repositories/common_repo.dart'; // import 'package:mc_common_app/repositories/common_repo.dart';
import 'package:mc_common_app/services/common_services.dart'; // import 'package:mc_common_app/services/common_services.dart';
import 'package:mc_common_app/utils/utils.dart'; // import 'package:mc_common_app/utils/utils.dart';
import 'package:mc_common_app/view_models/base_view_model.dart'; // import 'package:mc_common_app/view_models/base_view_model.dart';
//
import '../repositories/request_repo.dart'; // import '../repositories/request_repo.dart';
//
class RequestsVM extends BaseVM { // class RequestsVM extends BaseVM {
final CommonAppServices commonServices; // final CommonAppServices commonServices;
final CommonRepo commonRepo; // final CommonRepo commonRepo;
final RequestRepo requestRepo; // final RequestRepo requestRepo;
//
RequestsVM({required this.commonServices, required this.commonRepo, required this.requestRepo}); // RequestsVM({required this.commonServices, required this.commonRepo, required this.requestRepo});
//
List<FilterListModel> requestsFilterOptions = []; // List<FilterListModel> requestsFilterOptions = [];
//
populateRequestsFilterList() { // populateRequestsFilterList() {
requestsFilterOptions.clear(); // requestsFilterOptions.clear();
requestsFilterOptions = [ // requestsFilterOptions = [
FilterListModel(title: "Cars", isSelected: true, id: 1), // FilterListModel(title: "Cars", isSelected: true, id: 1),
FilterListModel(title: "Spare Parts", isSelected: false, id: 2), // FilterListModel(title: "Spare Parts", isSelected: false, id: 2),
]; // ];
notifyListeners(); // notifyListeners();
} // }
//
applyFilterOnRequestsVM({required int index}) { // applyFilterOnRequestsVM({required int index}) {
if (requestsFilterOptions.isEmpty) return; // if (requestsFilterOptions.isEmpty) return;
for (var value in requestsFilterOptions) { // for (var value in requestsFilterOptions) {
value.isSelected = false; // value.isSelected = false;
} // }
requestsFilterOptions[index].isSelected = true; // requestsFilterOptions[index].isSelected = true;
notifyListeners(); // notifyListeners();
} // }
//
List<File> pickedVehicleImages = []; // List<File> pickedVehicleImages = [];
String vehicleImageError = ""; // String vehicleImageError = "";
//
void removeImageFromList(String filePath) { // void removeImageFromList(String filePath) {
int index = pickedVehicleImages.indexWhere((element) => element.path == filePath); // int index = pickedVehicleImages.indexWhere((element) => element.path == filePath);
if (index == -1) { // if (index == -1) {
return; // return;
} // }
pickedVehicleImages.removeAt(index); // pickedVehicleImages.removeAt(index);
notifyListeners(); // notifyListeners();
} // }
//
void pickMultipleImages() async { // void pickMultipleImages() async {
List<File> Images = await commonServices.pickMultipleImages(); // List<File> Images = await commonServices.pickMultipleImages();
pickedVehicleImages.addAll(Images); // pickedVehicleImages.addAll(Images);
if (pickedVehicleImages.isNotEmpty) vehicleImageError = ""; // if (pickedVehicleImages.isNotEmpty) vehicleImageError = "";
notifyListeners(); // notifyListeners();
} // }
//
bool isFetchingRequestType = false; // bool isFetchingRequestType = false;
bool isFetchingVehicleType = true; // bool isFetchingVehicleType = true;
bool isFetchingVehicleDetail = false; // bool isFetchingVehicleDetail = false;
List<Enums> requestTypes = []; // List<EnumsModel> requestTypes = [];
List<VehicleTypeModel> vehicleTypes = []; // List<VehicleTypeModel> vehicleTypes = [];
VehicleDetailsModel? vehicleDetails; // VehicleDetailsModel? vehicleDetails;
List<VehicleBrandsModel> vehicleBrands = []; // List<VehicleBrandsModel> vehicleBrands = [];
List<VehicleModel> vehicleModels = []; // List<VehicleModel> vehicleModels = [];
List<VehicleYearModel> vehicleModelYears = []; // List<VehicleYearModel> vehicleModelYears = [];
List<VehicleCountryModel> vehicleCountries = []; // List<VehicleCountryModel> vehicleCountries = [];
List<VehicleCityModel> vehicleCities = []; // List<VehicleCityModel> vehicleCities = [];
//
SelectionModel requestTypeId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); // SelectionModel requestTypeId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
//
getRequestTypes() async { // getRequestTypes() async {
requestTypeId.selectedId = -1; // requestTypeId.selectedId = -1;
isFetchingRequestType = true; // isFetchingRequestType = true;
requestTypes = await commonRepo.getEnumTypeValues(enumTypeID: 16); //TODO: 16 is to get Request types // requestTypes = await commonRepo.getEnumTypeValues(enumTypeID: 16); //TODO: 16 is to get Request types
isFetchingRequestType = false; // isFetchingRequestType = false;
notifyListeners(); // notifyListeners();
} // }
//
void updateSelectionRequestTypeId(SelectionModel id) async { // void updateSelectionRequestTypeId(SelectionModel id) async {
requestTypeId = id; // requestTypeId = id;
getVehicleTypes(); // getVehicleTypes();
notifyListeners(); // notifyListeners();
} // }
//
SelectionModel vehicleTypeId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); // SelectionModel vehicleTypeId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
//
Future<void> getVehicleTypes() async { // Future<void> getVehicleTypes() async {
reset(); // reset();
isFetchingVehicleType = true; // isFetchingVehicleType = true;
vehicleTypes = await commonRepo.getVehicleTypes(); // vehicleTypes = await commonRepo.getVehicleTypes();
isFetchingVehicleType = false; // isFetchingVehicleType = false;
notifyListeners(); // notifyListeners();
} // }
//
reset() { // reset() {
vehicleTypeId.selectedId = -1; // vehicleTypeId.selectedId = -1;
vehicleBrandId.selectedId = -1; // vehicleBrandId.selectedId = -1;
vehicleModelId.selectedId = -1; // vehicleModelId.selectedId = -1;
vehicleModelYearId.selectedId = -1; // vehicleModelYearId.selectedId = -1;
vehicleCountryId.selectedId = -1; // vehicleCountryId.selectedId = -1;
vehicleCityId.selectedId = -1; // vehicleCityId.selectedId = -1;
} // }
//
void updateSelectionVehicleTypeId(SelectionModel id) async { // void updateSelectionVehicleTypeId(SelectionModel id) async {
vehicleTypeId = id; // vehicleTypeId = id;
getVehicleBrandsByVehicleTypeId(); // getVehicleBrandsByVehicleTypeId();
notifyListeners(); // notifyListeners();
} // }
//
Future<void> getVehicleBrandsByVehicleTypeId() async { // Future<void> getVehicleBrandsByVehicleTypeId() async {
// if (vehicleBrandId.selectedId == -1) { // // if (vehicleBrandId.selectedId == -1) {
// return; // // return;
// } // // }
isFetchingVehicleDetail = true; // isFetchingVehicleDetail = true;
notifyListeners(); // notifyListeners();
vehicleDetails = await commonRepo.getVehicleDetails(vehicleTypeId: vehicleTypeId.selectedId); // vehicleDetails = await commonRepo.getVehicleDetails(vehicleTypeId: vehicleTypeId.selectedId);
//
if (vehicleDetails != null) { // if (vehicleDetails != null) {
vehicleBrands = vehicleDetails!.vehicleBrands!; // vehicleBrands = vehicleDetails!.vehicleBrands!;
vehicleModels = vehicleDetails!.vehicleModels!; // vehicleModels = vehicleDetails!.vehicleModels!;
vehicleModelYears = vehicleDetails!.vehicleModelYears!; // vehicleModelYears = vehicleDetails!.vehicleModelYears!;
vehicleCountries = vehicleDetails!.vehicleCountries!; // vehicleCountries = vehicleDetails!.vehicleCountries!;
} // }
isFetchingVehicleDetail = false; // isFetchingVehicleDetail = false;
notifyListeners(); // notifyListeners();
} // }
//
SelectionModel vehicleBrandId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); // SelectionModel vehicleBrandId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
//
void updateSelectionVehicleBrandId(SelectionModel id) { // void updateSelectionVehicleBrandId(SelectionModel id) {
vehicleBrandId = id; // vehicleBrandId = id;
vehicleModelId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); // vehicleModelId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
vehicleModelYearId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); // vehicleModelYearId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
notifyListeners(); // notifyListeners();
} // }
//
SelectionModel vehicleModelId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); // SelectionModel vehicleModelId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
//
void updateSelectionVehicleModelId(SelectionModel id) { // void updateSelectionVehicleModelId(SelectionModel id) {
vehicleModelId = id; // vehicleModelId = id;
vehicleModelYearId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); // vehicleModelYearId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
notifyListeners(); // notifyListeners();
} // }
//
SelectionModel vehicleModelYearId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); // SelectionModel vehicleModelYearId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
//
void updateSelectionVehicleModelYearId(SelectionModel id) { // void updateSelectionVehicleModelYearId(SelectionModel id) {
vehicleModelYearId = id; // vehicleModelYearId = id;
notifyListeners(); // notifyListeners();
} // }
//
bool isShippingDeliveryEnabled = false; // bool isShippingDeliveryEnabled = false;
//
void updateShippingDeliverEnabled(bool v) { // void updateShippingDeliverEnabled(bool v) {
isShippingDeliveryEnabled = v; // isShippingDeliveryEnabled = v;
notifyListeners(); // notifyListeners();
} // }
//
bool isCountryFetching = false; // bool isCountryFetching = false;
SelectionModel vehicleCountryId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); // SelectionModel vehicleCountryId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
//
void updateSelectionVehicleCountryId(SelectionModel id) async { // void updateSelectionVehicleCountryId(SelectionModel id) async {
vehicleCountryId = id; // vehicleCountryId = id;
isCountryFetching = true; // isCountryFetching = true;
notifyListeners(); // notifyListeners();
vehicleCities = await commonRepo.getVehicleCities(countryId: vehicleCountryId.selectedId); // vehicleCities = await commonRepo.getVehicleCities(countryId: vehicleCountryId.selectedId);
isCountryFetching = false; // isCountryFetching = false;
notifyListeners(); // notifyListeners();
} // }
//
SelectionModel vehicleCityId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); // SelectionModel vehicleCityId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
//
void updateSelectionVehicleCityId(SelectionModel id) { // void updateSelectionVehicleCityId(SelectionModel id) {
vehicleCityId = id; // vehicleCityId = id;
notifyListeners(); // notifyListeners();
} // }
//
//Request Management // //Request Management
String price = "", description = ""; // String price = "", description = "";
//
updatePrice(String v) { // updatePrice(String v) {
price = v; // price = v;
} // }
//
updateDescription(String v) { // updateDescription(String v) {
description = v; // description = v;
} // }
//
Future<GenericRespModel?> createRequest() async { // Future<GenericRespModel?> createRequest() async {
if (validate()) { // if (validate()) {
Map<String, dynamic> m = { // Map<String, dynamic> m = {
"customerID": AppState().getUser.data!.userInfo!.customerId ?? 0, // "customerID": AppState().getUser.data!.userInfo!.customerId ?? 0,
"requestType": requestTypeId.selectedId, // "requestType": requestTypeId.selectedId,
"vehicleTypeID": vehicleTypeId.selectedId, // "vehicleTypeID": vehicleTypeId.selectedId,
"brand": vehicleBrandId.selectedOption, // "brand": vehicleBrandId.selectedOption,
"model": vehicleModelId.selectedOption, // "model": vehicleModelId.selectedOption,
"year": vehicleModelYearId.selectedOption, // "year": vehicleModelYearId.selectedOption,
"isNew": true, // "isNew": true,
"countryID": vehicleCountryId.selectedId, // "countryID": vehicleCountryId.selectedId,
"cityID": vehicleCityId.selectedId, // "cityID": vehicleCityId.selectedId,
"price": price, // "price": price,
"description": description, // "description": description,
"isSpecialServiceNeeded": false, // "isSpecialServiceNeeded": false,
"requestImages": [] // "requestImages": []
}; // };
GenericRespModel respModel = await requestRepo.createRequest(m); // GenericRespModel respModel = await requestRepo.createRequest(m);
return respModel; // return respModel;
} else { // } else {
return null; // return null;
} // }
} // }
//
bool validate() { // bool validate() {
bool isValid = true; // bool isValid = true;
if (requestTypeId.selectedId == -1) { // if (requestTypeId.selectedId == -1) {
Utils.showToast("Please select valid Request Type"); // Utils.showToast("Please select valid Request Type");
isValid = false; // isValid = false;
} else if (vehicleTypeId.selectedId == -1) { // } else if (vehicleTypeId.selectedId == -1) {
Utils.showToast("Please select valid Vehicle Type"); // Utils.showToast("Please select valid Vehicle Type");
isValid = false; // isValid = false;
} else if (vehicleBrandId.selectedId == -1) { // } else if (vehicleBrandId.selectedId == -1) {
Utils.showToast("Please select valid Brand"); // Utils.showToast("Please select valid Brand");
isValid = false; // isValid = false;
} else if (vehicleModelId.selectedId == -1) { // } else if (vehicleModelId.selectedId == -1) {
Utils.showToast("Please select valid Model"); // Utils.showToast("Please select valid Model");
isValid = false; // isValid = false;
} else if (vehicleModelYearId.selectedId == -1) { // } else if (vehicleModelYearId.selectedId == -1) {
Utils.showToast("Please select valid Year"); // Utils.showToast("Please select valid Year");
isValid = false; // isValid = false;
} else if (vehicleCountryId.selectedId == -1) { // } else if (vehicleCountryId.selectedId == -1) {
Utils.showToast("Please select valid Country"); // Utils.showToast("Please select valid Country");
isValid = false; // isValid = false;
} else if (vehicleCityId.selectedId == -1) { // } else if (vehicleCityId.selectedId == -1) {
Utils.showToast("Please select valid City"); // Utils.showToast("Please select valid City");
isValid = false; // isValid = false;
} else if (price.isEmpty) { // } else if (price.isEmpty) {
Utils.showToast("Please add valid Price"); // Utils.showToast("Please add valid Price");
isValid = false; // isValid = false;
} else if (description.isEmpty) { // } else if (description.isEmpty) {
Utils.showToast("Please add valid Description"); // Utils.showToast("Please add valid Description");
isValid = false; // isValid = false;
} // }
return isValid; // return isValid;
} // }
//
bool isRequestLoading = true; // bool isRequestLoading = true;
List<RequestModel> requests = []; // List<RequestModel> requests = [];
//
getRequests() async { // getRequests() async {
isRequestLoading = true; // isRequestLoading = true;
notifyListeners(); // notifyListeners();
//
int selectedRequestType; // int selectedRequestType;
// Find the FilterListModel with isSelected equal to true // // Find the FilterListModel with isSelected equal to true
//
requests = await requestRepo.getRequests( // requests = await requestRepo.getRequests(
{ // {
"customerID": AppState().getUser.data!.userInfo!.customerId, // "customerID": AppState().getUser.data!.userInfo!.customerId,
"pageSize": 100, // "pageSize": 100,
"pageIndex": 0, // "pageIndex": 0,
"requestType": requestsFilterOptions.firstWhere((element) => element.isSelected).id, // "requestType": requestsFilterOptions.firstWhere((element) => element.isSelected).id,
}, // },
); // );
isRequestLoading = false; // isRequestLoading = false;
notifyListeners(); // notifyListeners();
} // }
} // }

@ -10,13 +10,10 @@ import 'package:mc_common_app/widgets/common_widgets/search_entity_widget.dart';
import 'package:mc_common_app/widgets/dropdown/dropdow_field.dart'; import 'package:mc_common_app/widgets/dropdown/dropdow_field.dart';
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart'; import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:sizer/sizer.dart';
class AdsFilterView extends StatelessWidget { class AdsFilterView extends StatelessWidget {
const AdsFilterView({super.key}); const AdsFilterView({super.key});
//
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(

Loading…
Cancel
Save