Request Management 1.0

models_removal
devshafique 1 year ago
parent f2224a3f76
commit 4b08a974bb

@ -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<String> closingUrls = ["PayFortResponse"];
}

@ -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<String, WidgetBuilder> routes = {

@ -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) {

@ -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<String, dynamic> json) => Enums(
id: json["id"],
enumTypeId: json["enumTypeID"],
enumValueStr: json["enumValueStr"],
enumValue: json["enumValue"],
isActive: json["isActive"],
);
Map<String, dynamic> toJson() => {
"id": id,
"enumTypeID": enumTypeId,
"enumValueStr": enumValueStr,
"enumValue": enumValue,
"isActive": isActive,
};
}

@ -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<String, dynamic> json) => GenericRespModel(
factory GenericRespModel.fromJson(Map<String, dynamic> json) =>
GenericRespModel(
data: json["data"],
messageStatus: json["messageStatus"],
totalItemsCount: json["totalItemsCount"],
message: json["message"],
);
Map<String, dynamic> toJson() => {
Map<String, dynamic> 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<String, dynamic> json) {
id = json['id'];

@ -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<Country> getAllCountries();
Future<Cities> getAllCites(String countryId);
//TODO: Needs to remove cities method one of them
Future<List<VehicleCityModel>> getVehicleCities({required int countryId});
Future<Role> getRoles();
Future<List<AppointmentListModel>> getMyAppointments();
@ -26,6 +32,13 @@ abstract class CommonRepo {
// Future<List<ProviderCategoryModel>> getProviderServiceCategories();
// Future<List<ProviderServiceModel>> getProviderServices({required int categoryId});
Future<List<VehicleTypeModel>> getVehicleTypes();
//TODO: Needs to remove common methods from AD's repo and delete all repeated methods.
Future<VehicleDetailsModel> getVehicleDetails({int? vehicleTypeId, int? vehicleBrandId});
Future<List<Enums>> 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<List<VehicleTypeModel>> getVehicleTypes() async {
GenericRespModel adsGenericModel = await apiClient.getJsonForObject(token: appState.getUser.data!.accessToken, (json) => GenericRespModel.fromJson(json), ApiConsts.vehicleTypeGet);
List<VehicleTypeModel> vehicleTypes = List.generate(adsGenericModel.data.length, (index) => VehicleTypeModel.fromJson(adsGenericModel.data[index]));
return vehicleTypes;
}
@override
Future<VehicleDetailsModel> 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<List<VehicleCityModel>> 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<VehicleCityModel> vehicleCities = List.generate(adsGenericModel.data.length, (index) => VehicleCityModel.fromJson(adsGenericModel.data[index]));
return vehicleCities;
}
@override
Future<List<Enums>> 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<Enums> vehicleCities = List.generate(enumGenericModel.data.length, (index) => Enums.fromJson(enumGenericModel.data[index]));
return vehicleCities;
}
//
// @override
// Future<List<ProviderCategoryModel>> getProviderServiceCategories() async {
// GenericRespModel adsGenericModel = await apiClient.getJsonForObject(token: appState.getUser.data!.accessToken, (json) => GenericRespModel.fromJson(json), ApiConsts.serviceCategoryGet);

@ -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,

@ -232,7 +232,8 @@ class AdVM extends BaseVM {
Future<void> getMyReservedAds() async {
isFetchingLists = true;
setState(ViewState.busy);
myReservedAdsRespModel = await adsRepo.getMyReservedAds();
//TODO: BREAKING
// myReservedAdsRespModel = await adsRepo.getMyReservedAds();
isFetchingLists = false;
setState(ViewState.idle);
}

@ -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(

@ -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<double> a,
required math.Point<double> 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;
}
}

@ -43,11 +43,12 @@ class _DropdownFieldState extends State<DropdownField> {
@override
void initState() {
super.initState();
dropdownValue = widget.dropdownValue;
}
@override
Widget build(BuildContext context) {
dropdownValue = widget.dropdownValue;
return Column(
children: [
Container(

Loading…
Cancel
Save