diff --git a/lib/classes/consts.dart b/lib/classes/consts.dart index 51f3faa..f2378be 100644 --- a/lib/classes/consts.dart +++ b/lib/classes/consts.dart @@ -118,6 +118,13 @@ class ApiConsts { static String assignDealerToBranch = "${baseUrlServices}api/ServiceProviders/BranchUser_Create"; static String removeDealerFromBranch = "${baseUrlServices}api/ServiceProviders/BranchUser_Update"; + //Master & Common + static String getEnumTypeValues = "${baseUrlServices}api/Common/GetEnumTypeValues"; + + //Requests + static String createRequest = "${baseUrlServices}api/RequestManagement/Request_Create"; + static String getRequest = "${baseUrlServices}api/RequestManagement/Request_Get"; + static List closingUrls = ["PayFortResponse"]; } diff --git a/lib/config/routes.dart b/lib/config/routes.dart index c852ecc..09a5b08 100644 --- a/lib/config/routes.dart +++ b/lib/config/routes.dart @@ -66,6 +66,11 @@ class AppRoutes { static const String mySubscriptionsPage = "/mySubscriptionsPage"; static const String subscriptionsPage = "/subscriptionsPage"; + //Requests + static const String createRequestPage = "/createRequestPage"; + static const String offersListPage = "/offersListPage"; + + static const String initialRoute = splash; static final Map routes = { diff --git a/lib/extensions/string_extensions.dart b/lib/extensions/string_extensions.dart index 2f07f17..6f1ff63 100644 --- a/lib/extensions/string_extensions.dart +++ b/lib/extensions/string_extensions.dart @@ -152,6 +152,28 @@ extension FormatDate on String { } } +extension RequestEnum on int { + RequestStatus toRequestStatusEnum() { + if (this == 1) { + return RequestStatus.submitted; + } else if (this == 2) { + return RequestStatus.inProgress; + } else if (this == 3) { + return RequestStatus.completed; + } else if (this == 4) { + return RequestStatus.cancelled; + } else if (this == 5) { + return RequestStatus.paid; + } else if (this == 6) { + return RequestStatus.expired; + } else if (this == 7) { + return RequestStatus.shipping; + } else { + return RequestStatus.pending; + } + } +} + extension AdPostEnum on int { AdPostStatus toAdPostEnum() { if (this == 1) { diff --git a/lib/models/enums.dart b/lib/models/enums.dart new file mode 100644 index 0000000..6b07f3e --- /dev/null +++ b/lib/models/enums.dart @@ -0,0 +1,31 @@ +class Enums { + int id; + int enumTypeId; + String enumValueStr; + int enumValue; + bool isActive; + + Enums({ + required this.id, + required this.enumTypeId, + required this.enumValueStr, + required this.enumValue, + required this.isActive, + }); + + factory Enums.fromJson(Map json) => Enums( + id: json["id"], + enumTypeId: json["enumTypeID"], + enumValueStr: json["enumValueStr"], + enumValue: json["enumValue"], + isActive: json["isActive"], + ); + + Map toJson() => { + "id": id, + "enumTypeID": enumTypeId, + "enumValueStr": enumValueStr, + "enumValue": enumValue, + "isActive": isActive, + }; +} diff --git a/lib/models/generic_resp_model.dart b/lib/models/generic_resp_model.dart index 89d935d..8dd3bb9 100644 --- a/lib/models/generic_resp_model.dart +++ b/lib/models/generic_resp_model.dart @@ -2,23 +2,29 @@ class GenericRespModel { GenericRespModel({ this.data, this.messageStatus, - this.totalItemsCount, + this.totalItemsCount, this.message, }); dynamic data; int? messageStatus; int? totalItemsCount; + String? message; - factory GenericRespModel.fromJson(Map json) => GenericRespModel( + + factory GenericRespModel.fromJson(Map json) => + GenericRespModel( data: json["data"], messageStatus: json["messageStatus"], totalItemsCount: json["totalItemsCount"], + message: json["message"], ); - Map toJson() => { + Map toJson() => + { "data": data, "messageStatus": messageStatus, "totalItemsCount": totalItemsCount, + "message": message, }; } @@ -136,32 +142,31 @@ class VehiclePosting { String? phoneNo; String? whatsAppNo; - VehiclePosting( - {this.id, - this.userID, - this.vehicleType, - this.vehicleModelID, - this.vehicleModelYearID, - this.vehicleColorID, - this.vehicleCategoryID, - this.vehicleConditionID, - this.vehicleMileageID, - this.vehicleTransmissionID, - this.vehicleSellerTypeID, - this.cityID, - this.price, - this.vehicleVIN, - this.vehicleDescription, - this.vehicleTitle, - this.vehicleDescriptionN, - this.isFinanceAvailable, - this.warantyYears, - this.demandAmount, - this.adStatus, - this.phoneNo, - this.whatsAppNo, - this.vehiclePostingImages, - this.vehiclePostingDamageParts}); + VehiclePosting({this.id, + this.userID, + this.vehicleType, + this.vehicleModelID, + this.vehicleModelYearID, + this.vehicleColorID, + this.vehicleCategoryID, + this.vehicleConditionID, + this.vehicleMileageID, + this.vehicleTransmissionID, + this.vehicleSellerTypeID, + this.cityID, + this.price, + this.vehicleVIN, + this.vehicleDescription, + this.vehicleTitle, + this.vehicleDescriptionN, + this.isFinanceAvailable, + this.warantyYears, + this.demandAmount, + this.adStatus, + this.phoneNo, + this.whatsAppNo, + this.vehiclePostingImages, + this.vehiclePostingDamageParts}); VehiclePosting.fromJson(Map json) { id = json['id']; diff --git a/lib/repositories/common_repo.dart b/lib/repositories/common_repo.dart index 13caa08..68e3614 100644 --- a/lib/repositories/common_repo.dart +++ b/lib/repositories/common_repo.dart @@ -10,11 +10,17 @@ import 'package:mc_common_app/models/user/cities.dart'; import 'package:mc_common_app/models/user/country.dart'; import 'package:mc_common_app/models/user/role.dart'; +import '../models/advertisment_models/vehicle_details_models.dart'; +import '../models/enums.dart'; + abstract class CommonRepo { Future getAllCountries(); Future getAllCites(String countryId); + //TODO: Needs to remove cities method one of them + Future> getVehicleCities({required int countryId}); + Future getRoles(); Future> getMyAppointments(); @@ -26,6 +32,13 @@ abstract class CommonRepo { // Future> getProviderServiceCategories(); // Future> getProviderServices({required int categoryId}); + + Future> getVehicleTypes(); + + //TODO: Needs to remove common methods from AD's repo and delete all repeated methods. + Future getVehicleDetails({int? vehicleTypeId, int? vehicleBrandId}); + + Future> getEnumTypeValues({int? enumTypeID, String? enumTypeName}); } class CommonRepoImp implements CommonRepo { @@ -96,7 +109,69 @@ class CommonRepoImp implements CommonRepo { SSPhotoScheduleModel ssPhotoScheduleModel = SSPhotoScheduleModel.fromJson(genericRespModel.data[0]); return ssPhotoScheduleModel; } - // + + @override + Future> getVehicleTypes() async { + GenericRespModel adsGenericModel = await apiClient.getJsonForObject(token: appState.getUser.data!.accessToken, (json) => GenericRespModel.fromJson(json), ApiConsts.vehicleTypeGet); + List vehicleTypes = List.generate(adsGenericModel.data.length, (index) => VehicleTypeModel.fromJson(adsGenericModel.data[index])); + return vehicleTypes; + } + + @override + Future getVehicleDetails({int? vehicleTypeId, int? vehicleBrandId}) async { + var postParams = { + "vehicleType": vehicleTypeId ?? 0, + "isVehicleBrand": "true", + "vehicleBrand": vehicleBrandId ?? 0, + "isVehicleCategory": "true", + "isVehicleColor": "true", + "isVehicleCondition": "true", + "isVehicleMileage": "true", + "isVehicleModel": "true", + "isVehicleModelYear": "true", + "isVehiclePriceRange": "true", + "isVehiclePricingMethod": "true", + "isVehcileSellerType": "true", + "isVehicleTransmission": "true", + "isCountry": "true" + }; + + String token = appState.getUser.data!.accessToken ?? ""; + GenericRespModel adsGenericModel = await apiClient.postJsonForObject( + (json) => GenericRespModel.fromJson(json), + ApiConsts.vehicleDetailsMaster, + postParams, + token: token, + ); + VehicleDetailsModel vehicleDetails = VehicleDetailsModel.fromJson(adsGenericModel.data); + return vehicleDetails; + } + + @override + Future> getVehicleCities({required int countryId}) async { + var postParams = { + "CountryID": countryId.toString(), + }; + GenericRespModel adsGenericModel = + await apiClient.getJsonForObject(token: appState.getUser.data!.accessToken, (json) => GenericRespModel.fromJson(json), ApiConsts.vehicleCityGet, queryParameters: postParams); + List vehicleCities = List.generate(adsGenericModel.data.length, (index) => VehicleCityModel.fromJson(adsGenericModel.data[index])); + return vehicleCities; + } + + @override + Future> getEnumTypeValues({int? enumTypeID, String? enumTypeName}) async { + var postParams = {"enumTypeID": (enumTypeID ?? 0).toString(), "enumTypeName": enumTypeName ?? ""}; + GenericRespModel enumGenericModel = await apiClient.postJsonForObject( + (json) => GenericRespModel.fromJson(json), + ApiConsts.getEnumTypeValues, + postParams, + token: appState.getUser.data!.accessToken, + ); + + List vehicleCities = List.generate(enumGenericModel.data.length, (index) => Enums.fromJson(enumGenericModel.data[index])); + return vehicleCities; + } +// // @override // Future> getProviderServiceCategories() async { // GenericRespModel adsGenericModel = await apiClient.getJsonForObject(token: appState.getUser.data!.accessToken, (json) => GenericRespModel.fromJson(json), ApiConsts.serviceCategoryGet); diff --git a/lib/utils/enums.dart b/lib/utils/enums.dart index 2e45e3c..052963e 100644 --- a/lib/utils/enums.dart +++ b/lib/utils/enums.dart @@ -41,6 +41,33 @@ enum AdPostStatus { reserveCancel, } +enum RequestStatus { + pending, + submitted, + inProgress, + completed, + cancelled, + paid, + expired, + shipping, +} + +//TODO: Needs to remove +// public enum RequestType : int +// { +// Special_Car_Request = 1, +// Service_Request = 2 //SparePart +// } +// public enum OfferStatus : int +// { +// Offer = 1,//SP +// Negotiate = 2, +// Accepted = 3, +// Rejected = 4, +// Cancelled = 5 //SP +// } + + enum PaymentMethodsEnum { mada, visa, diff --git a/lib/view_models/ad_view_model.dart b/lib/view_models/ad_view_model.dart index 31076db..c732f7b 100644 --- a/lib/view_models/ad_view_model.dart +++ b/lib/view_models/ad_view_model.dart @@ -232,7 +232,8 @@ class AdVM extends BaseVM { Future getMyReservedAds() async { isFetchingLists = true; setState(ViewState.busy); - myReservedAdsRespModel = await adsRepo.getMyReservedAds(); + //TODO: BREAKING + // myReservedAdsRespModel = await adsRepo.getMyReservedAds(); isFetchingLists = false; setState(ViewState.idle); } diff --git a/lib/views/advertisement/ad_creation_steps/damage_parts_container.dart b/lib/views/advertisement/ad_creation_steps/damage_parts_container.dart index 4004158..73912f4 100644 --- a/lib/views/advertisement/ad_creation_steps/damage_parts_container.dart +++ b/lib/views/advertisement/ad_creation_steps/damage_parts_container.dart @@ -129,7 +129,14 @@ class DamageParts extends StatelessWidget { ).paddingOnly(right: 10) ], ], - ).toWhiteContainer(width: double.infinity, allPading: 12, margin: const EdgeInsets.symmetric(horizontal: 21, vertical: 4)); + ).toWhiteContainer( + width: double.infinity, + allPading: 12, + margin: const EdgeInsets.symmetric( + horizontal: 21, + vertical: 4, + ), + ); }, ), // DottedRectContainer( diff --git a/lib/widgets/dash_rect.dart b/lib/widgets/dash_rect.dart new file mode 100644 index 0000000..2d8c0cb --- /dev/null +++ b/lib/widgets/dash_rect.dart @@ -0,0 +1,101 @@ +import 'package:flutter/material.dart'; +import 'dart:math' as math; + +class DashedRect extends StatelessWidget { + final Color color; + final double strokeWidth; + final double gap; + + DashedRect({this.color = Colors.black, this.strokeWidth = 1.0, this.gap = 5.0}); + + @override + Widget build(BuildContext context) { + return Padding( + padding: EdgeInsets.all(strokeWidth / 2), + child: CustomPaint( + painter: DashRectPainter(color: color, strokeWidth: strokeWidth, gap: gap), + ), + ); + } +} + +class DashRectPainter extends CustomPainter { + double strokeWidth; + Color color; + double gap; + + DashRectPainter({this.strokeWidth = 5.0, this.color = Colors.red, this.gap = 5.0}); + + @override + void paint(Canvas canvas, Size size) { + Paint dashedPaint = Paint() + ..color = color + ..strokeWidth = strokeWidth + ..style = PaintingStyle.stroke; + + double x = size.width; + double y = size.height; + + Path _topPath = getDashedPath( + a: math.Point(0, 0), + b: math.Point(x, 0), + gap: gap, + ); + + Path _rightPath = getDashedPath( + a: math.Point(x, 0), + b: math.Point(x, y), + gap: gap, + ); + + Path _bottomPath = getDashedPath( + a: math.Point(0, y), + b: math.Point(x, y), + gap: gap, + ); + + Path _leftPath = getDashedPath( + a: math.Point(0, 0), + b: math.Point(0.001, y), + gap: gap, + ); + + canvas.drawPath(_topPath, dashedPaint); + canvas.drawPath(_rightPath, dashedPaint); + canvas.drawPath(_bottomPath, dashedPaint); + canvas.drawPath(_leftPath, dashedPaint); + } + + Path getDashedPath({ + required math.Point a, + required math.Point b, + required gap, + }) { + Size size = Size(b.x - a.x, b.y - a.y); + Path path = Path(); + path.moveTo(a.x, a.y); + bool shouldDraw = true; + math.Point currentPoint = math.Point(a.x, a.y); + + num radians = math.atan(size.height / size.width); + + num dx = math.cos(radians) * gap < 0 ? math.cos(radians) * gap * -1 : math.cos(radians) * gap; + + num dy = math.sin(radians) * gap < 0 ? math.sin(radians) * gap * -1 : math.sin(radians) * gap; + + while (currentPoint.x <= b.x && currentPoint.y <= b.y) { + shouldDraw ? path.lineTo(currentPoint.x.toDouble(), currentPoint.y.toDouble()) : path.moveTo(currentPoint.x.toDouble(), currentPoint.y.toDouble()); + shouldDraw = !shouldDraw; + currentPoint = math.Point( + currentPoint.x + dx, + currentPoint.y + dy, + ); + } + return path; + } + + @override + bool shouldRepaint(CustomPainter oldDelegate) { + return true; + } +} diff --git a/lib/widgets/dropdown/dropdow_field.dart b/lib/widgets/dropdown/dropdow_field.dart index e09ba88..7397ef8 100644 --- a/lib/widgets/dropdown/dropdow_field.dart +++ b/lib/widgets/dropdown/dropdow_field.dart @@ -43,11 +43,12 @@ class _DropdownFieldState extends State { @override void initState() { super.initState(); - dropdownValue = widget.dropdownValue; + } @override Widget build(BuildContext context) { + dropdownValue = widget.dropdownValue; return Column( children: [ Container(