Merged Ads Module

merge-requests/9/head
FaizHashmiCS22 3 years ago
parent 79a8671e77
commit 9bf716eb39

@ -68,25 +68,25 @@ class ApiClientImp implements ApiClient {
@override
Future<U> postJsonForObject<T, U>(FactoryConstructor<U> factoryConstructor, String url, T jsonObject,
{String? token, Map<String, dynamic>? queryParameters, Map<String, String>? headers, int retryTimes = 0}) async {
var _headers = {'Accept': 'application/json'};
var headers0 = {'Accept': 'application/json'};
if (headers != null && headers.isNotEmpty) {
_headers.addAll(headers);
headers0.addAll(headers);
}
if (!kReleaseMode) {
debugPrint("Url:$url");
debugPrint("body:$jsonObject");
}
var response = await postJsonForResponse(url, jsonObject, token: token, queryParameters: queryParameters, headers: _headers, retryTimes: retryTimes);
var response = await postJsonForResponse(url, jsonObject, token: token, queryParameters: queryParameters, headers: headers0, retryTimes: retryTimes);
try {
if (!kReleaseMode) {
debugPrint("res121:" + response.body);
debugPrint("res121:" + response.statusCode.toString());
debugPrint("res121:${response.body}");
debugPrint("res121:${response.statusCode}");
}
var jsonData = jsonDecode(response.body);
return factoryConstructor(jsonData);
} catch (ex) {
debugPrint(ex.toString());
debugPrint("exception:" + ex.toString());
debugPrint("exception:$ex");
throw APIException(APIException.BAD_RESPONSE_FORMAT, arguments: ex);
}
}
@ -115,28 +115,28 @@ class ApiClientImp implements ApiClient {
int retryTimes = 0,
}) async {
try {
var _headers = <String, String>{};
var headers0 = <String, String>{};
if (token != null) {
_headers['Authorization'] = 'Bearer $token';
headers0['Authorization'] = 'Bearer $token';
}
if (headers != null && headers.isNotEmpty) {
_headers.addAll(headers);
headers0.addAll(headers);
}
if (queryParameters != null) {
var queryString = Uri(queryParameters: queryParameters).query;
url = url + '?' + queryString;
url = '$url?$queryString';
}
Response response;
response = await _post(Uri.parse(url), body: requestBody, headers: _headers).timeout(const Duration(seconds: 100));
response = await _post(Uri.parse(url), body: requestBody, headers: headers0).timeout(const Duration(seconds: 100));
if (!kReleaseMode) {
debugPrint("Url:$url");
debugPrint("body:$requestBody");
debugPrint("res: " + response.body);
debugPrint("res: ${response.body}");
}
if (response.statusCode >= 200 && response.statusCode < 500) {
var jsonData = jsonDecode(response.body);
@ -175,7 +175,7 @@ class ApiClientImp implements ApiClient {
throw APIException(APIException.OTHER, arguments: e);
}
} catch (ex) {
debugPrint("exception1:" + ex.toString());
debugPrint("exception1:$ex");
throw APIException(APIException.BAD_RESPONSE_FORMAT, arguments: ex);
}
}
@ -197,19 +197,19 @@ class ApiClientImp implements ApiClient {
@override
Future<U> getJsonForObject<T, U>(FactoryConstructor<U> factoryConstructor, String url,
{String? token, Map<String, dynamic>? queryParameters, Map<String, String>? headers, int retryTimes = 0}) async {
var _headers = {'Accept': 'application/json'};
var headers0 = {'Accept': 'application/json'};
if (headers != null && headers.isNotEmpty) {
_headers.addAll(headers);
headers0.addAll(headers);
}
var response = await getJsonForResponse(url, token: token, queryParameters: queryParameters, headers: _headers, retryTimes: retryTimes);
var response = await getJsonForResponse(url, token: token, queryParameters: queryParameters, headers: headers0, retryTimes: retryTimes);
try {
if (!kReleaseMode) {
debugPrint("res:" + response.body);
debugPrint("res:${response.body}");
}
var jsonData = jsonDecode(response.body);
return factoryConstructor(jsonData);
} catch (ex) {
debugPrint("exception:" + response.body);
debugPrint("exception:${response.body}");
throw APIException(APIException.BAD_RESPONSE_FORMAT, arguments: ex);
}
}
@ -228,27 +228,28 @@ class ApiClientImp implements ApiClient {
Future<Response> _getForResponse(String url, {String? token, Map<String, dynamic>? queryParameters, Map<String, String>? headers, int retryTimes = 0}) async {
try {
var _headers = <String, String>{};
var headers0 = <String, String>{};
if (token != null) {
_headers['Authorization'] = 'Bearer $token';
headers0['Authorization'] = 'Bearer $token';
}
if (headers != null && headers.isNotEmpty) {
_headers.addAll(headers);
headers0.addAll(headers);
}
if (queryParameters != null) {
String queryString = Uri(queryParameters: queryParameters).query;
if (isFirstCall) url = url + '?' + queryString.toString();
if (isFirstCall) url = '$url?$queryString';
}
if (!kReleaseMode) {
debugPrint("Url:$url");
debugPrint("queryParameters:$queryParameters");
}
var response = await _get(Uri.parse(url), headers: _headers).timeout(const Duration(seconds: 60));
var response = await _get(Uri.parse(url), headers: headers0).timeout(const Duration(seconds: 60));
if (!kReleaseMode) {
debugPrint("res: " + response.body.toString());
debugPrint("res: ${response.body}");
debugPrint("resCode: ${response.statusCode}");
}
if (response.statusCode >= 200 && response.statusCode < 500) {
var jsonData = jsonDecode(response.body);
@ -286,8 +287,6 @@ class ApiClientImp implements ApiClient {
} else {
throw APIException(APIException.OTHER, arguments: e);
}
} catch (e) {
throw APIException(APIException.OTHER, arguments: e);
}
}

@ -49,6 +49,25 @@ class ApiConsts {
static String ServiceProviderService_Get = "${baseUrlServices}api/ServiceProviders/ServiceProviderService_Get";
static String BranchesAndServices = "${baseUrlServices}api/ServiceProviders/ServiceProviderDetail_Get";
//Advertisement APIs
static String vehicleTypeGet = "${baseUrlServices}api/ServiceProviders/VehicleType_Get";
static String vehicleModelGet = "${baseUrlServices}api/Master/VehicleModel_Get";
static String vehicleModelYearGet = "${baseUrlServices}api/Master/VehicleModelYear_Get";
static String vehicleColorGet = "${baseUrlServices}api/Master/VehicleColor_Get";
static String vehicleConditionGet = "${baseUrlServices}api/Master/VehicleCondition_Get";
static String vehicleCategoryGet = "${baseUrlServices}api/Master/VehicleCategory_Get";
static String vehicleMileageGet = "${baseUrlServices}api/Master/VehicleMileage_Get";
static String vehicleTransmissionGet = "${baseUrlServices}api/Master/VehicleTransmission_Get";
static String vehicleSellerTypeGet = "${baseUrlServices}api/Master/VehicleSellerType_Get";
static String vehicleDamagePartGet = "${baseUrlServices}api/ServiceProviders/VehicleDamagePart_Get";
static String vehicleCountryGet = "${baseUrlServices}api/Master/Country_Get";
static String vehicleCityGet = "${baseUrlServices}api/Master/City_Get";
static String vehicleDetailsMaster = "${baseUrlServices}api/Master";
static String vehicleAdsDurationGet = "${baseUrlServices}api/Advertisement/AdsDuration_Get";
static String vehicleAdsSpecialServicesGet = "${baseUrlServices}api/Common/SpecialService_Get";
static String vehicleAdsSingleStepCreate = "${baseUrlServices}api/Advertisement/AdsSingleStep_Create";
static String vehicleAdsGet = "${baseUrlServices}api/Advertisement/Ads_Get";
}
class GlobalConsts {
@ -59,11 +78,18 @@ class GlobalConsts {
static String fontZoomSize = "font_zoom_size";
static String welcomeVideoUrl = "welcomeVideoUrl";
static String doNotShowWelcomeVideo = "doNotShowWelcomeVideo";
static String demandAmountError = "Demand Amount Cannot be Empty";
static String vehicleVinError = "Vehicle VIN Cannot be Empty";
static String vehicleTitleError = "Vehicle Title Cannot be Empty";
static String warrantyError = "Warranty Duration Cannot be Empty";
static String vehicleDescError = "Vehicle Description Cannot be Empty";
static String attachImageError = "You must add at least 3 images";
static String adDurationDateError = "Ad Duration start date cannot be empty";
}
class MyAssets {
static const String assetPath = "packages/mc_common_app/assets/";
//JPEG
static String bnCar = "${assetPath}images/bn_car.jpeg";
static String carBanner = "${assetPath}images/bn_car.jpeg";
@ -124,7 +150,7 @@ class MyAssets {
static String icGroupStar = "${assetPath}icons/ic_group_star.svg";
static String icPassword = "${assetPath}icons/ic_password.svg";
static String icPhoneNumber = "${assetPath}icons/ic_phone_number.svg";
static String icStar= "${assetPath}icons/ic_star.svg";
static String icStar = "${assetPath}icons/ic_star.svg";
//PNG
static String icWorldPng = "${assetPath}images/ic_world.png";
@ -137,7 +163,6 @@ class MyAssets {
static String icFingerprintPng = "${assetPath}icons/ic_fingerprint.png";
}
RegExp numReg = RegExp(r".*[0-9].*");
RegExp letterReg = RegExp(r".*[A-Za-z].*");

@ -1,18 +1,16 @@
// import 'package:firebase_crashlytics/firebase_crashlytics.dart';
// import 'package:flutter/material.dart';
import 'package:injector/injector.dart';
import 'package:mc_common_app/api/api_client.dart';
import 'package:mc_common_app/classes/app_state.dart';
import 'package:mc_common_app/repositories/common_repo.dart';
import 'package:mc_common_app/repositories/user_repo.dart';
import 'package:mc_common_app/services/services.dart';
Injector injector = Injector.appInstance;
class AppDependencies {
static void addDependencies() {
//services
injector.registerSingleton<AppState>(() => AppState());
@ -21,6 +19,6 @@ class AppDependencies {
//repos
injector.registerSingleton<UserRepo>(() => UserRepoImp());
injector.registerSingleton<CommonRepo>(() => CommonRepoImp());
}
}

@ -0,0 +1,500 @@
import 'package:mc_common_app/models/advertisment_models/special_service_model.dart';
class AdDetailsModel {
int? id;
String? startdate;
String? enddate;
Vehicle? vehicle;
List<SpecialServiceModel>? specialservice;
// List<Null>? reserved;
int? statusID;
String? statuslabel;
double? adsDurationPrice;
double? adsDurationDiscount;
double? adsDurationDiscountPrice;
String? comment;
bool? active;
bool? isPaid;
bool? isSubscription;
bool? isVerified;
double? netPrice;
double? specialServiceTotalPrice;
double? taxPrice;
double? totalPrice;
String? userID;
int? vehiclePostingID;
String? qrCodePath;
bool? isCustomerAcknowledged;
int? createdByRole;
int? totalViews;
String? createdOn;
double? priceExcludingDiscount;
double? reservePrice;
bool? isMCHandled;
String? modifiedOn;
AdDetailsModel(
{this.id,
this.startdate,
this.enddate,
this.vehicle,
this.specialservice,
// this.reserved,
this.statusID,
this.statuslabel,
this.adsDurationPrice,
this.adsDurationDiscount,
this.adsDurationDiscountPrice,
this.comment,
this.active,
this.isPaid,
this.isSubscription,
this.isVerified,
this.netPrice,
this.specialServiceTotalPrice,
this.taxPrice,
this.totalPrice,
this.userID,
this.vehiclePostingID,
this.qrCodePath,
this.isCustomerAcknowledged,
this.createdByRole,
this.totalViews,
this.createdOn,
this.priceExcludingDiscount,
this.reservePrice,
this.isMCHandled,
this.modifiedOn});
AdDetailsModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
startdate = json['startdate'];
enddate = json['enddate'];
vehicle =
json['vehicle'] != null ? Vehicle.fromJson(json['vehicle']) : null;
if (json['specialservice'] != null) {
specialservice = <SpecialServiceModel>[];
json['specialservice'].forEach((v) {
specialservice!.add(SpecialServiceModel.fromJson(v));
});
}
// if (json['reserved'] != null) {
// reserved = <Null>[];
// json['reserved'].forEach((v) {
// reserved!.add(Null.fromJson(v));
// });
// }
statusID = json['statusID'];
statuslabel = json['statuslabel'];
adsDurationPrice = json['adsDurationPrice'];
adsDurationDiscount = json['adsDurationDiscount'];
adsDurationDiscountPrice = json['adsDurationDiscountPrice'];
comment = json['comment'];
active = json['active'];
isPaid = json['isPaid'];
isSubscription = json['isSubscription'];
isVerified = json['isVerified'];
netPrice = json['netPrice'];
specialServiceTotalPrice = json['specialServiceTotalPrice'];
taxPrice = json['taxPrice'];
totalPrice = json['totalPrice'];
userID = json['userID'];
vehiclePostingID = json['vehiclePostingID'];
qrCodePath = json['qrCodePath'];
isCustomerAcknowledged = json['isCustomerAcknowledged'];
createdByRole = json['createdByRole'];
totalViews = json['totalViews'];
createdOn = json['createdOn'];
priceExcludingDiscount = json['priceExcludingDiscount'];
reservePrice = json['reservePrice'];
isMCHandled = json['isMCHandled'];
modifiedOn = json['modifiedOn'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['startdate'] = startdate;
data['enddate'] = enddate;
if (vehicle != null) {
data['vehicle'] = vehicle!.toJson();
}
if (specialservice != null) {
data['specialservice'] =
specialservice!.map((v) => v.toJson()).toList();
}
// if (reserved != null) {
// data['reserved'] = reserved!.map((v) => v.toJson()).toList();
// }
data['statusID'] = statusID;
data['statuslabel'] = statuslabel;
data['adsDurationPrice'] = adsDurationPrice;
data['adsDurationDiscount'] = adsDurationDiscount;
data['adsDurationDiscountPrice'] = adsDurationDiscountPrice;
data['comment'] = comment;
data['active'] = active;
data['isPaid'] = isPaid;
data['isSubscription'] = isSubscription;
data['isVerified'] = isVerified;
data['netPrice'] = netPrice;
data['specialServiceTotalPrice'] = specialServiceTotalPrice;
data['taxPrice'] = taxPrice;
data['totalPrice'] = totalPrice;
data['userID'] = userID;
data['vehiclePostingID'] = vehiclePostingID;
data['qrCodePath'] = qrCodePath;
data['isCustomerAcknowledged'] = isCustomerAcknowledged;
data['createdByRole'] = createdByRole;
data['totalViews'] = totalViews;
data['createdOn'] = createdOn;
data['priceExcludingDiscount'] = priceExcludingDiscount;
data['reservePrice'] = reservePrice;
data['isMCHandled'] = isMCHandled;
data['modifiedOn'] = modifiedOn;
return data;
}
}
class Vehicle {
int? id;
int? cityID;
String? cityName;
double? demandAmount;
bool? isActive;
bool? isFinanceAvailable;
int? status;
String? statustext;
Category? category;
Category? color;
Condition? condition;
Mileage? mileage;
Condition? model;
ModelYear? modelyear;
Condition? sellertype;
Condition? transmission;
Duration? duration;
List<AdImage>? image;
List<DamageReport>? damagereport;
String? vehicleDescription;
String? vehicleTitle;
int? vehicleType;
String? vehicleVIN;
int? countryID;
String? currency;
Vehicle(
{this.id,
this.cityID,
this.cityName,
this.demandAmount,
this.isActive,
this.isFinanceAvailable,
this.status,
this.statustext,
this.category,
this.color,
this.condition,
this.mileage,
this.model,
this.modelyear,
this.sellertype,
this.transmission,
this.duration,
this.image,
this.damagereport,
this.vehicleDescription,
this.vehicleTitle,
this.vehicleType,
this.vehicleVIN,
this.countryID,
this.currency});
Vehicle.fromJson(Map<String, dynamic> json) {
id = json['id'];
cityID = json['cityID'];
cityName = json['cityName'];
demandAmount = json['demandAmount'];
isActive = json['isActive'];
isFinanceAvailable = json['isFinanceAvailable'];
status = json['status'];
statustext = json['statustext'];
category = json['category'] != null
? Category.fromJson(json['category'])
: null;
color = json['color'] != null ? Category.fromJson(json['color']) : null;
condition = json['condition'] != null
? Condition.fromJson(json['condition'])
: null;
mileage =
json['mileage'] != null ? Mileage.fromJson(json['mileage']) : null;
model =
json['model'] != null ? Condition.fromJson(json['model']) : null;
modelyear = json['modelyear'] != null
? ModelYear.fromJson(json['modelyear'])
: null;
sellertype = json['sellertype'] != null
? Condition.fromJson(json['sellertype'])
: null;
transmission = json['transmission'] != null
? Condition.fromJson(json['transmission'])
: null;
duration = json['duration'] != null
? Duration.fromJson(json['duration'])
: null;
if (json['image'] != null) {
image = <AdImage>[];
json['image'].forEach((v) {
image!.add(AdImage.fromJson(v));
});
}
if (json['damagereport'] != null) {
damagereport = <DamageReport>[];
json['damagereport'].forEach((v) {
damagereport!.add(DamageReport.fromJson(v));
});
}
vehicleDescription = json['vehicleDescription'];
vehicleTitle = json['vehicleTitle'];
vehicleType = json['vehicleType'];
vehicleVIN = json['vehicleVIN'];
countryID = json['countryID'];
currency = json['currency'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['cityID'] = cityID;
data['cityName'] = cityName;
data['demandAmount'] = demandAmount;
data['isActive'] = isActive;
data['isFinanceAvailable'] = isFinanceAvailable;
data['status'] = status;
data['statustext'] = statustext;
if (category != null) {
data['category'] = category!.toJson();
}
if (color != null) {
data['color'] = color!.toJson();
}
if (condition != null) {
data['condition'] = condition!.toJson();
}
if (mileage != null) {
data['mileage'] = mileage!.toJson();
}
if (model != null) {
data['model'] = model!.toJson();
}
if (modelyear != null) {
data['modelyear'] = modelyear!.toJson();
}
if (sellertype != null) {
data['sellertype'] = sellertype!.toJson();
}
if (transmission != null) {
data['transmission'] = transmission!.toJson();
}
if (duration != null) {
data['duration'] = duration!.toJson();
}
if (image != null) {
data['image'] = image!.map((v) => v.toJson()).toList();
}
if (damagereport != null) {
data['damagereport'] = damagereport!.map((v) => v.toJson()).toList();
}
data['vehicleDescription'] = vehicleDescription;
data['vehicleTitle'] = vehicleTitle;
data['vehicleType'] = vehicleType;
data['vehicleVIN'] = vehicleVIN;
data['countryID'] = countryID;
data['currency'] = currency;
return data;
}
}
class Category {
int? id;
String? label;
String? labelN;
bool? isActive;
Category({this.id, this.label, this.labelN, this.isActive});
Category.fromJson(Map<String, dynamic> json) {
id = json['id'];
label = json['label'];
labelN = json['labelN'];
isActive = json['isActive'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['label'] = label;
data['labelN'] = labelN;
data['isActive'] = isActive;
return data;
}
}
class Condition {
int? id;
String? label;
String? labelN;
Condition({this.id, this.label, this.labelN});
Condition.fromJson(Map<String, dynamic> json) {
id = json['id'];
label = json['label'];
labelN = json['labelN'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['label'] = label;
data['labelN'] = labelN;
return data;
}
}
class Mileage {
int? id;
String? mileageStart;
String? mileageEnd;
String? label;
Mileage({this.id, this.mileageStart, this.mileageEnd, this.label});
Mileage.fromJson(Map<String, dynamic> json) {
id = json['id'];
mileageStart = json['mileageStart'];
mileageEnd = json['mileageEnd'];
label = json['label'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['mileageStart'] = mileageStart;
data['mileageEnd'] = mileageEnd;
data['label'] = label;
return data;
}
}
class ModelYear {
int? id;
String? label;
ModelYear({this.id, this.label});
ModelYear.fromJson(Map<String, dynamic> json) {
id = json['id'];
label = json['label'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['label'] = label;
return data;
}
}
class Duration {
int? id;
String? label;
int? days;
double? price;
ModelYear? country;
Duration({this.id, this.label, this.days, this.price, this.country});
Duration.fromJson(Map<String, dynamic> json) {
id = json['id'];
label = json['label'];
days = json['days'];
price = json['price'];
country = json['country'] != null
? ModelYear.fromJson(json['country'])
: null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['label'] = label;
data['days'] = days;
data['price'] = price;
if (country != null) {
data['country'] = country!.toJson();
}
return data;
}
}
class AdImage {
int? id;
String? imageName;
String? imageUrl;
bool? isActive;
AdImage({this.id, this.imageName, this.imageUrl, this.isActive});
AdImage.fromJson(Map<String, dynamic> json) {
id = json['id'];
imageName = json['imageName'];
imageUrl = json['imageUrl'];
isActive = json['isActive'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['imageName'] = imageName;
data['imageUrl'] = imageUrl;
data['isActive'] = isActive;
return data;
}
}
class DamageReport {
int? id;
String? comment;
String? imageUrl;
bool? isActive;
int? vehicleDamagePartID;
String? partName;
DamageReport(
{this.id,
this.comment,
this.imageUrl,
this.isActive,
this.vehicleDamagePartID,
this.partName});
DamageReport.fromJson(Map<String, dynamic> json) {
id = json['id'];
comment = json['comment'];
imageUrl = json['imageUrl'];
isActive = json['isActive'];
vehicleDamagePartID = json['vehicleDamagePartID'];
partName = json['partName'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['comment'] = comment;
data['imageUrl'] = imageUrl;
data['isActive'] = isActive;
data['vehicleDamagePartID'] = vehicleDamagePartID;
data['partName'] = partName;
return data;
}
}

@ -0,0 +1,159 @@
// class AdCreationRespModel {
// int? id;
// int? vehiclePostingID;
// Null? vehiclePosting;
// int? adsDurationID;
// Null? adsDuration;
// int? adsStatus;
// int? specialServiceTotalPrice;
// int? adsDurationPrice;
// int? adsDurationDiscount;
// int? adsDurationDiscountPrice;
// int? totalPrice;
// int? taxPrice;
// int? netPrice;
// bool? isPaid;
// bool? isSubscription;
// bool? isVerified;
// String? userID;
// Null? user;
// String? comment;
// String? startDate;
// String? endDate;
// Null? adsJson;
// String? qrCodePath;
// List<Null>? adsViews;
// double? adsPricing;
// bool? isCustomerAcknowledged;
// int? createdByRole;
// bool? isReservable;
// int? reservePrice;
// bool? isMCHandled;
// bool? isActive;
// int? createdBy;
// String? createdOn;
// String? modifiedBy;
// String? modifiedOn;
//
// AdCreationResepModel(
// {this.id,
// this.vehiclePostingID,
// this.vehiclePosting,
// this.adsDurationID,
// this.adsDuration,
// this.adsStatus,
// this.specialServiceTotalPrice,
// this.adsDurationPrice,
// this.adsDurationDiscount,
// this.adsDurationDiscountPrice,
// this.totalPrice,
// this.taxPrice,
// this.netPrice,
// this.isPaid,
// this.isSubscription,
// this.isVerified,
// this.userID,
// this.user,
// this.comment,
// this.startDate,
// this.endDate,
// this.adsJson,
// this.qrCodePath,
// this.adsViews,
// this.adsPricing,
// this.isCustomerAcknowledged,
// this.createdByRole,
// this.isReservable,
// this.reservePrice,
// this.isMCHandled,
// this.isActive,
// this.createdBy,
// this.createdOn,
// this.modifiedBy,
// this.modifiedOn});
//
// AdCreationResepModel.fromJson(Map<String, dynamic> json) {
// id = json['id'];
// vehiclePostingID = json['vehiclePostingID'];
// vehiclePosting = json['vehiclePosting'];
// adsDurationID = json['adsDurationID'];
// adsDuration = json['adsDuration'];
// adsStatus = json['adsStatus'];
// specialServiceTotalPrice = json['specialServiceTotalPrice'];
// adsDurationPrice = json['adsDurationPrice'];
// adsDurationDiscount = json['adsDurationDiscount'];
// adsDurationDiscountPrice = json['adsDurationDiscountPrice'];
// totalPrice = json['totalPrice'];
// taxPrice = json['taxPrice'];
// netPrice = json['netPrice'];
// isPaid = json['isPaid'];
// isSubscription = json['isSubscription'];
// isVerified = json['isVerified'];
// userID = json['userID'];
// user = json['user'];
// comment = json['comment'];
// startDate = json['startDate'];
// endDate = json['endDate'];
// adsJson = json['adsJson'];
// qrCodePath = json['qrCodePath'];
// if (json['adsViews'] != null) {
// adsViews = <Null>[];
// json['adsViews'].forEach((v) {
// adsViews!.add(new Null.fromJson(v));
// });
// }
// adsPricing = json['adsPricing'];
// isCustomerAcknowledged = json['isCustomerAcknowledged'];
// createdByRole = json['createdByRole'];
// isReservable = json['isReservable'];
// reservePrice = json['reservePrice'];
// isMCHandled = json['isMCHandled'];
// isActive = json['isActive'];
// createdBy = json['createdBy'];
// createdOn = json['createdOn'];
// modifiedBy = json['modifiedBy'];
// modifiedOn = json['modifiedOn'];
// }
//
// Map<String, dynamic> toJson() {
// final Map<String, dynamic> data = <String, dynamic>{};
// data['id'] = id;
// data['vehiclePostingID'] = vehiclePostingID;
// data['vehiclePosting'] = vehiclePosting;
// data['adsDurationID'] = adsDurationID;
// data['adsDuration'] = adsDuration;
// data['adsStatus'] = adsStatus;
// data['specialServiceTotalPrice'] = specialServiceTotalPrice;
// data['adsDurationPrice'] = adsDurationPrice;
// data['adsDurationDiscount'] = adsDurationDiscount;
// data['adsDurationDiscountPrice'] = adsDurationDiscountPrice;
// data['totalPrice'] = totalPrice;
// data['taxPrice'] = taxPrice;
// data['netPrice'] = netPrice;
// data['isPaid'] = isPaid;
// data['isSubscription'] = isSubscription;
// data['isVerified'] = isVerified;
// data['userID'] = userID;
// data['user'] = user;
// data['comment'] = comment;
// data['startDate'] = startDate;
// data['endDate'] = endDate;
// data['adsJson'] = adsJson;
// data['qrCodePath'] = qrCodePath;
// if (adsViews != null) {
// data['adsViews'] = adsViews!.map((v) => v.toJson()).toList();
// }
// data['adsPricing'] = adsPricing;
// data['isCustomerAcknowledged'] = isCustomerAcknowledged;
// data['createdByRole'] = createdByRole;
// data['isReservable'] = isReservable;
// data['reservePrice'] = reservePrice;
// data['isMCHandled'] = isMCHandled;
// data['isActive'] = isActive;
// data['createdBy'] = createdBy;
// data['createdOn'] = createdOn;
// data['modifiedBy'] = modifiedBy;
// data['modifiedOn'] = modifiedOn;
// return data;
// }
// }

@ -0,0 +1,40 @@
class AdsDurationModel {
int? id;
String? name;
int? days;
double? price;
int? countryID;
bool? isActive;
String? countryName;
AdsDurationModel(
{this.id,
this.name,
this.days,
this.price,
this.countryID,
this.isActive,
this.countryName});
AdsDurationModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
days = json['days'];
price = json['price'];
countryID = json['countryID'];
isActive = json['isActive'];
countryName = json['countryName'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['name'] = name;
data['days'] = days;
data['price'] = price;
data['countryID'] = countryID;
data['isActive'] = isActive;
data['countryName'] = countryName;
return data;
}
}

@ -0,0 +1,337 @@
class AdsGenericModel {
AdsGenericModel({
this.data,
this.messageStatus,
this.totalItemsCount,
});
dynamic data;
int? messageStatus;
int? totalItemsCount;
factory AdsGenericModel.fromJson(Map<String, dynamic> json) => AdsGenericModel(
data: json["data"],
messageStatus: json["messageStatus"],
totalItemsCount: json["totalItemsCount"],
);
Map<String, dynamic> toJson() => {
"data": data,
"messageStatus": messageStatus,
"totalItemsCount": totalItemsCount,
};
}
var json = {
"ads": {
"id": 0,
"adsDurationID": 1,
"startDate": "2023-04-12T10:10:20.905Z",
"countryId": 1,
"specialServiceIDs": [
],
"isMCHandled": false
},
"vehiclePosting": {
"id": 0,
"userID": "1A1597B3-D5A0-433A-098B-08DB189E51EC",
"vehicleType": 1,
"vehicleModelID": 1,
"vehicleModelYearID": 1,
"vehicleColorID": 2,
"vehicleCategoryID": 1,
"vehicleConditionID": 1,
"vehicleMileageID": 1,
"vehicleTransmissionID": 1,
"vehicleSellerTypeID": 1,
"cityID": 1,
"price": 33,
"vehicleVIN": "fdfd",
"vehicleDescription": "dsd",
"vehicleTitle": "fsfs",
"vehicleDescriptionN": "dsdds",
"isFinanceAvailable": true,
"warantyYears": 2,
"demandAmount": 34,
"adStatus": 1,
"vehiclePostingImages": [
{
"id": 0,
"imageName": "onon",
"imageUrl": "string",
"imageStr": null,
"vehiclePostingID": 0,
"vehiclePosting": null
}
],
"vehiclePostingDamageParts": [
{
"id": 0,
"comment": "hhsa",
"vehicleImageBase64": null,
"vehicleDamagePartID": 1,
"vehiclePostingID": 0,
"isActive": true
}
]
}
};
class AdsCreationPayloadModel {
Ads? ads;
VehiclePosting? vehiclePosting;
AdsCreationPayloadModel({this.ads, this.vehiclePosting});
AdsCreationPayloadModel.fromJson(Map<String, dynamic> json) {
ads = json['ads'] != null ? Ads.fromJson(json['ads']) : null;
vehiclePosting = json['vehiclePosting'] != null
? VehiclePosting.fromJson(json['vehiclePosting'])
: null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
if (ads != null) {
data['ads'] = ads!.toJson();
}
if (vehiclePosting != null) {
data['vehiclePosting'] = vehiclePosting!.toJson();
}
return data;
}
}
class Ads {
int? id;
int? adsDurationID;
String? startDate;
int? countryId;
List<int>? specialServiceIDs;
bool? isMCHandled;
Ads(
{this.id,
this.adsDurationID,
this.startDate,
this.countryId,
this.specialServiceIDs,
this.isMCHandled});
Ads.fromJson(Map<String, dynamic> json) {
id = json['id'];
adsDurationID = json['adsDurationID'];
startDate = json['startDate'];
countryId = json['countryId'];
specialServiceIDs = json['specialServiceIDs'].cast<int>();
isMCHandled = json['isMCHandled'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['adsDurationID'] = adsDurationID;
data['startDate'] = startDate;
data['countryId'] = countryId;
data['specialServiceIDs'] = specialServiceIDs;
data['isMCHandled'] = isMCHandled;
return data;
}
}
class VehiclePosting {
int? id;
String? userID;
int? vehicleType;
int? vehicleModelID;
int? vehicleModelYearID;
int? vehicleColorID;
int? vehicleCategoryID;
int? vehicleConditionID;
int? vehicleMileageID;
int? vehicleTransmissionID;
int? vehicleSellerTypeID;
int? cityID;
int? price;
String? vehicleVIN;
String? vehicleDescription;
String? vehicleTitle;
String? vehicleDescriptionN;
bool? isFinanceAvailable;
int? warantyYears;
int? demandAmount;
int? adStatus;
List<VehiclePostingImages>? vehiclePostingImages;
List<VehiclePostingDamageParts>? 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.vehiclePostingImages,
this.vehiclePostingDamageParts});
VehiclePosting.fromJson(Map<String, dynamic> json) {
id = json['id'];
userID = json['userID'];
vehicleType = json['vehicleType'];
vehicleModelID = json['vehicleModelID'];
vehicleModelYearID = json['vehicleModelYearID'];
vehicleColorID = json['vehicleColorID'];
vehicleCategoryID = json['vehicleCategoryID'];
vehicleConditionID = json['vehicleConditionID'];
vehicleMileageID = json['vehicleMileageID'];
vehicleTransmissionID = json['vehicleTransmissionID'];
vehicleSellerTypeID = json['vehicleSellerTypeID'];
cityID = json['cityID'];
price = json['price'];
vehicleVIN = json['vehicleVIN'];
vehicleDescription = json['vehicleDescription'];
vehicleTitle = json['vehicleTitle'];
vehicleDescriptionN = json['vehicleDescriptionN'];
isFinanceAvailable = json['isFinanceAvailable'];
warantyYears = json['warantyYears'];
demandAmount = json['demandAmount'];
adStatus = json['adStatus'];
if (json['vehiclePostingImages'] != null) {
vehiclePostingImages = <VehiclePostingImages>[];
json['vehiclePostingImages'].forEach((v) {
vehiclePostingImages!.add(VehiclePostingImages.fromJson(v));
});
}
if (json['vehiclePostingDamageParts'] != null) {
vehiclePostingDamageParts = <VehiclePostingDamageParts>[];
json['vehiclePostingDamageParts'].forEach((v) {
vehiclePostingDamageParts!
.add(VehiclePostingDamageParts.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['userID'] = userID;
data['vehicleType'] = vehicleType;
data['vehicleModelID'] = vehicleModelID;
data['vehicleModelYearID'] = vehicleModelYearID;
data['vehicleColorID'] = vehicleColorID;
data['vehicleCategoryID'] = vehicleCategoryID;
data['vehicleConditionID'] = vehicleConditionID;
data['vehicleMileageID'] = vehicleMileageID;
data['vehicleTransmissionID'] = vehicleTransmissionID;
data['vehicleSellerTypeID'] = vehicleSellerTypeID;
data['cityID'] = cityID;
data['price'] = price;
data['vehicleVIN'] = vehicleVIN;
data['vehicleDescription'] = vehicleDescription;
data['vehicleTitle'] = vehicleTitle;
data['vehicleDescriptionN'] = vehicleDescriptionN;
data['isFinanceAvailable'] = isFinanceAvailable;
data['warantyYears'] = warantyYears;
data['demandAmount'] = demandAmount;
data['adStatus'] = adStatus;
if (vehiclePostingImages != null) {
data['vehiclePostingImages'] =
vehiclePostingImages!.map((v) => v.toJson()).toList();
}
if (vehiclePostingDamageParts != null) {
data['vehiclePostingDamageParts'] =
vehiclePostingDamageParts!.map((v) => v.toJson()).toList();
}
return data;
}
}
class VehiclePostingImages {
int? id;
String? imageName;
String? imageUrl;
String? imageStr;
int? vehiclePostingID;
String? vehiclePosting;
VehiclePostingImages(
{this.id,
this.imageName,
this.imageUrl,
this.imageStr,
this.vehiclePostingID,
this.vehiclePosting});
VehiclePostingImages.fromJson(Map<String, dynamic> json) {
id = json['id'];
imageName = json['imageName'];
imageUrl = json['imageUrl'];
imageStr = json['imageStr'];
vehiclePostingID = json['vehiclePostingID'];
vehiclePosting = json['vehiclePosting'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['imageName'] = imageName;
data['imageUrl'] = imageUrl;
data['imageStr'] = imageStr;
data['vehiclePostingID'] = vehiclePostingID;
data['vehiclePosting'] = vehiclePosting;
return data;
}
}
class VehiclePostingDamageParts {
int? id;
String? comment;
String? vehicleImageBase64;
int? vehicleDamagePartID;
int? vehiclePostingID;
bool? isActive;
VehiclePostingDamageParts(
{this.id,
this.comment,
this.vehicleImageBase64,
this.vehicleDamagePartID,
this.vehiclePostingID,
this.isActive});
VehiclePostingDamageParts.fromJson(Map<String, dynamic> json) {
id = json['id'];
comment = json['comment'];
vehicleImageBase64 = json['vehicleImageBase64'];
vehicleDamagePartID = json['vehicleDamagePartID'];
vehiclePostingID = json['vehiclePostingID'];
isActive = json['isActive'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['comment'] = comment;
data['vehicleImageBase64'] = vehicleImageBase64;
data['vehicleDamagePartID'] = vehicleDamagePartID;
data['vehiclePostingID'] = vehiclePostingID;
data['isActive'] = isActive;
return data;
}
}

@ -0,0 +1,140 @@
class SpecialServiceModel {
int? id;
String? name;
String? description;
double? price;
int? specialServiceType;
String? specialServiceTypeName;
bool? isActive;
String? startDate;
String? endDate;
List<Details>? details;
List<Office>? office;
bool? isDelivery;
SpecialServiceModel(
{this.id,
this.name,
this.description,
this.price,
this.specialServiceType,
this.specialServiceTypeName,
this.isActive,
this.startDate,
this.endDate,
this.details,
this.office,
this.isDelivery});
SpecialServiceModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
description = json['description'];
price = json['price'];
specialServiceType = json['specialServiceType'];
specialServiceTypeName = json['specialServiceTypeName'];
isActive = json['isActive'];
startDate = json['startDate'];
endDate = json['endDate'];
if (json['details'] != null) {
details = <Details>[];
json['details'].forEach((v) {
details!.add(Details.fromJson(v));
});
}
if (json['office'] != null) {
office = <Office>[];
json['office'].forEach((v) {
office!.add(Office.fromJson(v));
});
}
isDelivery = json['isDelivery'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['name'] = name;
data['description'] = description;
data['price'] = price;
data['specialServiceType'] = specialServiceType;
data['specialServiceTypeName'] = specialServiceTypeName;
data['isActive'] = isActive;
data['startDate'] = startDate;
data['endDate'] = endDate;
if (details != null) {
data['details'] = details!.map((v) => v.toJson()).toList();
}
if (office != null) {
data['office'] = office!.map((v) => v.toJson()).toList();
}
data['isDelivery'] = isDelivery;
return data;
}
}
class Details {
int? id;
int? specialServiceID;
int? fromcity;
int? tocity;
int? price;
Details(
{this.id, this.specialServiceID, this.fromcity, this.tocity, this.price});
Details.fromJson(Map<String, dynamic> json) {
id = json['id'];
specialServiceID = json['specialServiceID'];
fromcity = json['fromcity'];
tocity = json['tocity'];
price = json['price'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['specialServiceID'] = specialServiceID;
data['fromcity'] = fromcity;
data['tocity'] = tocity;
data['price'] = price;
return data;
}
}
class Office {
int? id;
String? officeAreaName;
String? officeAreaNameN;
int? cityID;
String? city;
int? specialServiceID;
Office(
{this.id,
this.officeAreaName,
this.officeAreaNameN,
this.cityID,
this.city,
this.specialServiceID});
Office.fromJson(Map<String, dynamic> json) {
id = json['id'];
officeAreaName = json['officeAreaName'];
officeAreaNameN = json['officeAreaNameN'];
cityID = json['cityID'];
city = json['city'];
specialServiceID = json['specialServiceID'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['officeAreaName'] = officeAreaName;
data['officeAreaNameN'] = officeAreaNameN;
data['cityID'] = cityID;
data['city'] = city;
data['specialServiceID'] = specialServiceID;
return data;
}
}

@ -0,0 +1,522 @@
import 'dart:developer';
class VehicleDetailsModel {
List<VehicleBrandsModel>? vehicleBrands;
List<VehicleCategoryModel>? vehicleCategories;
List<VehicleColorModel>? vehicleColors;
List<VehicleConditionModel>? vehicleConditions;
List<VehicleMileageModel>? vehicleMileages;
List<VehicleModel>? vehicleModels;
List<VehicleYearModel>? vehicleModelYears;
List<VehiclePriceRangeModel>? vehiclePriceRanges;
List<VehiclePricingMethodModel>? vehiclePricingMethods;
List<VehicleSellerTypeModel>? vehicleSellerTypes;
List<VehicleTransmissionModel>? vehicleTransmissions;
List<VehicleCountryModel>? vehicleCountries;
VehicleDetailsModel({
this.vehicleBrands,
this.vehicleCategories,
this.vehicleColors,
this.vehicleConditions,
this.vehicleMileages,
this.vehicleModels,
this.vehicleModelYears,
this.vehiclePriceRanges,
this.vehiclePricingMethods,
this.vehicleSellerTypes,
this.vehicleTransmissions,
this.vehicleCountries,
});
VehicleDetailsModel.fromJson(Map<String, dynamic> json) {
log("jsonJee: $json");
vehicleBrands = List.generate((json['vehiclebrands']['data']).length, (index) => VehicleBrandsModel.fromJson(json['vehiclebrands']['data'][index]));
vehicleCategories = List.generate((json['vehiclecategories']['data']).length, (index) => VehicleCategoryModel.fromJson(json['vehiclecategories']['data'][index]));
vehicleColors = List.generate((json['vehiclecolors']['data']).length, (index) => VehicleColorModel.fromJson(json['vehiclecolors']['data'][index]));
vehicleConditions = List.generate((json['vehicleconditions']['data']).length, (index) => VehicleConditionModel.fromJson(json['vehicleconditions']['data'][index]));
vehicleMileages = List.generate((json['vehiclemileages']['data']).length, (index) => VehicleMileageModel.fromJson(json['vehiclemileages']['data'][index]));
vehicleModels = List.generate((json['vehiclemodels']['data']).length, (index) => VehicleModel.fromJson(json['vehiclemodels']['data'][index]));
vehicleModelYears = List.generate((json['vehiclemodelyears']['data']).length, (index) => VehicleYearModel.fromJson(json['vehiclemodelyears']['data'][index]));
vehiclePriceRanges = List.generate((json['vehiclepriceranges']['data']).length, (index) => VehiclePriceRangeModel.fromJson(json['vehiclepriceranges']['data'][index]));
vehiclePricingMethods = List.generate((json['vehiclepricingmethods']['data']).length, (index) => VehiclePricingMethodModel.fromJson(json['vehiclepricingmethods']['data'][index]));
vehicleSellerTypes = List.generate((json['vehiclesellertypes']['data']).length, (index) => VehicleSellerTypeModel.fromJson(json['vehiclesellertypes']['data'][index]));
vehicleTransmissions = List.generate((json['vehicletransmissions']['data']).length, (index) => VehicleTransmissionModel.fromJson(json['vehicletransmissions']['data'][index]));
vehicleCountries = List.generate((json['countries']['data']).length, (index) => VehicleCountryModel.fromJson(json['countries']['data'][index]));
}
@override
String toString() {
return 'VehicleDetailsModel{vehicleBrands: $vehicleBrands, vehicleCategories: $vehicleCategories, vehicleColors: $vehicleColors, vehicleConditions: $vehicleConditions, vehicleMileages: $vehicleMileages, vehicleModels: $vehicleModels, vehicleModelYears: $vehicleModelYears, vehiclePriceRanges: $vehiclePriceRanges, vehiclePricingMethods: $vehiclePricingMethods, vehicleSellerTypes: $vehicleSellerTypes, vehicleTransmissions: $vehicleTransmissions, vehicleCountries: $vehicleCountries,}';
}
}
class VehicleTypeModel {
int? id;
String? vehicleTypeName;
String? vehicleTypeNameN;
bool? isActive;
VehicleTypeModel({this.id, this.vehicleTypeName, this.vehicleTypeNameN, this.isActive});
VehicleTypeModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
vehicleTypeName = json['vehicleTypeName'];
vehicleTypeNameN = json['vehicleTypeNameN'];
isActive = json['isActive'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['vehicleTypeName'] = vehicleTypeName;
data['vehicleTypeNameN'] = vehicleTypeNameN;
data['isActive'] = isActive;
return data;
}
@override
String toString() {
return 'VehicleTypeModel{id: $id, vehicleTypeName: $vehicleTypeName, vehicleTypeNameN: $vehicleTypeNameN, isActive: $isActive}';
}
}
class VehicleModel {
int? id;
int? vehicleType;
String? vehicleTypeVal;
String? model;
String? modelN;
int? vehicleBrandID;
bool? isActive;
VehicleModel({this.id, this.vehicleType, this.vehicleTypeVal, this.model, this.modelN, this.vehicleBrandID, this.isActive});
VehicleModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
vehicleType = json['vehicleType'];
vehicleTypeVal = json['vehicleTypeVal'];
model = json['model'];
modelN = json['modelN'];
vehicleBrandID = json['vehicleBrandID'];
isActive = json['isActive'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['vehicleType'] = vehicleType;
data['vehicleTypeVal'] = vehicleTypeVal;
data['model'] = model;
data['modelN'] = modelN;
data['vehicleBrandID'] = vehicleBrandID;
data['isActive'] = isActive;
return data;
}
}
class VehicleYearModel {
int? id;
int? vehicleType;
String? vehicleTypeVal;
String? modelYear;
bool? isActive;
VehicleYearModel({this.id, this.vehicleType, this.vehicleTypeVal, this.modelYear, this.isActive});
VehicleYearModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
vehicleType = json['vehicleType'];
vehicleTypeVal = json['vehicleTypeVal'];
modelYear = json['modelYear'];
isActive = json['isActive'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['vehicleType'] = vehicleType;
data['vehicleTypeVal'] = vehicleTypeVal;
data['modelYear'] = modelYear;
data['isActive'] = isActive;
return data;
}
}
class VehicleColorModel {
int? id;
int? vehicleType;
String? vehicleTypeVal;
String? color;
String? colorN;
bool? isActive;
VehicleColorModel({this.id, this.vehicleType, this.vehicleTypeVal, this.color, this.colorN, this.isActive});
VehicleColorModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
vehicleType = json['vehicleType'];
vehicleTypeVal = json['vehicleTypeVal'];
color = json['color'];
colorN = json['colorN'];
isActive = json['isActive'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['vehicleType'] = vehicleType;
data['vehicleTypeVal'] = vehicleTypeVal;
data['color'] = color;
data['colorN'] = colorN;
data['isActive'] = isActive;
return data;
}
}
class VehicleConditionModel {
int? id;
int? vehicleType;
String? vehicleTypeVal;
String? condition;
String? conditionN;
bool? isActive;
VehicleConditionModel({this.id, this.vehicleType, this.vehicleTypeVal, this.condition, this.conditionN, this.isActive});
VehicleConditionModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
vehicleType = json['vehicleType'];
vehicleTypeVal = json['vehicleTypeVal'];
condition = json['condition'];
conditionN = json['conditionN'];
isActive = json['isActive'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['vehicleType'] = vehicleType;
data['vehicleTypeVal'] = vehicleTypeVal;
data['condition'] = condition;
data['conditionN'] = conditionN;
data['isActive'] = isActive;
return data;
}
}
class VehicleCategoryModel {
int? id;
int? vehicleType;
String? vehicleTypeVal;
String? category;
String? categoryN;
bool? isActive;
VehicleCategoryModel({this.id, this.vehicleType, this.vehicleTypeVal, this.category, this.categoryN, this.isActive});
VehicleCategoryModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
vehicleType = json['vehicleType'];
vehicleTypeVal = json['vehicleTypeVal'];
category = json['category'];
categoryN = json['categoryN'];
isActive = json['isActive'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['vehicleType'] = vehicleType;
data['vehicleTypeVal'] = vehicleTypeVal;
data['category'] = category;
data['categoryN'] = categoryN;
data['isActive'] = isActive;
return data;
}
}
class VehicleMileageModel {
int? id;
int? vehicleType;
String? vehicleTypeVal;
String? mileageStart;
String? mileageEnd;
bool? isActive;
VehicleMileageModel({this.id, this.vehicleType, this.vehicleTypeVal, this.mileageStart, this.mileageEnd, this.isActive});
VehicleMileageModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
vehicleType = json['vehicleType'];
vehicleTypeVal = json['vehicleTypeVal'];
mileageStart = json['mileageStart'];
mileageEnd = json['mileageEnd'];
isActive = json['isActive'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['vehicleType'] = vehicleType;
data['vehicleTypeVal'] = vehicleTypeVal;
data['mileageStart'] = mileageStart;
data['mileageEnd'] = mileageEnd;
data['isActive'] = isActive;
return data;
}
}
class VehicleTransmissionModel {
int? id;
String? transmission;
String? transmissionN;
int? vehicleType;
String? vehicleTypeVal;
bool? isActive;
VehicleTransmissionModel({this.id, this.transmission, this.transmissionN, this.vehicleType, this.vehicleTypeVal, this.isActive});
VehicleTransmissionModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
transmission = json['transmission'];
transmissionN = json['transmissionN'];
vehicleType = json['vehicleType'];
vehicleTypeVal = json['vehicleTypeVal'];
isActive = json['isActive'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['transmission'] = transmission;
data['transmissionN'] = transmissionN;
data['vehicleType'] = vehicleType;
data['vehicleTypeVal'] = vehicleTypeVal;
data['isActive'] = isActive;
return data;
}
}
class VehicleSellerTypeModel {
int? id;
String? sellerType;
String? sellerTypeN;
int? vehicleType;
String? vehicleTypeVal;
bool? isActive;
VehicleSellerTypeModel({this.id, this.sellerType, this.sellerTypeN, this.vehicleType, this.vehicleTypeVal, this.isActive});
VehicleSellerTypeModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
sellerType = json['sellerType'];
sellerTypeN = json['sellerTypeN'];
vehicleType = json['vehicleType'];
vehicleTypeVal = json['vehicleTypeVal'];
isActive = json['isActive'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['sellerType'] = sellerType;
data['sellerTypeN'] = sellerTypeN;
data['vehicleType'] = vehicleType;
data['vehicleTypeVal'] = vehicleTypeVal;
data['isActive'] = isActive;
return data;
}
}
class VehicleCountryModel {
int? id;
String? countryName;
String? countryNameN;
String? nationality;
String? nationalityN;
String? countryCode;
String? alpha2Code;
String? alpha3Code;
String? currency;
bool? isActive;
VehicleCountryModel({this.id, this.countryName, this.countryNameN, this.nationality, this.nationalityN, this.countryCode, this.alpha2Code, this.alpha3Code, this.currency, this.isActive});
VehicleCountryModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
countryName = json['countryName'];
countryNameN = json['countryNameN'];
nationality = json['nationality'];
nationalityN = json['nationalityN'];
countryCode = json['countryCode'];
alpha2Code = json['alpha2Code'];
alpha3Code = json['alpha3Code'];
currency = json['currency'];
isActive = json['isActive'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['countryName'] = countryName;
data['countryNameN'] = countryNameN;
data['nationality'] = nationality;
data['nationalityN'] = nationalityN;
data['countryCode'] = countryCode;
data['alpha2Code'] = alpha2Code;
data['alpha3Code'] = alpha3Code;
data['currency'] = currency;
data['isActive'] = isActive;
return data;
}
}
class VehicleCityModel {
int? id;
String? cityName;
String? cityNameN;
int? countryID;
bool? isActive;
VehicleCityModel({this.id, this.cityName, this.cityNameN, this.countryID, this.isActive});
VehicleCityModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
cityName = json['cityName'];
cityNameN = json['cityNameN'];
countryID = json['countryID'];
isActive = json['isActive'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['cityName'] = cityName;
data['cityNameN'] = cityNameN;
data['countryID'] = countryID;
data['isActive'] = isActive;
return data;
}
}
class VehiclePartModel {
int? id;
int? partNo;
String? partName;
String? description;
bool? isActive;
VehiclePartModel({this.id, this.partNo, this.partName, this.description, this.isActive});
VehiclePartModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
partNo = json['partNo'];
partName = json['partName'];
description = json['description'];
isActive = json['isActive'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['partNo'] = partNo;
data['partName'] = partName;
data['description'] = description;
data['isActive'] = isActive;
return data;
}
}
class VehicleBrandsModel {
int? id;
int? vehicleType;
String? vehicleTypeVal;
String? vehicleBrandDescription;
String? vehicleBrandDescriptionN;
bool? isActive;
VehicleBrandsModel({this.id, this.vehicleType, this.vehicleTypeVal, this.vehicleBrandDescription, this.vehicleBrandDescriptionN, this.isActive});
VehicleBrandsModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
vehicleType = json['vehicleType'];
vehicleTypeVal = json['vehicleTypeVal'];
vehicleBrandDescription = json['vehicleBrand_Description'];
vehicleBrandDescriptionN = json['vehicleBrand_DescriptionN'];
isActive = json['isActive'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['vehicleType'] = vehicleType;
data['vehicleTypeVal'] = vehicleTypeVal;
data['vehicleBrand_Description'] = vehicleBrandDescription;
data['vehicleBrand_DescriptionN'] = vehicleBrandDescriptionN;
data['isActive'] = isActive;
return data;
}
}
class VehiclePriceRangeModel {
int? id;
String? priceRangeStart;
String? priceRangeEnd;
int? vehicleType;
String? vehicleTypeVal;
bool? isActive;
VehiclePriceRangeModel({this.id, this.priceRangeStart, this.priceRangeEnd, this.vehicleType, this.vehicleTypeVal, this.isActive});
VehiclePriceRangeModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
priceRangeStart = json['priceRangeStart'];
priceRangeEnd = json['priceRangeEnd'];
vehicleType = json['vehicleType'];
vehicleTypeVal = json['vehicleTypeVal'];
isActive = json['isActive'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['priceRangeStart'] = priceRangeStart;
data['priceRangeEnd'] = priceRangeEnd;
data['vehicleType'] = vehicleType;
data['vehicleTypeVal'] = vehicleTypeVal;
data['isActive'] = isActive;
return data;
}
}
class VehiclePricingMethodModel {
int? id;
String? pricingMethod;
String? pricingMethodN;
int? vehicleType;
String? vehicleTypeVal;
bool? isActive;
VehiclePricingMethodModel({this.id, this.pricingMethod, this.pricingMethodN, this.vehicleType, this.vehicleTypeVal, this.isActive});
VehiclePricingMethodModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
pricingMethod = json['pricingMethod'];
pricingMethodN = json['pricingMethodN'];
vehicleType = json['vehicleType'];
vehicleTypeVal = json['vehicleTypeVal'];
isActive = json['isActive'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['pricingMethod'] = pricingMethod;
data['pricingMethodN'] = pricingMethodN;
data['vehicleType'] = vehicleType;
data['vehicleTypeVal'] = vehicleTypeVal;
data['isActive'] = isActive;
return data;
}
}

@ -22,17 +22,17 @@ class Cities {
String? message;
factory Cities.fromJson(Map<String, dynamic> json) => Cities(
totalItemsCount: json["totalItemsCount"] == null ? null : json["totalItemsCount"],
totalItemsCount: json["totalItemsCount"],
data: json["data"] == null ? null : List<CityData>.from(json["data"].map((x) => CityData.fromJson(x))),
messageStatus: json["messageStatus"] == null ? null : json["messageStatus"],
message: json["message"] == null ? null : json["message"],
messageStatus: json["messageStatus"],
message: json["message"],
);
Map<String, dynamic> toJson() => {
"totalItemsCount": totalItemsCount == null ? null : totalItemsCount,
"totalItemsCount": totalItemsCount,
"data": data == null ? null : List<dynamic>.from(data!.map((x) => x.toJson())),
"messageStatus": messageStatus == null ? null : messageStatus,
"message": message == null ? null : message,
"messageStatus": messageStatus,
"message": message,
};
}
@ -50,16 +50,16 @@ class CityData {
int? countryId;
factory CityData.fromJson(Map<String, dynamic> json) => CityData(
id: json["id"] == null ? null : json["id"],
cityName: json["cityName"] == null ? null : json["cityName"],
cityNameN: json["cityNameN"] == null ? null : json["cityNameN"],
countryId: json["countryID"] == null ? null : json["countryID"],
id: json["id"],
cityName: json["cityName"],
cityNameN: json["cityNameN"],
countryId: json["countryID"],
);
Map<String, dynamic> toJson() => {
"id": id == null ? null : id,
"cityName": cityName == null ? null : cityName,
"cityNameN": cityNameN == null ? null : cityNameN,
"countryID": countryId == null ? null : countryId,
"id": id,
"cityName": cityName,
"cityNameN": cityNameN,
"countryID": countryId,
};
}

@ -1,10 +1,15 @@
import 'package:mc_common_app/api/api_client.dart';
import 'package:mc_common_app/classes/consts.dart';
import 'package:mc_common_app/config/dependencies.dart';
import 'package:mc_common_app/models/advertisment_models/ad_details_model.dart';
import 'package:mc_common_app/models/advertisment_models/ads_duration_model.dart';
import 'package:mc_common_app/models/advertisment_models/ads_generic_model.dart';
import 'package:mc_common_app/models/advertisment_models/special_service_model.dart';
import 'package:mc_common_app/models/advertisment_models/vehicle_details_models.dart';
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 'package:mc_common_app/classes/app_state.dart';
abstract class CommonRepo {
Future<Country> getAllCountries();
@ -12,12 +17,51 @@ abstract class CommonRepo {
Future<Cities> getAllCites(String countryId);
Future<Role> getRoles();
Future<List<VehicleTypeModel>> getVehicleTypes();
Future<List<VehicleModel>> getVehicleModels({required int vehicleTypeId});
Future<List<VehicleYearModel>> getVehicleModelYears({required int vehicleTypeId});
Future<List<VehicleColorModel>> getVehicleColors({required int vehicleTypeId});
Future<List<VehicleConditionModel>> getVehicleConditions({required int vehicleTypeId});
Future<List<VehicleCategoryModel>> getVehicleCategories({required int vehicleTypeId});
Future<List<VehicleMileageModel>> getVehicleMileages({required int vehicleTypeId});
Future<List<VehicleTransmissionModel>> getVehicleTransmission({required int vehicleTypeId});
Future<List<VehicleSellerTypeModel>> getVehicleSellerTypes({required int vehicleTypeId});
Future<List<VehicleCountryModel>> getVehicleCountries();
Future<List<VehicleCityModel>> getVehicleCities({required int countryId});
Future<List<VehiclePartModel>> getVehicleDamageParts();
Future<VehicleDetailsModel> getVehicleDetails({required int vehicleTypeId});
Future<List<AdsDurationModel>> getAdsDuration();
Future<List<SpecialServiceModel>> getSpecialServices();
Future<AdsGenericModel> createNewAd({required AdsCreationPayloadModel adsCreationPayloadModel});
Future<List<AdDetailsModel>> getAllAds();
Future<List<AdDetailsModel>> getMyAds();
}
class CommonRepoImp implements CommonRepo {
ApiClient apiClient = injector.get<ApiClient>();
AppState appState = injector.get<AppState>();
@override
Future<Country> getAllCountries() async {
return await injector.get<ApiClient>().getJsonForObject((json) => Country.fromJson(json), ApiConsts.GetAllCountry);
return await apiClient.getJsonForObject((json) => Country.fromJson(json), ApiConsts.GetAllCountry);
}
@override
@ -25,11 +69,291 @@ class CommonRepoImp implements CommonRepo {
var postParams = {
"CountryID": countryId,
};
return await injector.get<ApiClient>().getJsonForObject((json) => Cities.fromJson(json), ApiConsts.GetAllCities, queryParameters: postParams);
return await apiClient.getJsonForObject((json) => Cities.fromJson(json), ApiConsts.GetAllCities, queryParameters: postParams);
}
@override
Future<Role> getRoles() async {
return await injector.get<ApiClient>().getJsonForObject((json) => Role.fromJson(json), ApiConsts.GetProviderRoles);
return await apiClient.getJsonForObject((json) => Role.fromJson(json), ApiConsts.GetProviderRoles);
}
@override
Future<List<VehicleTypeModel>> getVehicleTypes() async {
AdsGenericModel adsGenericModel = await apiClient.getJsonForObject(token: appState.getUser.data!.accessToken, (json) => AdsGenericModel.fromJson(json), ApiConsts.vehicleTypeGet);
List<VehicleTypeModel> vehicleTypes = List.generate(adsGenericModel.data.length, (index) => VehicleTypeModel.fromJson(adsGenericModel.data[index]));
return vehicleTypes;
}
@override
Future<List<VehicleCategoryModel>> getVehicleCategories({required int vehicleTypeId}) async {
var postParams = {
"VehicleType": vehicleTypeId.toString(),
};
AdsGenericModel adsGenericModel =
await apiClient.getJsonForObject(token: appState.getUser.data!.accessToken, (json) => AdsGenericModel.fromJson(json), ApiConsts.vehicleCategoryGet, queryParameters: postParams);
List<VehicleCategoryModel> vehicleCategories = List.generate(adsGenericModel.data.length, (index) => VehicleCategoryModel.fromJson(adsGenericModel.data[index]));
return vehicleCategories;
}
@override
Future<List<VehicleCityModel>> getVehicleCities({required int countryId}) async {
var postParams = {
"CountryID": countryId.toString(),
};
AdsGenericModel adsGenericModel =
await apiClient.getJsonForObject(token: appState.getUser.data!.accessToken, (json) => AdsGenericModel.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<VehicleColorModel>> getVehicleColors({required int vehicleTypeId}) async {
var postParams = {
"VehicleType": vehicleTypeId.toString(),
};
AdsGenericModel adsGenericModel =
await apiClient.getJsonForObject(token: appState.getUser.data!.accessToken, (json) => AdsGenericModel.fromJson(json), ApiConsts.vehicleColorGet, queryParameters: postParams);
List<VehicleColorModel> vehicleColors = List.generate(adsGenericModel.data.length, (index) => VehicleColorModel.fromJson(adsGenericModel.data[index]));
return vehicleColors;
}
@override
Future<List<VehicleConditionModel>> getVehicleConditions({required int vehicleTypeId}) async {
var postParams = {
"VehicleType": vehicleTypeId.toString(),
};
AdsGenericModel adsGenericModel =
await apiClient.getJsonForObject(token: appState.getUser.data!.accessToken, (json) => AdsGenericModel.fromJson(json), ApiConsts.vehicleConditionGet, queryParameters: postParams);
List<VehicleConditionModel> vehicleConditions = List.generate(adsGenericModel.data.length, (index) => VehicleConditionModel.fromJson(adsGenericModel.data[index]));
return vehicleConditions;
}
@override
Future<List<VehicleCountryModel>> getVehicleCountries() async {
AdsGenericModel adsGenericModel = await apiClient.getJsonForObject(
token: appState.getUser.data!.accessToken,
(json) => AdsGenericModel.fromJson(json),
ApiConsts.vehicleCountryGet,
);
List<VehicleCountryModel> vehicleConditions = List.generate(adsGenericModel.data.length, (index) => VehicleCountryModel.fromJson(adsGenericModel.data[index]));
return vehicleConditions;
}
@override
Future<List<VehicleMileageModel>> getVehicleMileages({required int vehicleTypeId}) async {
var postParams = {
"VehicleType": vehicleTypeId.toString(),
};
AdsGenericModel adsGenericModel =
await apiClient.getJsonForObject(token: appState.getUser.data!.accessToken, (json) => AdsGenericModel.fromJson(json), ApiConsts.vehicleMileageGet, queryParameters: postParams);
List<VehicleMileageModel> vehicleMileages = List.generate(adsGenericModel.data.length, (index) => VehicleMileageModel.fromJson(adsGenericModel.data[index]));
return vehicleMileages;
}
}
@override
Future<List<VehicleYearModel>> getVehicleModelYears({required int vehicleTypeId}) async {
var postParams = {
"VehicleType": vehicleTypeId.toString(),
};
AdsGenericModel adsGenericModel =
await apiClient.getJsonForObject(token: appState.getUser.data!.accessToken, (json) => AdsGenericModel.fromJson(json), ApiConsts.vehicleModelYearGet, queryParameters: postParams);
List<VehicleYearModel> vehicleModelYears = List.generate(adsGenericModel.data.length, (index) => VehicleYearModel.fromJson(adsGenericModel.data[index]));
return vehicleModelYears;
}
@override
Future<List<VehicleModel>> getVehicleModels({required int vehicleTypeId}) async {
var postParams = {
"VehicleType": vehicleTypeId.toString(),
};
AdsGenericModel adsGenericModel =
await apiClient.getJsonForObject(token: appState.getUser.data!.accessToken, (json) => AdsGenericModel.fromJson(json), ApiConsts.vehicleModelGet, queryParameters: postParams);
List<VehicleModel> vehicleModels = List.generate(adsGenericModel.data.length, (index) => VehicleModel.fromJson(adsGenericModel.data[index]));
return vehicleModels;
}
@override
Future<List<VehicleSellerTypeModel>> getVehicleSellerTypes({required int vehicleTypeId}) async {
var postParams = {
"VehicleType": vehicleTypeId.toString(),
};
AdsGenericModel adsGenericModel =
await apiClient.getJsonForObject(token: appState.getUser.data!.accessToken, (json) => AdsGenericModel.fromJson(json), ApiConsts.vehicleSellerTypeGet, queryParameters: postParams);
List<VehicleSellerTypeModel> vehicleSellerTypes = List.generate(adsGenericModel.data.length, (index) => VehicleSellerTypeModel.fromJson(adsGenericModel.data[index]));
return vehicleSellerTypes;
}
@override
Future<List<VehicleTransmissionModel>> getVehicleTransmission({required int vehicleTypeId}) async {
var postParams = {
"VehicleType": vehicleTypeId.toString(),
};
AdsGenericModel adsGenericModel =
await apiClient.getJsonForObject(token: appState.getUser.data!.accessToken, (json) => AdsGenericModel.fromJson(json), ApiConsts.vehicleTransmissionGet, queryParameters: postParams);
List<VehicleTransmissionModel> vehicleTransmissions = List.generate(adsGenericModel.data.length, (index) => VehicleTransmissionModel.fromJson(adsGenericModel.data[index]));
return vehicleTransmissions;
}
@override
Future<VehicleDetailsModel> getVehicleDetails({required int vehicleTypeId}) async {
var postParams = {
"vehicleType": vehicleTypeId.toString(),
"isVehicleBrand": "true",
"vehicleBrand": "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 ?? "";
AdsGenericModel adsGenericModel = await apiClient.postJsonForObject(
(json) => AdsGenericModel.fromJson(json),
ApiConsts.vehicleDetailsMaster,
postParams,
token: token,
);
VehicleDetailsModel vehicleDetails = VehicleDetailsModel.fromJson(adsGenericModel.data);
return vehicleDetails;
}
@override
Future<List<VehiclePartModel>> getVehicleDamageParts() async {
AdsGenericModel adsGenericModel = await apiClient.getJsonForObject(
token: appState.getUser.data!.accessToken,
(json) => AdsGenericModel.fromJson(json),
ApiConsts.vehicleDamagePartGet,
);
List<VehiclePartModel> vehicleParts = List.generate(adsGenericModel.data.length, (index) => VehiclePartModel.fromJson(adsGenericModel.data[index]));
return vehicleParts;
}
@override
Future<List<AdsDurationModel>> getAdsDuration() async {
AdsGenericModel adsGenericModel = await apiClient.getJsonForObject(
token: appState.getUser.data!.accessToken,
(json) => AdsGenericModel.fromJson(json),
ApiConsts.vehicleAdsDurationGet,
);
List<AdsDurationModel> vehicleAdsDuration = List.generate(adsGenericModel.data.length, (index) => AdsDurationModel.fromJson(adsGenericModel.data[index]));
return vehicleAdsDuration;
}
@override
Future<List<SpecialServiceModel>> getSpecialServices() async {
AdsGenericModel adsGenericModel = await apiClient.getJsonForObject(
token: appState.getUser.data!.accessToken,
(json) => AdsGenericModel.fromJson(json),
ApiConsts.vehicleAdsSpecialServicesGet,
);
List<SpecialServiceModel> vehicleAdsDuration = List.generate(adsGenericModel.data.length, (index) => SpecialServiceModel.fromJson(adsGenericModel.data[index]));
return vehicleAdsDuration;
}
@override
Future<AdsGenericModel> createNewAd({required AdsCreationPayloadModel adsCreationPayloadModel}) async {
List vehiclePostingImages = [];
adsCreationPayloadModel.vehiclePosting!.vehiclePostingImages?.forEach((element) {
var imageMap = {
"id": 0,
"imageName": element.imageName,
"imageUrl": element.imageUrl,
"imageStr": element.imageStr,
"vehiclePostingID": 0,
"vehiclePosting": null,
};
vehiclePostingImages.add(imageMap);
});
List vehiclePostingDamageParts = [];
adsCreationPayloadModel.vehiclePosting!.vehiclePostingDamageParts?.forEach((element) {
var imageMap = {
"id": 0,
"comment": element.comment,
"vehicleImageBase64": element.vehicleImageBase64,
"vehicleDamagePartID": element.vehicleDamagePartID,
"vehiclePostingID": 0,
"isActive": true
};
vehiclePostingDamageParts.add(imageMap);
});
var postParams = {
"ads": {
"id": 0,
"adsDurationID": adsCreationPayloadModel.ads!.adsDurationID,
"startDate": adsCreationPayloadModel.ads!.startDate,
"countryId": adsCreationPayloadModel.ads!.countryId,
"specialServiceIDs": adsCreationPayloadModel.ads!.specialServiceIDs,
"isMCHandled": false
},
"vehiclePosting": {
"id": 0,
"userID": adsCreationPayloadModel.vehiclePosting!.userID,
"vehicleType": adsCreationPayloadModel.vehiclePosting!.vehicleType,
"vehicleModelID": adsCreationPayloadModel.vehiclePosting!.vehicleModelID,
"vehicleModelYearID": adsCreationPayloadModel.vehiclePosting!.vehicleModelYearID,
"vehicleColorID": adsCreationPayloadModel.vehiclePosting!.vehicleColorID,
"vehicleCategoryID": adsCreationPayloadModel.vehiclePosting!.vehicleCategoryID,
"vehicleConditionID": adsCreationPayloadModel.vehiclePosting!.vehicleConditionID,
"vehicleMileageID": adsCreationPayloadModel.vehiclePosting!.vehicleMileageID,
"vehicleTransmissionID": adsCreationPayloadModel.vehiclePosting!.vehicleTransmissionID,
"vehicleSellerTypeID": adsCreationPayloadModel.vehiclePosting!.vehicleSellerTypeID,
"cityID": adsCreationPayloadModel.vehiclePosting!.cityID,
"price": adsCreationPayloadModel.vehiclePosting!.price,
"vehicleVIN": adsCreationPayloadModel.vehiclePosting!.vehicleVIN,
"vehicleDescription": adsCreationPayloadModel.vehiclePosting!.vehicleDescription,
"vehicleTitle": adsCreationPayloadModel.vehiclePosting!.vehicleTitle,
"vehicleDescriptionN": adsCreationPayloadModel.vehiclePosting!.vehicleDescription,
"isFinanceAvailable": adsCreationPayloadModel.vehiclePosting!.isFinanceAvailable,
"warantyYears": adsCreationPayloadModel.vehiclePosting!.warantyYears,
"demandAmount": adsCreationPayloadModel.vehiclePosting!.demandAmount,
// "adStatus": 1,
"vehiclePostingImages": vehiclePostingImages,
"vehiclePostingDamageParts": vehiclePostingDamageParts
}
};
String token = appState.getUser.data!.accessToken ?? "";
AdsGenericModel adsGenericModel = await apiClient.postJsonForObject(
(json) => AdsGenericModel.fromJson(json),
ApiConsts.vehicleAdsSingleStepCreate,
postParams,
token: token,
);
return Future.value(adsGenericModel);
}
@override
Future<List<AdDetailsModel>> getAllAds() async {
AdsGenericModel adsGenericModel = await apiClient.getJsonForObject(
token: appState.getUser.data!.accessToken,
(json) => AdsGenericModel.fromJson(json),
ApiConsts.vehicleAdsGet,
);
List<AdDetailsModel> vehicleAdsDetails = List.generate(adsGenericModel.data.length, (index) => AdDetailsModel.fromJson(adsGenericModel.data[index]));
return vehicleAdsDetails;
}
@override
Future<List<AdDetailsModel>> getMyAds() async {
var params = {
"userID": appState.getUser.data!.userInfo!.userId ?? "",
};
AdsGenericModel adsGenericModel = await apiClient.getJsonForObject(
token: appState.getUser.data!.accessToken,
(json) => AdsGenericModel.fromJson(json),
queryParameters: params,
ApiConsts.vehicleAdsGet,
);
List<AdDetailsModel> vehicleAdsDetails = List.generate(adsGenericModel.data.length, (index) => AdDetailsModel.fromJson(adsGenericModel.data[index]));
return vehicleAdsDetails;
}
}

@ -5,6 +5,8 @@ import 'package:image_picker/image_picker.dart';
import 'package:mc_common_app/utils/utils.dart';
abstract class CommonServices {
Future<List<File>> pickMultipleImages();
Future<File?> pickImageFromPhone(int sourceFlag);
Future<File?> pickFile({FileType fileType = FileType.custom, List<String?>? allowedExtensions});
@ -38,5 +40,24 @@ class CommonServicesImp implements CommonServices {
// User canceled the picker
return null;
}
return null;
}
@override
Future<List<File>> pickMultipleImages() async {
final picker = ImagePicker();
final pickedImagesXFiles = await picker.pickMultiImage();
List<File> pickedImages = [];
if (pickedImagesXFiles == null) {
return [];
}
if (pickedImagesXFiles.isEmpty) {
return [];
}
for (var element in pickedImagesXFiles) {
pickedImages.add(File(element.path));
}
return pickedImages;
}
}

@ -2,6 +2,7 @@ import 'dart:convert';
import 'dart:io';
import 'dart:typed_data';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:path/path.dart' as p;
@ -20,6 +21,23 @@ class Utils {
msg: message, toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.BOTTOM, timeInSecForIosWeb: 2, backgroundColor: Colors.black54, textColor: Colors.white, fontSize: 16.0);
}
static Future<String> pickDateFromDatePicker(BuildContext context) async {
DateTime? pickedDate = await showDatePicker(
context: context,
initialDate: DateTime.now(), //get today's date
firstDate: DateTime.now(), //DateTime.now() - not to allow to choose before today.
lastDate: DateTime(2101));
if (pickedDate == null) {
return "";
}
String formattedDate = DateFormat.yMMMMd().format(pickedDate); // format date in required form here we use yyyy-MM-dd that means time is removed
return formattedDate;
}
static dynamic getNotNullValue(List<dynamic> list, int index) {
try {
return list[index];
@ -174,7 +192,7 @@ class Utils {
static String checkFileExt(String path) {
String ex = p.extension(path);
var parts = ex.split('.');
return parts[1] ?? "png"; // '.dart'
return parts[1]; // '.dart'
}
static spacer() {

@ -1,31 +1,503 @@
import 'dart:convert';
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:mc_common_app/classes/app_state.dart';
import 'package:mc_common_app/classes/consts.dart';
import 'package:mc_common_app/config/dependencies.dart';
import 'package:mc_common_app/config/routes.dart';
import 'package:mc_common_app/models/advertisment_models/ad_details_model.dart';
import 'package:mc_common_app/models/advertisment_models/ads_duration_model.dart';
import 'package:mc_common_app/models/advertisment_models/ads_generic_model.dart';
import 'package:mc_common_app/models/advertisment_models/special_service_model.dart';
import 'package:mc_common_app/models/advertisment_models/vehicle_details_models.dart';
import 'package:mc_common_app/repositories/common_repo.dart';
import 'package:mc_common_app/services/services.dart';
import 'package:mc_common_app/utils/enums.dart';
import 'package:mc_common_app/utils/navigator.dart';
import 'package:mc_common_app/utils/utils.dart';
import 'package:mc_common_app/view_models/base_view_model.dart';
class AdVM extends BaseVM {
final CommonRepo commonRepo;
final CommonServices commonServices;
AdVM({required this.commonServices});
AdVM({required this.commonServices, required this.commonRepo});
AdCreationStepsEnum currentProgressStep = AdCreationStepsEnum.vehicleDetails;
void updateCurrentStep() {
VehicleDetailsModel? vehicleDetails;
List<VehicleTypeModel> vehicleTypes = [];
List<VehicleModel> vehicleModels = [];
List<VehicleYearModel> vehicleModelYears = [];
List<VehicleColorModel> vehicleColors = [];
List<VehicleConditionModel> vehicleConditions = [];
List<VehicleCategoryModel> vehicleCategories = [];
List<VehicleMileageModel> vehicleMileages = [];
List<VehicleTransmissionModel> vehicleTransmissions = [];
List<VehicleSellerTypeModel> vehicleSellerTypes = [];
List<VehiclePartModel> vehicleDamageParts = [];
List<VehicleCountryModel> vehicleCountries = [];
List<VehicleCityModel> vehicleCities = [];
List<AdsDurationModel> vehicleAdsDurations = [];
List<SpecialServiceModel> vehicleAdsSpecialServices = [];
String demandAmountError = "";
String vehicleVinError = "";
String vehicleTitleError = "";
String warrantyError = "";
String vehicleDescError = "";
String vehicleImageError = "";
String vehicleDamageImageError = "";
String adStartDateError = "";
List<AdDetailsModel> allAds = [];
List<AdDetailsModel> myAds = [];
bool isExploreAdsTapped = true;
void updateIsExploreAds(bool value) async {
isExploreAdsTapped = value;
// if (value) {
// await getAllAds();
// }
notifyListeners();
}
Future<void> getMyAds() async {
isFetchingLists = true;
myAds = await commonRepo.getMyAds();
isFetchingLists = true;
notifyListeners();
}
Future<void> getAllAds() async {
allAds = await commonRepo.getAllAds();
notifyListeners();
}
Future<void> getVehicleTypes() async {
vehicleTypes = await commonRepo.getVehicleTypes();
notifyListeners();
}
Future<void> getVehicleAdsDuration() async {
vehicleAdsDurations = await commonRepo.getAdsDuration();
notifyListeners();
}
Future<void> getVehicleAdsSpecialServices() async {
vehicleAdsSpecialServices = await commonRepo.getSpecialServices();
notifyListeners();
}
bool isFetchingLists = false;
bool isCountryFetching = false;
Future<void> getAllDataBasedOnVehicleTypeId() async {
if (vehicleTypeId.selectedId == -1) {
return;
}
isFetchingLists = true;
notifyListeners();
vehicleModels = await commonRepo.getVehicleModels(vehicleTypeId: vehicleTypeId.selectedId);
vehicleModelYears = await commonRepo.getVehicleModelYears(vehicleTypeId: vehicleTypeId.selectedId);
vehicleColors = await commonRepo.getVehicleColors(vehicleTypeId: vehicleTypeId.selectedId);
vehicleConditions = await commonRepo.getVehicleConditions(vehicleTypeId: vehicleTypeId.selectedId);
vehicleCategories = await commonRepo.getVehicleCategories(vehicleTypeId: vehicleTypeId.selectedId);
vehicleMileages = await commonRepo.getVehicleMileages(vehicleTypeId: vehicleTypeId.selectedId);
vehicleTransmissions = await commonRepo.getVehicleTransmission(vehicleTypeId: vehicleTypeId.selectedId);
vehicleCountries = await commonRepo.getVehicleCountries();
isFetchingLists = false;
notifyListeners();
}
Future<void> getVehicleDetailsByVehicleId() async {
if (vehicleTypeId.selectedId == -1) {
return;
}
isFetchingLists = true;
notifyListeners();
vehicleDetails = await commonRepo.getVehicleDetails(vehicleTypeId: vehicleTypeId.selectedId);
if (vehicleDetails != null) {
vehicleModels = vehicleDetails!.vehicleModels!;
vehicleModelYears = vehicleDetails!.vehicleModelYears!;
vehicleColors = vehicleDetails!.vehicleColors!;
vehicleConditions = vehicleDetails!.vehicleConditions!;
vehicleCategories = vehicleDetails!.vehicleCategories!;
vehicleMileages = vehicleDetails!.vehicleMileages!;
vehicleSellerTypes = vehicleDetails!.vehicleSellerTypes!;
vehicleTransmissions = vehicleDetails!.vehicleTransmissions!;
vehicleCountries = vehicleDetails!.vehicleCountries!;
}
isFetchingLists = false;
notifyListeners();
}
String selectionDurationStartDate = "";
void updateSelectionDurationStartDate(String date) {
selectionDurationStartDate = date;
if (selectionDurationStartDate.isNotEmpty) adStartDateError = "";
notifyListeners();
}
SelectionModel vehicleTypeId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
void updateSelectionVehicleTypeId(SelectionModel id) async {
vehicleTypeId = id;
getVehicleDetailsByVehicleId();
notifyListeners();
}
SelectionModel vehicleModelId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
void updateSelectionVehicleModelId(SelectionModel id) {
vehicleModelId = id;
notifyListeners();
}
SelectionModel vehicleModelYearId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
void updateSelectionVehicleModelYearId(SelectionModel id) {
vehicleModelYearId = id;
notifyListeners();
}
SelectionModel vehicleColorId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
void updateSelectionVehicleColorId(SelectionModel id) {
vehicleColorId = id;
notifyListeners();
}
SelectionModel vehicleConditionId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
void updateSelectionVehicleConditionId(SelectionModel id) {
vehicleConditionId = id;
notifyListeners();
}
SelectionModel vehicleCategoryId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
void updateSelectionVehicleCategoryId(SelectionModel id) {
vehicleCategoryId = id;
notifyListeners();
}
SelectionModel vehicleMileageId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
void updateSelectionVehicleMileageId(SelectionModel id) {
vehicleMileageId = id;
notifyListeners();
}
String vehicleVin = "";
void updateVehicleVin(String vin) {
vehicleVin = vin;
}
String warrantyDuration = "";
void updateVehicleWarrantyDuration(String warranty) {
warrantyDuration = warranty;
}
String vehicleDemandAmount = "";
void updateVehicleDemandAmount(String amount) {
vehicleDemandAmount = amount;
}
String vehicleTitle = "";
void updateVehicleTitle(String title) {
vehicleTitle = title;
}
String vehicleDescription = "";
void updateVehicleDescription(String desc) {
vehicleDescription = desc;
}
SelectionModel vehicleTransmissionId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
void updateSelectionVehicleTransmissionId(SelectionModel id) {
vehicleTransmissionId = id;
notifyListeners();
}
SelectionModel vehicleSellerTypeId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
void updateSelectionVehicleSellerTypeId(SelectionModel id) {
vehicleSellerTypeId = id;
notifyListeners();
}
SelectionModel vehicleDamagePartId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
void updateSelectionVehicleDamagePartId(SelectionModel id) {
vehicleDamagePartId = id;
notifyListeners();
}
SelectionModel vehicleCountryId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
void updateSelectionVehicleCountryId(SelectionModel id) async {
vehicleCountryId = id;
isCountryFetching = true;
notifyListeners();
vehicleCities = await commonRepo.getVehicleCities(countryId: vehicleCountryId.selectedId);
isCountryFetching = false;
notifyListeners();
}
SelectionModel vehicleCityId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
void updateSelectionVehicleCityId(SelectionModel id) {
vehicleCityId = id;
notifyListeners();
}
SelectionModel vehicleAdDurationId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
void updateVehicleAdDurationId(SelectionModel id) {
vehicleAdDurationId = id;
notifyListeners();
}
SelectionModel vehicleAdsSpecialServicesId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
void updateVehicleAdsSpecialServicesId(SelectionModel id) {
vehicleAdsSpecialServicesId = id;
notifyListeners();
}
bool isVehicleDetailsValidated() {
bool isValidated = true;
if (vehicleTypeId.selectedId == -1) {
vehicleTypeId.errorValue = "Please select vehicle type";
isValidated = false;
notifyListeners();
return isValidated;
} else {
vehicleTypeId.errorValue = "";
}
if (vehicleModelId.selectedId == -1) {
vehicleModelId.errorValue = "Please select vehicle model";
isValidated = false;
} else {
vehicleModelId.errorValue = "";
}
if (vehicleModelYearId.selectedId == -1) {
vehicleModelYearId.errorValue = "Please select vehicle model year";
isValidated = false;
} else {
vehicleModelYearId.errorValue = "";
}
if (vehicleColorId.selectedId == -1) {
vehicleColorId.errorValue = "Please select vehicle color";
isValidated = false;
} else {
vehicleColorId.errorValue = "";
}
if (vehicleConditionId.selectedId == -1) {
vehicleConditionId.errorValue = "Please select vehicle condition";
isValidated = false;
} else {
vehicleConditionId.errorValue = "";
}
if (vehicleCategoryId.selectedId == -1) {
vehicleCategoryId.errorValue = "Please select vehicle category";
isValidated = false;
} else {
vehicleCategoryId.errorValue = "";
}
if (vehicleMileageId.selectedId == -1) {
vehicleMileageId.errorValue = "Please select vehicle Mileage";
isValidated = false;
} else {
vehicleMileageId.errorValue = "";
}
if (vehicleTransmissionId.selectedId == -1) {
vehicleTransmissionId.errorValue = "Please select vehicle transmission";
isValidated = false;
} else {
vehicleTransmissionId.errorValue = "";
}
if (vehicleSellerTypeId.selectedId == -1) {
vehicleSellerTypeId.errorValue = "Please select vehicle seller type";
isValidated = false;
} else {
vehicleSellerTypeId.errorValue = "";
}
if (vehicleCountryId.selectedId == -1) {
vehicleCountryId.errorValue = "Please select any";
isValidated = false;
} else {
vehicleCountryId.errorValue = "";
}
if (vehicleCityId.selectedId != -1 && vehicleCityId.selectedId == -1) {
vehicleCityId.errorValue = "Please select vehicle city";
isValidated = false;
} else {
vehicleCityId.errorValue = "";
}
if (vehicleDemandAmount.isEmpty) {
demandAmountError = GlobalConsts.demandAmountError;
isValidated = false;
} else {
demandAmountError = "";
}
if (vehicleVin.isEmpty) {
vehicleVinError = GlobalConsts.vehicleVinError;
isValidated = false;
} else {
vehicleVinError = "";
}
if (vehicleTitle.isEmpty) {
vehicleTitleError = GlobalConsts.vehicleTitleError;
isValidated = false;
} else {
vehicleTitleError = "";
}
if (warrantyDuration.isEmpty) {
warrantyError = GlobalConsts.warrantyError;
isValidated = false;
} else {
warrantyError = "";
}
if (vehicleDescription.isEmpty) {
vehicleDescError = GlobalConsts.vehicleDescError;
isValidated = false;
} else {
vehicleDescError = "";
}
if (pickedVehicleImages.isEmpty || pickedVehicleImages.length < 3) {
vehicleImageError = GlobalConsts.attachImageError;
isValidated = false;
} else {
vehicleImageError = "";
}
notifyListeners();
return isValidated;
}
bool isDamagePartsValidated() {
bool isValidated = true;
if (vehicleDamagePartId.selectedId == -1) {
vehicleDamagePartId.errorValue = "Please select vehicle part";
isValidated = false;
} else {
vehicleDamagePartId.errorValue = "";
}
if (pickedDamageImages.isEmpty || pickedDamageImages.length < 3) {
vehicleDamageImageError = GlobalConsts.attachImageError;
isValidated = false;
} else {
vehicleDamageImageError = "";
}
notifyListeners();
return isValidated;
}
bool isAdDurationValidated() {
bool isValidated = true;
if (vehicleAdDurationId.selectedId == -1) {
vehicleAdDurationId.errorValue = "Please select vehicle part";
isValidated = false;
} else {
vehicleAdDurationId.errorValue = "";
}
if (selectionDurationStartDate.isEmpty) {
adStartDateError = GlobalConsts.adDurationDateError;
isValidated = false;
} else {
adStartDateError = "";
}
notifyListeners();
return isValidated;
}
void onBackButtonPressed(BuildContext context) {
switch (currentProgressStep) {
case AdCreationStepsEnum.vehicleDetails:
resetValues();
pop(context);
break;
case AdCreationStepsEnum.damageParts:
currentProgressStep = AdCreationStepsEnum.vehicleDetails;
notifyListeners();
break;
case AdCreationStepsEnum.adDuration:
currentProgressStep = AdCreationStepsEnum.damageParts;
notifyListeners();
break;
case AdCreationStepsEnum.damageParts:
case AdCreationStepsEnum.reviewAd:
currentProgressStep = AdCreationStepsEnum.adDuration;
notifyListeners();
break;
}
}
void updateCurrentStep(BuildContext context) async {
switch (currentProgressStep) {
case AdCreationStepsEnum.vehicleDetails:
if (isVehicleDetailsValidated()) {
currentProgressStep = AdCreationStepsEnum.damageParts;
getVehicleDamagePartsList();
notifyListeners();
}
break;
case AdCreationStepsEnum.damageParts:
if (isDamagePartsValidated()) {
currentProgressStep = AdCreationStepsEnum.adDuration;
getVehicleAdsDuration();
getVehicleAdsSpecialServices();
notifyListeners();
}
break;
case AdCreationStepsEnum.adDuration:
currentProgressStep = AdCreationStepsEnum.reviewAd;
notifyListeners();
if (isAdDurationValidated()) {
currentProgressStep = AdCreationStepsEnum.reviewAd;
notifyListeners();
}
break;
case AdCreationStepsEnum.reviewAd:
Utils.showLoading(context);
try {
int status = await createNewAd();
if (status != 1) {
Utils.hideLoading(context);
Utils.showToast("Something went wrong!");
return;
}
Utils.hideLoading(context);
Utils.showToast("A new ads has been created.");
navigateReplaceWithName(context, AppRoutes.dashboard);
} catch (e) {
Utils.hideLoading(context);
Utils.showToast("Error: ${e.toString()}");
}
break;
}
}
@ -37,10 +509,21 @@ class AdVM extends BaseVM {
notifyListeners();
}
List<File> pickedImages = [];
List<File> pickedVehicleImages = [];
void removeImageFromList(int index) {
pickedImages.removeAt(index);
void removeImageFromList(String filePath) {
int index = pickedVehicleImages.indexWhere((element) => element.path == filePath);
if (index == -1) {
return;
}
pickedVehicleImages.removeAt(index);
notifyListeners();
}
void pickMultipleImages() async {
List<File> Images = await commonServices.pickMultipleImages();
pickedVehicleImages.addAll(Images);
if (pickedVehicleImages.isNotEmpty) vehicleImageError = "";
notifyListeners();
}
@ -50,8 +533,123 @@ class AdVM extends BaseVM {
File? file = await commonServices.pickImageFromPhone(1);
if (file != null) {
pickedImages.add(file);
pickedVehicleImages.add(file);
notifyListeners();
}
}
List<File> pickedDamageImages = [];
void removeDamageImageFromList(String filePath) {
int index = pickedDamageImages.indexWhere((element) => element.path == filePath);
if (index == -1) {
return;
}
pickedDamageImages.removeAt(index);
notifyListeners();
}
void pickMultipleDamageImages() async {
List<File> Images = await commonServices.pickMultipleImages();
pickedDamageImages.addAll(Images);
if (pickedDamageImages.isNotEmpty) vehicleDamageImageError = "";
notifyListeners();
}
void resetValues() {
pickedDamageImages.clear();
pickedVehicleImages.clear();
currentProgressStep = AdCreationStepsEnum.vehicleDetails;
vehicleTypeId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
updateFinanceAvailableStatus(false);
notifyListeners();
}
Future<void> getVehicleDamagePartsList() async {
vehicleDamageParts = await commonRepo.getVehicleDamageParts();
notifyListeners();
}
Future<int> createNewAd() async {
AppState appState = injector.get<AppState>();
Ads ads = Ads(
adsDurationID: vehicleAdDurationId.selectedId,
startDate: selectionDurationStartDate,
countryId: vehicleCountryId.selectedId,
specialServiceIDs: [vehicleAdsSpecialServicesId.selectedId],
);
List<VehiclePostingImages> vehicleImages = [];
pickedVehicleImages.forEach((element) async {
vehicleImages.add(await convertFileToVehiclePostingImages(file: element));
});
List<VehiclePostingDamageParts> vehicleDamageImages = [];
vehicleDamageImages.add(await convertFileToVehiclePostingDamageParts(
file: pickedDamageImages.first,
damagePartId: vehicleDamagePartId.selectedId,
));
VehiclePosting vehiclePosting = VehiclePosting(
userID: appState.getUser.data!.userInfo!.userId,
vehicleType: vehicleTypeId.selectedId,
vehicleModelID: vehicleModelId.selectedId,
vehicleModelYearID: vehicleModelYearId.selectedId,
vehicleColorID: vehicleColorId.selectedId,
vehicleCategoryID: vehicleCategoryId.selectedId,
vehicleConditionID: vehicleConditionId.selectedId,
vehicleMileageID: vehicleMileageId.selectedId,
vehicleTransmissionID: vehicleTransmissionId.selectedId,
vehicleSellerTypeID: vehicleSellerTypeId.selectedId,
cityID: vehicleCityId.selectedId,
price: int.parse(vehicleDemandAmount),
vehicleVIN: vehicleVin,
vehicleDescription: vehicleDescription,
vehicleTitle: vehicleTitle,
vehicleDescriptionN: vehicleDescription,
isFinanceAvailable: financeAvailableStatus,
warantyYears: int.parse(warrantyDuration),
demandAmount: int.parse(vehicleDemandAmount),
vehiclePostingImages: vehicleImages,
vehiclePostingDamageParts: vehicleDamageImages,
);
AdsCreationPayloadModel adsCreationPayloadModel = AdsCreationPayloadModel(ads: ads, vehiclePosting: vehiclePosting);
AdsGenericModel respModel = await commonRepo.createNewAd(adsCreationPayloadModel: adsCreationPayloadModel);
return Future.value(respModel.messageStatus);
}
Future<VehiclePostingImages> convertFileToVehiclePostingImages({required File file}) async {
List<int> imageBytes = await file.readAsBytes();
String image = base64Encode(imageBytes);
String fileName = file.path.split('/').last;
VehiclePostingImages vehiclePostingImages = VehiclePostingImages(
imageName: fileName,
imageStr: image,
imageUrl: file.path,
);
return vehiclePostingImages;
}
Future<VehiclePostingDamageParts> convertFileToVehiclePostingDamageParts({required File file, required int damagePartId}) async {
List<int> imageBytes = await file.readAsBytes();
String image = base64Encode(imageBytes);
VehiclePostingDamageParts vehiclePostingDamageParts = VehiclePostingDamageParts(
vehicleImageBase64: image,
vehicleDamagePartID: damagePartId,
);
return vehiclePostingDamageParts;
}
}
class SelectionModel {
String selectedOption;
int selectedId;
String errorValue;
SelectionModel({
this.selectedOption = "",
this.errorValue = "",
this.selectedId = 0,
});
}

@ -5,7 +5,9 @@ import 'package:mc_common_app/extensions/int_extensions.dart';
import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/theme/colors.dart';
import 'package:mc_common_app/utils/enums.dart';
import 'package:mc_common_app/utils/utils.dart';
import 'package:mc_common_app/view_models/ad_view_model.dart';
import 'package:mc_common_app/views/advertisement/picked_images_container.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/txt_field.dart';
@ -85,140 +87,276 @@ class VehicleDetails extends StatelessWidget {
@override
Widget build(BuildContext context) {
List<DropValue> dropList = [
DropValue(0, "Maintenance", ""),
DropValue(1, "Car Wash", ""),
DropValue(2, "Monthly Checkup", ""),
DropValue(3, "Friendly Visit", ""),
DropValue(4, "Muftaa", ""),
];
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
"Vehicle Detail".toText(fontSize: 18, isBold: true),
8.height,
DropdownField(
(DropValue value) {},
list: dropList,
hint: "Vehicle Type",
),
8.height,
DropdownField(
(DropValue value) {},
list: dropList,
hint: "Vehicle Model",
),
8.height,
DropdownField(
(DropValue value) {},
list: dropList,
hint: "Vehicle Model Year",
),
8.height,
DropdownField(
(DropValue value) {},
list: dropList,
hint: "Vehicle Color",
),
8.height,
DropdownField(
(DropValue value) {},
list: dropList,
hint: "Vehicle Condition",
),
8.height,
DropdownField(
(DropValue value) {},
list: dropList,
hint: "Vehicle Category",
),
8.height,
TxtField(
hint: "Vehicle Mileage",
// onChanged: (v) => email = v,
),
8.height,
DropdownField(
(DropValue value) {},
list: dropList,
hint: "Vehicle Transmission",
),
8.height,
DropdownField(
(DropValue value) {},
list: dropList,
hint: "Vehicle Seller Type",
),
8.height,
DropdownField(
(DropValue value) {},
list: dropList,
hint: "Vehicle Country",
),
8.height,
DropdownField(
(DropValue value) {},
list: dropList,
hint: "Vehicle City",
),
8.height,
TxtField(
hint: "Demand Amount",
// onChanged: (v) => email = v,
),
8.height,
TxtField(
hint: "Vehicle VIN",
// onChanged: (v) => email = v,
),
8.height,
TxtField(
hint: "Vehicle Title",
// onChanged: (v) => email = v,
),
8.height,
TxtField(
hint: "Warranty Available (No. of Years)",
// onChanged: (v) => email = v,
),
8.height,
TxtField(
hint: "Vehicle Description",
maxLines: 5,
// onChanged: (v) => email = v,
),
22.height,
"Finance Available".toText(fontSize: 16),
8.height,
Consumer(builder: (BuildContext context, AdVM adVm, Widget? child) {
return Container(
width: 65,
height: 37,
decoration: BoxDecoration(
color: adVm.financeAvailableStatus ? MyColors.darkPrimaryColor : MyColors.white,
borderRadius: BorderRadius.circular(25.0),
border: Border.all(color: MyColors.black, width: 1.5),
),
child: CupertinoSwitch(
activeColor: MyColors.darkPrimaryColor,
trackColor: MyColors.white,
thumbColor: MyColors.grey98Color,
value: adVm.financeAvailableStatus,
onChanged: (value) {
adVm.updateFinanceAvailableStatus(value);
},
),
);
}),
28.height,
"Vehicle Pictures".toText(fontSize: 18, isBold: true),
8.height,
AttachImageContainer(onTap: () {
context.read<AdVM>().pickImageFromPhone(1);
}),
20.height,
],
).toWhiteContainer(width: double.infinity, allPading: 12, margin: EdgeInsets.symmetric(horizontal: 21, vertical: 10));
return Consumer(builder: (BuildContext context, AdVM adVM, Widget? child) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
"Vehicle Detail".toText(fontSize: 18, isBold: true),
8.height,
Builder(
builder: (BuildContext context) {
List<DropValue> vehicleTypesDrop = [];
for (var element in adVM.vehicleTypes) {
vehicleTypesDrop.add(DropValue(element.id?.toInt() ?? 0, element.vehicleTypeName ?? "", ""));
}
return DropdownField(
(DropValue value) => adVM.updateSelectionVehicleTypeId(SelectionModel(selectedId: value.id, selectedOption: value.value, errorValue: "")),
list: vehicleTypesDrop,
dropdownValue: adVM.vehicleTypeId.selectedId != -1 ? DropValue(adVM.vehicleTypeId.selectedId, adVM.vehicleTypeId.selectedOption, "") : null,
errorValue: adVM.vehicleTypeId.errorValue,
hint: "Vehicle Type",
);
},
),
if (adVM.vehicleTypeId.selectedId != -1) ...[
if (adVM.isFetchingLists) ...[
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
CircularProgressIndicator(),
],
).paddingAll(10),
] else ...[
8.height,
Builder(builder: (context) {
List<DropValue> vehicleModelsDrop = [];
for (var element in adVM.vehicleModels) {
vehicleModelsDrop.add(DropValue(element.id?.toInt() ?? 0, element.model ?? "", ""));
}
return DropdownField(
(DropValue value) => adVM.updateSelectionVehicleModelId(SelectionModel(selectedId: value.id, selectedOption: value.value)),
list: vehicleModelsDrop,
dropdownValue: adVM.vehicleModelId.selectedId != -1 ? DropValue(adVM.vehicleModelId.selectedId, adVM.vehicleModelId.selectedOption, "") : null,
hint: "Vehicle Model",
errorValue: adVM.vehicleModelId.errorValue,
);
}),
8.height,
Builder(builder: (context) {
List<DropValue> vehicleYearModelsDrop = [];
for (var element in adVM.vehicleModelYears) {
vehicleYearModelsDrop.add(DropValue(element.id?.toInt() ?? 0, element.modelYear ?? "", ""));
}
return DropdownField(
(DropValue value) => adVM.updateSelectionVehicleModelYearId(SelectionModel(selectedId: value.id, selectedOption: value.value)),
list: vehicleYearModelsDrop,
dropdownValue: adVM.vehicleModelYearId.selectedId != -1 ? DropValue(adVM.vehicleModelYearId.selectedId, adVM.vehicleModelYearId.selectedOption, "") : null,
hint: "Vehicle Model Year",
errorValue: adVM.vehicleModelYearId.errorValue,
);
}),
8.height,
Builder(builder: (context) {
List<DropValue> vehicleColorsDrop = [];
for (var element in adVM.vehicleColors) {
vehicleColorsDrop.add(DropValue(element.id?.toInt() ?? 0, element.color ?? "", ""));
}
return DropdownField(
(DropValue value) => adVM.updateSelectionVehicleColorId(SelectionModel(selectedId: value.id, selectedOption: value.value)),
list: vehicleColorsDrop,
hint: "Vehicle Color",
dropdownValue: adVM.vehicleColorId.selectedId != -1 ? DropValue(adVM.vehicleColorId.selectedId, adVM.vehicleColorId.selectedOption, "") : null,
errorValue: adVM.vehicleColorId.errorValue,
);
}),
8.height,
Builder(builder: (context) {
List<DropValue> vehicleConditionsDrop = [];
for (var element in adVM.vehicleConditions) {
vehicleConditionsDrop.add(DropValue(element.id?.toInt() ?? 0, element.condition ?? "", ""));
}
return DropdownField(
(DropValue value) => adVM.updateSelectionVehicleConditionId(SelectionModel(selectedId: value.id, selectedOption: value.value)),
list: vehicleConditionsDrop,
dropdownValue: adVM.vehicleConditionId.selectedId != -1 ? DropValue(adVM.vehicleConditionId.selectedId, adVM.vehicleConditionId.selectedOption, "") : null,
hint: "Vehicle Condition",
errorValue: adVM.vehicleConditionId.errorValue,
);
}),
8.height,
Builder(builder: (context) {
List<DropValue> vehicleCategoriesDrop = [];
for (var element in adVM.vehicleCategories) {
vehicleCategoriesDrop.add(DropValue(element.id?.toInt() ?? 0, element.category ?? "", ""));
}
return DropdownField(
(DropValue value) => adVM.updateSelectionVehicleCategoryId(SelectionModel(selectedId: value.id, selectedOption: value.value)),
list: vehicleCategoriesDrop,
hint: "Vehicle Category",
dropdownValue: adVM.vehicleCategoryId.selectedId != -1 ? DropValue(adVM.vehicleCategoryId.selectedId, adVM.vehicleCategoryId.selectedOption, "") : null,
errorValue: adVM.vehicleCategoryId.errorValue,
);
}),
8.height,
Builder(builder: (context) {
List<DropValue> vehicleMileageDrop = [];
for (var element in adVM.vehicleMileages) {
vehicleMileageDrop.add(DropValue(element.id?.toInt() ?? 0, "${element.mileageStart ?? ""} - ${element.mileageEnd ?? ""}", ""));
}
return DropdownField(
(DropValue value) => adVM.updateSelectionVehicleMileageId(SelectionModel(selectedId: value.id, selectedOption: value.value)),
list: vehicleMileageDrop,
dropdownValue: adVM.vehicleMileageId.selectedId != -1 ? DropValue(adVM.vehicleMileageId.selectedId, adVM.vehicleMileageId.selectedOption, "") : null,
hint: "Vehicle Mileage",
errorValue: adVM.vehicleMileageId.errorValue,
);
}),
8.height,
Builder(builder: (context) {
List<DropValue> vehicleTransmissionsDrop = [];
for (var element in adVM.vehicleTransmissions) {
vehicleTransmissionsDrop.add(DropValue(element.id?.toInt() ?? 0, element.transmission ?? "", ""));
}
return DropdownField(
(DropValue value) => adVM.updateSelectionVehicleTransmissionId(SelectionModel(selectedId: value.id, selectedOption: value.value)),
list: vehicleTransmissionsDrop,
hint: "Vehicle Transmission",
errorValue: adVM.vehicleTransmissionId.errorValue,
);
}),
8.height,
Builder(builder: (context) {
List<DropValue> vehicleSellerTypesDrop = [];
for (var element in adVM.vehicleSellerTypes) {
vehicleSellerTypesDrop.add(DropValue(element.id?.toInt() ?? 0, element.sellerType ?? "", ""));
}
return DropdownField(
(DropValue value) => adVM.updateSelectionVehicleSellerTypeId(SelectionModel(selectedId: value.id, selectedOption: value.value)),
list: vehicleSellerTypesDrop,
dropdownValue: adVM.vehicleSellerTypeId.selectedId != -1 ? DropValue(adVM.vehicleSellerTypeId.selectedId, adVM.vehicleSellerTypeId.selectedOption, "") : null,
hint: "Vehicle Seller Type",
errorValue: adVM.vehicleSellerTypeId.errorValue,
);
}),
8.height,
Builder(builder: (context) {
List<DropValue> vehicleCountriesDrop = [];
for (var element in adVM.vehicleCountries) {
vehicleCountriesDrop.add(DropValue(element.id?.toInt() ?? 0, element.countryName ?? "", ""));
}
return DropdownField(
(DropValue value) => adVM.updateSelectionVehicleCountryId(SelectionModel(selectedOption: value.value, selectedId: value.id)),
list: vehicleCountriesDrop,
dropdownValue: adVM.vehicleCountryId.selectedId != -1 ? DropValue(adVM.vehicleCountryId.selectedId, adVM.vehicleCountryId.selectedOption, "") : null,
hint: "Vehicle Country",
errorValue: adVM.vehicleCountryId.errorValue,
);
}),
if (adVM.vehicleCountryId.selectedId != -1) ...[
if (adVM.isCountryFetching) ...[
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [const CircularProgressIndicator().paddingAll(10)],
),
] else ...[
8.height,
Builder(builder: (context) {
List<DropValue> vehicleCitiesDrop = [];
for (var element in adVM.vehicleCities) {
vehicleCitiesDrop.add(DropValue(element.id?.toInt() ?? 0, element.cityName ?? "", ""));
}
return DropdownField(
(DropValue value) => adVM.updateSelectionVehicleCityId(SelectionModel(selectedId: value.id, selectedOption: value.value)),
list: vehicleCitiesDrop,
dropdownValue: adVM.vehicleCityId.selectedId != -1 ? DropValue(adVM.vehicleCityId.selectedId, adVM.vehicleCityId.selectedOption, "") : null,
hint: "Vehicle City",
errorValue: adVM.vehicleCityId.errorValue,
);
}),
],
],
8.height,
TxtField(
value: adVM.vehicleDemandAmount,
errorValue: adVM.demandAmountError,
hint: "Demand Amount",
onChanged: (v) => adVM.updateVehicleDemandAmount(v),
),
8.height,
TxtField(
value: adVM.vehicleVin,
errorValue: adVM.vehicleVinError,
hint: "Vehicle VIN",
onChanged: (v) => adVM.updateVehicleVin(v),
),
8.height,
TxtField(
value: adVM.vehicleTitle,
errorValue: adVM.vehicleTitleError,
hint: "Vehicle Title",
onChanged: (v) => adVM.updateVehicleTitle(v),
),
8.height,
TxtField(
value: adVM.warrantyDuration,
errorValue: adVM.warrantyError,
hint: "Warranty Available (No. of Years)",
onChanged: (v) => adVM.updateVehicleWarrantyDuration(v),
),
8.height,
TxtField(
value: adVM.vehicleDescription,
hint: "Vehicle Description",
maxLines: 5,
errorValue: adVM.vehicleDescError,
onChanged: (v) => adVM.updateVehicleDescription(v),
),
22.height,
"Finance Available".toText(fontSize: 16),
8.height,
Container(
width: 65,
height: 37,
decoration: BoxDecoration(
color: adVM.financeAvailableStatus ? MyColors.darkPrimaryColor : MyColors.white,
borderRadius: BorderRadius.circular(25.0),
border: Border.all(color: MyColors.black, width: 1.5),
),
child: CupertinoSwitch(
activeColor: MyColors.darkPrimaryColor,
trackColor: MyColors.white,
thumbColor: MyColors.grey98Color,
value: adVM.financeAvailableStatus,
onChanged: (value) {
adVM.updateFinanceAvailableStatus(value);
},
),
),
28.height,
"Vehicle Pictures".toText(fontSize: 18, isBold: true),
8.height,
AttachImageContainer(onTap: () {
context.read<AdVM>().pickMultipleImages();
}),
if (adVM.vehicleImageError != "") ...[
10.height,
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
adVM.vehicleImageError.toText(fontSize: 14, color: Colors.red),
],
).paddingOnly(right: 10)
],
if (adVM.pickedVehicleImages.isNotEmpty) ...[
16.height,
PickedImagesContainer(
pickedImages: adVM.pickedVehicleImages,
onCrossPressed: adVM.removeImageFromList,
),
],
15.height,
],
]
],
).toWhiteContainer(width: double.infinity, allPading: 12, margin: const EdgeInsets.symmetric(horizontal: 21, vertical: 10));
});
}
}
@ -227,30 +365,53 @@ class DamageParts extends StatelessWidget {
@override
Widget build(BuildContext context) {
List<DropValue> dropList = [
DropValue(0, "Door Handles", ""),
DropValue(1, "Wind Screen", ""),
DropValue(2, "Rear Light", ""),
DropValue(3, "Bumper", ""),
DropValue(4, "Headlight", ""),
];
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
"Vehicle Damage Pictures".toText(fontSize: 18, isBold: true),
8.height,
DropdownField(
(DropValue value) {},
list: dropList,
hint: "Vehicle Part",
),
8.height,
AttachImageContainer(onTap: () {
context.read<AdVM>().pickImageFromPhone(1);
}),
20.height,
],
).toWhiteContainer(width: double.infinity, allPading: 12, margin: EdgeInsets.symmetric(horizontal: 21, vertical: 10));
return Consumer(
builder: (BuildContext context, AdVM adVM, Widget? child) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
"Vehicle Damage Pictures".toText(fontSize: 18, isBold: true),
8.height,
Builder(builder: (context) {
List<DropValue> vehicleDamagePartsDrop = [];
for (var element in adVM.vehicleDamageParts) {
vehicleDamagePartsDrop.add(DropValue(element.id?.toInt() ?? 0, element.partName ?? "", ""));
}
return DropdownField(
(DropValue value) {
adVM.updateSelectionVehicleDamagePartId(SelectionModel(selectedOption: value.value, selectedId: value.id));
},
dropdownValue: adVM.vehicleDamagePartId.selectedId != -1 ? DropValue(adVM.vehicleDamagePartId.selectedId, adVM.vehicleDamagePartId.selectedOption, "") : null,
list: vehicleDamagePartsDrop,
hint: "Vehicle Part",
errorValue: adVM.vehicleDamagePartId.errorValue,
);
}),
8.height,
AttachImageContainer(onTap: () {
adVM.pickMultipleDamageImages();
}),
if (adVM.vehicleDamageImageError != "") ...[
10.height,
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
adVM.vehicleDamageImageError.toText(fontSize: 14, color: Colors.red),
],
).paddingOnly(right: 10)
],
if (adVM.pickedDamageImages.isNotEmpty) ...[
16.height,
PickedImagesContainer(
pickedImages: adVM.pickedDamageImages,
onCrossPressed: adVM.removeDamageImageFromList,
),
],
20.height,
],
).toWhiteContainer(width: double.infinity, allPading: 12, margin: const EdgeInsets.symmetric(horizontal: 21, vertical: 10));
},
);
}
}
@ -259,55 +420,73 @@ class AdDuration extends StatelessWidget {
@override
Widget build(BuildContext context) {
List<DropValue> dropList = [
DropValue(0, "One Week", ""),
DropValue(1, "Two Weeks", ""),
DropValue(2, "Three Weeks", ""),
DropValue(3, "One Month", ""),
];
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
"Ad Duration".toText(fontSize: 18, isBold: true),
8.height,
DropdownField(
(DropValue value) {},
list: dropList,
hint: "Select Duration",
),
8.height,
DropdownField(
(DropValue value) {},
list: dropList,
hint: "Start Date",
),
28.height,
"Select Special Services".toText(fontSize: 18, isBold: true),
8.height,
DropdownField(
(DropValue value) {},
list: dropList,
hint: "Ad Management",
),
20.height,
],
).toWhiteContainer(width: double.infinity, allPading: 12, margin: EdgeInsets.symmetric(horizontal: 21, vertical: 10));
return Consumer(
builder: (BuildContext context, AdVM adVM, Widget? child) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
"Ad Duration".toText(fontSize: 18, isBold: true),
8.height,
Builder(builder: (context) {
List<DropValue> vehicleAdsDurationsDrop = [];
for (var element in adVM.vehicleAdsDurations) {
vehicleAdsDurationsDrop.add(DropValue(element.id?.toInt() ?? 0, element.name ?? "", ""));
}
return DropdownField(
(DropValue value) => adVM.updateVehicleAdDurationId(SelectionModel(selectedId: value.id, selectedOption: value.value)),
errorValue: adVM.vehicleAdDurationId.errorValue,
list: vehicleAdsDurationsDrop,
hint: "Select Duration",
);
}),
8.height,
TxtField(
errorValue: adVM.adStartDateError,
hint: 'Start Date',
value: adVM.selectionDurationStartDate,
isNeedClickAll: true,
postfixData: Icons.calendar_month_rounded,
postFixDataColor: MyColors.lightTextColor,
onTap: () async {
final formattedDate = await Utils.pickDateFromDatePicker(context);
adVM.updateSelectionDurationStartDate(formattedDate);
},
),
28.height,
"Select Special Services".toText(fontSize: 18, isBold: true),
8.height,
Builder(builder: (context) {
List<DropValue> vehicleAdsSpecialServices = [];
for (var element in adVM.vehicleAdsSpecialServices) {
vehicleAdsSpecialServices.add(DropValue(element.id?.toInt() ?? 0, element.name ?? "", ""));
}
return DropdownField(
(DropValue value) => adVM.updateVehicleAdsSpecialServicesId(SelectionModel(selectedId: value.id, selectedOption: value.value)),
list: vehicleAdsSpecialServices,
hint: "Select Service",
);
}),
20.height,
],
).toWhiteContainer(width: double.infinity, allPading: 12, margin: const EdgeInsets.symmetric(horizontal: 21, vertical: 10));
},
);
}
}
class SingleDetailWidget extends StatelessWidget {
final String title;
final String subTitle;
final String text;
final String type;
const SingleDetailWidget({Key? key, required this.title, required this.subTitle}) : super(key: key);
const SingleDetailWidget({Key? key, required this.text, required this.type}) : super(key: key);
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
"$subTitle:".toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true),
title.toText(fontSize: 14, color: MyColors.black, isBold: true),
"$type:".toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true),
text.toText(fontSize: 14, color: MyColors.black, isBold: true),
],
);
}
@ -320,7 +499,7 @@ class ReviewAd extends StatelessWidget {
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
children: const [
VehicleDetailsReview(),
DamagePartsReview(),
AdDurationReview(),
@ -334,73 +513,80 @@ class VehicleDetailsReview extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
"Vehicle Details".toText(fontSize: 18, isBold: true),
8.height,
Row(
mainAxisAlignment: MainAxisAlignment.start,
return Consumer(
builder: (BuildContext context, AdVM adVM, Widget? child) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 5,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SingleDetailWidget(title: "Vehicle Type", subTitle: "Car"),
16.height,
SingleDetailWidget(title: "Vehicle Type", subTitle: "Car"),
16.height,
SingleDetailWidget(title: "Vehicle Type", subTitle: "Car"),
16.height,
SingleDetailWidget(title: "Vehicle Type", subTitle: "Car"),
16.height,
SingleDetailWidget(title: "Vehicle Type", subTitle: "Car"),
16.height,
SingleDetailWidget(title: "Vehicle Type", subTitle: "Car"),
16.height,
SingleDetailWidget(title: "Vehicle Type", subTitle: "Car"),
16.height,
SingleDetailWidget(title: "Vehicle Type", subTitle: "Car"),
16.height,
],
),
"Vehicle Details".toText(fontSize: 18, isBold: true),
8.height,
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Expanded(
flex: 5,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SingleDetailWidget(text: adVM.vehicleTypeId.selectedOption, type: "Vehicle Type"),
16.height,
SingleDetailWidget(text: adVM.vehicleModelYearId.selectedOption, type: "Vehicle Year"),
16.height,
SingleDetailWidget(text: adVM.vehicleConditionId.selectedOption, type: "Vehicle Condition"),
16.height,
SingleDetailWidget(text: adVM.vehicleMileageId.selectedOption, type: "Vehicle Mileage"),
16.height,
SingleDetailWidget(text: adVM.vehicleSellerTypeId.selectedOption, type: "Seller Type"),
16.height,
SingleDetailWidget(text: adVM.vehicleCityId.selectedOption, type: "Vehicle City"),
16.height,
SingleDetailWidget(text: adVM.vehicleVin, type: "Vehicle VIN"),
16.height,
],
),
),
Expanded(
flex: 5,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SingleDetailWidget(text: adVM.vehicleModelId.selectedOption, type: "Vehicle Model"),
16.height,
SingleDetailWidget(text: adVM.vehicleColorId.selectedOption, type: "Vehicle Color"),
16.height,
SingleDetailWidget(text: adVM.vehicleCategoryId.selectedOption, type: "Vehicle Category"),
16.height,
SingleDetailWidget(text: adVM.vehicleTransmissionId.selectedOption, type: "Vehicle Transmission"),
16.height,
SingleDetailWidget(text: adVM.vehicleCountryId.selectedOption, type: "Vehicle Country"),
16.height,
SingleDetailWidget(text: adVM.vehicleDemandAmount, type: "Vehicle Amount"),
16.height,
SingleDetailWidget(text: adVM.vehicleTitle, type: "Vehicle Title"),
16.height,
],
),
),
],
),
Expanded(
flex: 5,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SingleDetailWidget(title: "Vehicle Type", subTitle: "Car"),
16.height,
SingleDetailWidget(title: "Vehicle Type", subTitle: "Car"),
16.height,
SingleDetailWidget(title: "Vehicle Type", subTitle: "Car"),
16.height,
SingleDetailWidget(title: "Vehicle Type", subTitle: "Car"),
16.height,
SingleDetailWidget(title: "Vehicle Type", subTitle: "Car"),
16.height,
SingleDetailWidget(title: "Vehicle Type", subTitle: "Car"),
16.height,
SingleDetailWidget(title: "Vehicle Type", subTitle: "Car"),
16.height,
SingleDetailWidget(title: "Vehicle Type", subTitle: "Car"),
16.height,
],
SingleDetailWidget(text: adVM.warrantyDuration, type: "Warranty Available"),
8.height,
SingleDetailWidget(text: adVM.vehicleDescription, type: "Description"),
8.height,
SingleDetailWidget(text: adVM.financeAvailableStatus ? "Yes" : "No", type: "Finance Available"),
8.height,
"Vehicle Pictures:".toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true),
if (adVM.pickedVehicleImages.isNotEmpty) ...[
// 10.height,
PickedImagesContainer(
pickedImages: adVM.pickedVehicleImages,
onCrossPressed: adVM.removeImageFromList,
),
),
],
],
),
SingleDetailWidget(title: "Warranty Available", subTitle: "0 Years"),
8.height,
SingleDetailWidget(subTitle: "Description", title: "Some Two lines Description about the car and its unique features"),
8.height,
SingleDetailWidget(subTitle: "Finance Available", title: "No"),
8.height,
"Vehicle Pictures:".toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true),
],
).toWhiteContainer(width: double.infinity, allPading: 12, margin: EdgeInsets.symmetric(horizontal: 21, vertical: 10));
).toWhiteContainer(width: double.infinity, allPading: 12, margin: const EdgeInsets.symmetric(horizontal: 21, vertical: 10));
},
);
}
}
@ -409,20 +595,31 @@ class DamagePartsReview extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
"Vehicle Damage Part".toText(fontSize: 18, isBold: true),
8.height,
Row(
return Consumer(
builder: (BuildContext context, AdVM adVM, Widget? child) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SingleDetailWidget(subTitle: "Vehicle Part", title: "Bumper"),
"Vehicle Damage Part".toText(fontSize: 18, isBold: true),
8.height,
Row(
children: [
SingleDetailWidget(type: "Vehicle Part", text: adVM.vehicleDamagePartId.selectedOption),
],
),
8.height,
"Damage Part Pictures:".toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true),
if (adVM.pickedDamageImages.isNotEmpty) ...[
// 16.height,
PickedImagesContainer(
pickedImages: adVM.pickedDamageImages,
onCrossPressed: adVM.removeDamageImageFromList,
),
],
],
),
8.height,
"Damage Part Pictures:".toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true),
],
).toWhiteContainer(width: double.infinity, allPading: 12, margin: EdgeInsets.symmetric(horizontal: 21, vertical: 10));
).toWhiteContainer(width: double.infinity, allPading: 12, margin: const EdgeInsets.symmetric(horizontal: 21, vertical: 10));
},
);
}
}
@ -431,36 +628,40 @@ class AdDurationReview extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
"Vehicle Damage Part".toText(fontSize: 18, isBold: true),
8.height,
Row(
return Consumer(
builder: (BuildContext context, AdVM adVM, Widget? child) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 5,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SingleDetailWidget(subTitle: "Duration", title: "One Week"),
8.height,
SingleDetailWidget(subTitle: "Special Services", title: "Ad Management"),
],
),
),
Expanded(
flex: 5,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SingleDetailWidget(subTitle: "Start Date", title: "5 February, 2023"),
],
),
"Vehicle Damage Part".toText(fontSize: 18, isBold: true),
8.height,
Row(
children: [
Expanded(
flex: 5,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SingleDetailWidget(type: "Duration", text: adVM.vehicleAdDurationId.selectedOption),
8.height,
SingleDetailWidget(type: "Special Service", text: adVM.vehicleAdsSpecialServicesId.selectedOption),
],
),
),
Expanded(
flex: 5,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SingleDetailWidget(type: "Start Date", text: adVM.selectionDurationStartDate),
],
),
),
],
),
],
),
],
).toWhiteContainer(width: double.infinity, allPading: 12, margin: EdgeInsets.symmetric(horizontal: 21, vertical: 10));
).toWhiteContainer(width: double.infinity, allPading: 12, margin: const EdgeInsets.symmetric(horizontal: 21, vertical: 10));
},
);
}
}

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:mc_common_app/classes/consts.dart';
import 'package:mc_common_app/extensions/int_extensions.dart';
import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/models/advertisment_models/ad_details_model.dart';
import 'package:mc_common_app/theme/colors.dart';
import 'package:mc_common_app/views/advertisement/ads_images_slider.dart';
import 'package:mc_common_app/widgets/button/show_fill_button.dart';
@ -9,7 +10,9 @@ import 'package:mc_common_app/widgets/common_widgets/app_bar.dart';
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
class AdsDetailView extends StatelessWidget {
const AdsDetailView({Key? key}) : super(key: key);
final AdDetailsModel adDetails;
const AdsDetailView({Key? key, required this.adDetails}) : super(key: key);
@override
Widget build(BuildContext context) {
@ -29,12 +32,12 @@ class AdsDetailView extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const CarouselWithIndicatorDemo(),
CarouselWithIndicatorDemo(vehicleImages: adDetails.vehicle!.image!),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
"Toyota Corolla | Silver".toText(fontSize: 18, isBold: true),
"Jeddah".toText(fontSize: 10, isBold: true, color: MyColors.lightTextColor),
"${adDetails.vehicle!.vehicleTitle} | ${adDetails.vehicle!.color!.label}".toText(fontSize: 18, isBold: true),
(adDetails.vehicle!.cityName ?? "").toText(fontSize: 10, isBold: true, color: MyColors.lightTextColor),
],
),
Row(
@ -43,13 +46,13 @@ class AdsDetailView extends StatelessWidget {
Row(
children: [
"Model: ".toText(fontSize: 14, isBold: true, color: MyColors.lightTextColor),
"2019".toText(
"${adDetails.vehicle!.modelyear!.label}".toText(
fontSize: 14,
isBold: true,
),
],
),
"Saudi Arabia".toText(fontSize: 10, isBold: true, color: MyColors.lightTextColor),
"${adDetails.vehicle!.countryID}".toText(fontSize: 10, isBold: true, color: MyColors.lightTextColor),
],
),
Row(
@ -58,19 +61,19 @@ class AdsDetailView extends StatelessWidget {
Row(
children: [
"Mileage: ".toText(fontSize: 14, isBold: true, color: MyColors.lightTextColor),
"10928Km".toText(
"${adDetails.vehicle!.mileage!.mileageEnd}Km".toText(
fontSize: 14,
isBold: true,
),
],
),
"5 Hours ago".toText(fontSize: 10, isBold: true, color: MyColors.lightTextColor),
"${adDetails.createdOn}".toText(fontSize: 10, isBold: true, color: MyColors.lightTextColor),
],
),
Row(
children: [
"Transmission: ".toText(fontSize: 14, isBold: true, color: MyColors.lightTextColor),
"Automatic".toText(
"${adDetails.vehicle!.transmission!.label}".toText(
fontSize: 14,
isBold: true,
),
@ -78,7 +81,7 @@ class AdsDetailView extends StatelessWidget {
),
8.height,
"Description: ".toText(fontSize: 14, isBold: true, color: MyColors.lightTextColor),
"No Issue in the car. All parts are genuine with no major accident. ".toText(
"${adDetails.vehicle!.vehicleDescription}".toText(
fontSize: 14,
isBold: true,
),
@ -86,16 +89,16 @@ class AdsDetailView extends StatelessWidget {
).toWhiteContainer(width: double.infinity, allPading: 12),
Align(
alignment: Alignment.bottomCenter,
child: Container(
child: SizedBox(
height: 150,
child: Column(
children: [
Divider(thickness: 1, height: 1),
const Divider(thickness: 1, height: 1),
18.height,
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
"35,000".toText(fontSize: 30, isBold: true),
adDetails.vehicle!.demandAmount!.toInt().toString().toText(fontSize: 30, isBold: true),
"SAR".toText(fontSize: 15, isBold: true, color: MyColors.lightTextColor),
],
),
@ -115,8 +118,8 @@ class AdsDetailView extends StatelessWidget {
width: 55,
alignment: Alignment.center,
decoration: BoxDecoration(border: Border.all(color: MyColors.black, width: 3)),
child: Icon(Icons.phone, color: MyColors.black),
),
child: const Icon(Icons.phone, color: MyColors.black),
).onPress(() {}),
],
),
],

@ -1,10 +1,12 @@
import 'package:flutter/material.dart';
import 'package:carousel_slider/carousel_slider.dart';
import 'package:mc_common_app/classes/consts.dart';
import 'package:mc_common_app/models/advertisment_models/ad_details_model.dart';
import 'package:mc_common_app/theme/colors.dart';
class CarouselWithIndicatorDemo extends StatefulWidget {
const CarouselWithIndicatorDemo({super.key});
final List<AdImage> vehicleImages;
const CarouselWithIndicatorDemo({key, required this.vehicleImages});
@override
State<StatefulWidget> createState() => _CarouselWithIndicatorState();
@ -14,22 +16,32 @@ class _CarouselWithIndicatorState extends State<CarouselWithIndicatorDemo> {
int _current = 0;
final CarouselController _controller = CarouselController();
final imgList = [
MyAssets.bnCar,
MyAssets.bnCar,
MyAssets.bnCar,
];
// final imgList = [
// MyAssets.bnCar,
// MyAssets.bnCar,
// MyAssets.bnCar,
// ];
@override
Widget build(BuildContext context) {
return Column(children: [
CarouselSlider(
items: imgList
items: widget.vehicleImages
.map((item) => Container(
margin: EdgeInsets.all(5.0),
child: ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(5.0)),
child: Image.asset(item, fit: BoxFit.cover),
child: Image.network(
item.imageUrl!,
fit: BoxFit.cover,
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
return const SizedBox(
width: 80,
height: 80,
child: Icon(Icons.error_outline),
);
},
),
),
))
.toList(),
@ -46,7 +58,7 @@ class _CarouselWithIndicatorState extends State<CarouselWithIndicatorDemo> {
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: imgList.asMap().entries.map((entry) {
children: widget.vehicleImages.asMap().entries.map((entry) {
return GestureDetector(
onTap: () => _controller.animateToPage(entry.key),
child: Container(

@ -1,36 +1,42 @@
import 'package:flutter/material.dart';
import 'package:mc_common_app/classes/consts.dart';
import 'package:mc_common_app/config/routes.dart';
import 'package:mc_common_app/extensions/int_extensions.dart';
import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/models/advertisment_models/ad_details_model.dart';
import 'package:mc_common_app/theme/colors.dart';
import 'package:mc_common_app/utils/navigator.dart';
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
class BuildAdsList extends StatelessWidget {
final int count;
final Function() onAdPressed;
final List<AdDetailsModel> adsList;
final ScrollPhysics? scrollPhysics;
const BuildAdsList({Key? key, required this.count, this.scrollPhysics, required this.onAdPressed}) : super(key: key);
const BuildAdsList({Key? key, required this.adsList, this.scrollPhysics}) : super(key: key);
@override
Widget build(BuildContext context) {
return ListView.builder(
itemCount: count,
itemCount: adsList.length,
shrinkWrap: true,
physics: scrollPhysics,
itemBuilder: (BuildContext context, int index) {
return Padding(
padding: const EdgeInsets.only(bottom: 15),
child: AdCard(isReserved: index == 3),
).onPress(onAdPressed);
child: AdCard(
adDetails: adsList[index],
),
).onPress(() {
navigateWithName(context, AppRoutes.adsDetailView, arguments: adsList[index]);
});
});
}
}
class AdCard extends StatelessWidget {
final bool isReserved;
final AdDetailsModel adDetails;
const AdCard({Key? key, required this.isReserved}) : super(key: key);
const AdCard({Key? key, required this.adDetails}) : super(key: key);
@override
Widget build(BuildContext context) {
@ -39,8 +45,15 @@ class AdCard extends StatelessWidget {
children: [
Row(
children: [
Image.asset(
MyAssets.bnCar,
Image.network(
adDetails.vehicle!.image!.first.imageUrl!,
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
return const SizedBox(
width: 80,
height: 80,
child: Icon(Icons.error_outline),
);
},
width: 80,
height: 80,
fit: BoxFit.cover,
@ -59,14 +72,14 @@ class AdCard extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
"Toyota Crolla".toText(fontSize: 16, isBold: true),
(adDetails.vehicle!.vehicleTitle ?? "").toText(fontSize: 16, isBold: true),
Row(
children: [
"Model:".toText(
color: MyColors.lightTextColor,
),
2.width,
"2019".toText(),
(adDetails.vehicle!.modelyear!.label ?? "").toText(),
],
),
Row(
@ -75,7 +88,7 @@ class AdCard extends StatelessWidget {
color: MyColors.lightTextColor,
),
2.width,
"73,000 km".toText(),
(adDetails.vehicle!.mileage!.mileageEnd ?? "").toText(),
],
),
],
@ -85,7 +98,7 @@ class AdCard extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.start,
children: [
"Riyadh".toText(
(adDetails.vehicle!.cityName ?? "").toText(
color: MyColors.lightTextColor,
),
"9 Hours Ago".toText(
@ -103,7 +116,7 @@ class AdCard extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
"30,000".toText(fontSize: 16, isBold: true),
(adDetails.vehicle!.demandAmount!.toInt().toString()).toText(fontSize: 16, isBold: true),
2.width,
"SAR:".toText(
color: MyColors.lightTextColor,
@ -119,7 +132,7 @@ class AdCard extends StatelessWidget {
),
],
),
if (isReserved)
if (false)
Container(
height: 100,
alignment: Alignment.center,

@ -1,3 +1,4 @@
import 'package:flutter/material.dart';
import 'package:mc_common_app/extensions/int_extensions.dart';
import 'package:mc_common_app/theme/colors.dart';
@ -11,17 +12,36 @@ import 'package:mc_common_app/widgets/common_widgets/app_bar.dart';
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
import 'package:provider/provider.dart';
class CreateAdView extends StatelessWidget {
class CreateAdView extends StatefulWidget {
const CreateAdView({Key? key}) : super(key: key);
@override
State<CreateAdView> createState() => _CreateAdViewState();
}
class _CreateAdViewState extends State<CreateAdView> {
late AdVM adVM;
@override
void initState() {
adVM = context.read<AdVM>();
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: const CustomAppBar(title: "Create Ad", isRemoveBackButton: false, isDrawerEnabled: false),
appBar: CustomAppBar(
title: "Create Ad",
isRemoveBackButton: false,
isDrawerEnabled: false,
onBackButtonTapped: () => adVM.onBackButtonPressed(context),
),
body: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
22.height,
const CreateAdProgressSteps(),
22.height,
Consumer(builder: (BuildContext context, AdVM adVm, Widget? child) {
@ -57,7 +77,7 @@ class BuildFooterButton extends StatelessWidget {
child: ShowFillButton(
title: "Next",
onPressed: () {
adVm.updateCurrentStep();
adVm.updateCurrentStep(context);
},
),
);
@ -70,6 +90,7 @@ class BuildFooterButton extends StatelessWidget {
maxHeight: 55,
title: "Cancel",
onPressed: () {
adVm.resetValues();
pop(context);
},
backgroundColor: MyColors.greyButtonColor,
@ -81,7 +102,7 @@ class BuildFooterButton extends StatelessWidget {
maxHeight: 55,
title: "Next",
onPressed: () {
adVm.updateCurrentStep();
adVm.updateCurrentStep(context);
},
backgroundColor: MyColors.darkPrimaryColor,
),
@ -97,6 +118,7 @@ class BuildFooterButton extends StatelessWidget {
maxHeight: 55,
title: "Cancel",
onPressed: () {
adVm.resetValues();
pop(context);
},
backgroundColor: MyColors.greyButtonColor,
@ -108,7 +130,7 @@ class BuildFooterButton extends StatelessWidget {
maxHeight: 55,
title: "Next",
onPressed: () {
adVm.updateCurrentStep();
adVm.updateCurrentStep(context);
},
backgroundColor: MyColors.darkPrimaryColor,
),
@ -124,6 +146,7 @@ class BuildFooterButton extends StatelessWidget {
maxHeight: 55,
title: "Cancel",
onPressed: () {
adVm.resetValues();
pop(context);
},
backgroundColor: MyColors.greyButtonColor,
@ -134,7 +157,9 @@ class BuildFooterButton extends StatelessWidget {
child: ShowFillButton(
maxHeight: 55,
title: "Submit Ad",
onPressed: () {},
onPressed: () {
adVm.updateCurrentStep(context);
},
backgroundColor: MyColors.darkPrimaryColor,
),
),

@ -0,0 +1,65 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:mc_common_app/classes/consts.dart';
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
class PickedImagesContainer extends StatelessWidget {
final List<File> pickedImages;
final Function(String filePath) onCrossPressed;
const PickedImagesContainer({
Key? key,
required this.pickedImages,
required this.onCrossPressed,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Wrap(
children: pickedImages.map((file) => BuildImageContainer(file: file, onCrossPressed: onCrossPressed,)).toList(),
);
}
}
class BuildImageContainer extends StatelessWidget {
final File file;
final Function(String filePath) onCrossPressed;
const BuildImageContainer({
Key? key,
required this.file,
required this.onCrossPressed,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Stack(
children: [
Container(
height: 80,
width: 80,
child: Stack(
children: [
Image.file(
file,
fit: BoxFit.fill,
height: 72,
width: 70,
).paddingAll(8),
Align(
alignment: Alignment.topRight,
child: MyAssets.closeWithOrangeBg.buildSvg(
fit: BoxFit.fill,
height: 25,
width: 25,
),
).onPress(() {
onCrossPressed(file.path);
})
],
)),
],
);
}
}

@ -72,6 +72,7 @@ class CustomAppBar extends StatelessWidget with PreferredSizeWidget {
final String profileImageUrl;
final bool isDrawerEnabled;
final VoidCallback? onTap;
final VoidCallback? onBackButtonTapped;
final double? leadingWidth;
const CustomAppBar({
@ -87,6 +88,7 @@ class CustomAppBar extends StatelessWidget with PreferredSizeWidget {
this.isTitleCenter,
this.titleColor,
this.onTap,
this.onBackButtonTapped,
this.leadingWidth,
}) : super(key: key);
@ -102,42 +104,44 @@ class CustomAppBar extends StatelessWidget with PreferredSizeWidget {
centerTitle: isTitleCenter ?? true,
leading: isDrawerEnabled
? InkWell(
onTap: onTap,
child: Row(
children: [
Image.asset(
profileImageUrl,
width: 34,
height: 34,
fit: BoxFit.fill,
).toCircle(borderRadius: 100),
10.width,
SvgPicture.asset(MyAssets.dashboardDrawerIcon),
],
).paddingOnly(left: 21),
)
onTap: onTap,
child: Row(
children: [
Image.asset(
profileImageUrl,
width: 34,
height: 34,
fit: BoxFit.fill,
).toCircle(borderRadius: 100),
10.width,
SvgPicture.asset(MyAssets.dashboardDrawerIcon),
],
).paddingOnly(left: 21),
)
: isRemoveBackButton
? null
: Row(
children: [
21.width,
IconButton(
icon: const Icon(
Icons.arrow_back_ios,
color: Colors.black,
size: 16,
),
onPressed: () => onTap ?? Navigator.of(context).pop(),
).toContainer(
paddingAll: 0,
borderRadius: 100,
borderColor: MyColors.lightGreyEFColor,
isEnabledBorder: true,
height: 40,
width: 40,
),
],
),
? null
: Row(
children: [
21.width,
IconButton(
icon: const Icon(
Icons.arrow_back_ios,
color: Colors.black,
size: 16,
),
onPressed: onBackButtonTapped ?? () {
Navigator.pop(context);
},
).toContainer(
paddingAll: 0,
borderRadius: 100,
borderColor: MyColors.lightGreyEFColor,
isEnabledBorder: true,
height: 40,
width: 40,
),
],
),
iconTheme: IconThemeData(
color: backIconColor ?? Colors.black, //change your color here
),

@ -1,9 +1,8 @@
import 'package:flutter/material.dart';
import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/theme/colors.dart';
import 'package:mc_common_app/utils/utils.dart';
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
class DropValue {
int id;
@ -16,12 +15,13 @@ class DropValue {
}
class DropdownField extends StatefulWidget {
String? hint;
List<DropValue>? list;
DropValue? dropdownValue;
Function(DropValue) onSelect;
final String? hint;
final String errorValue;
final List<DropValue>? list;
final DropValue? dropdownValue;
final Function(DropValue) onSelect;
DropdownField(this.onSelect, {Key? key, this.hint, this.list,this.dropdownValue}) : super(key: key);
const DropdownField(this.onSelect, {Key? key, this.hint, this.list, this.dropdownValue, this.errorValue = ""}) : super(key: key);
@override
State<DropdownField> createState() => _DropdownFieldState();
@ -42,43 +42,47 @@ class _DropdownFieldState extends State<DropdownField> {
@override
Widget build(BuildContext context) {
return Container(
decoration: Utils.containerColorRadiusBorderWidth(
MyColors.white,
0,
MyColors.darkPrimaryColor,
2,
),
margin: const EdgeInsets.all(0),
padding: const EdgeInsets.only(left: 8, right: 8),
child: DropdownButton<DropValue>(
value: dropdownValue,
icon: const Icon(Icons.keyboard_arrow_down_sharp),
elevation: 16,
iconSize: 16,
iconEnabledColor: borderColor,
iconDisabledColor: borderColor,
isExpanded: true,
style: const TextStyle(color: Colors.black, fontWeight: FontWeight.w600),
hint: (widget.hint ?? "").toText(color: borderColor, fontSize: 12),
underline: Container(
height: 0,
),
onChanged: (DropValue? newValue) {
setState(() {
dropdownValue = newValue!;
widget.onSelect(newValue);
});
},
items: (widget.list ?? defaultV).map<DropdownMenuItem<DropValue>>(
return Column(
children: [
Container(
decoration: Utils.containerColorRadiusBorderWidth(MyColors.white, 0, MyColors.darkPrimaryColor, 2),
margin: const EdgeInsets.all(0),
padding: const EdgeInsets.only(left: 8, right: 8),
child: DropdownButton<DropValue>(
value: dropdownValue,
icon: const Icon(Icons.keyboard_arrow_down_sharp),
elevation: 16,
iconSize: 16,
iconEnabledColor: borderColor,
iconDisabledColor: borderColor,
isExpanded: true,
style: const TextStyle(color: Colors.black, fontWeight: FontWeight.w600),
hint: (widget.hint ?? "").toText(color: borderColor, fontSize: 12),
underline: Container(height: 0),
onChanged: (DropValue? newValue) {
setState(() {
dropdownValue = newValue!;
widget.onSelect(newValue);
});
},
items: (widget.list ?? defaultV).map<DropdownMenuItem<DropValue>>(
(DropValue value) {
return DropdownMenuItem<DropValue>(
value: value,
child: value.value.toText(fontSize: 12),
);
},
).toList(),
),
return DropdownMenuItem<DropValue>(
value: value,
child: value.value.toText(fontSize: 12),
);
},
).toList(),
),
),
if (widget.errorValue != "")
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
widget.errorValue.toText(fontSize: 14, color: Colors.red),
],
).paddingOnly(right: 10),
],
);
}
}

@ -1,9 +1,9 @@
import 'package:flutter/material.dart';
import 'package:mc_common_app/extensions/int_extensions.dart';
import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/theme/colors.dart';
import 'package:mc_common_app/utils/utils.dart';
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
import 'package:sizer/sizer.dart';
class TxtField extends StatelessWidget {
@ -11,11 +11,13 @@ class TxtField extends StatelessWidget {
String? value;
String? hint;
String? lable;
Color postFixDataColor;
IconData? prefixData;
IconData? postfixData;
bool isNeedFilterButton;
bool isNeedClickAll;
bool isButtonEnable;
final String errorValue;
double? elevation;
VoidCallback? onTap;
String? buttonTitle;
@ -35,6 +37,8 @@ class TxtField extends StatelessWidget {
this.prefixData,
this.postfixData,
this.isNeedClickAll = false,
this.postFixDataColor = Colors.white,
this.errorValue = "",
this.isNeedFilterButton = false,
this.elevation,
this.onTap,
@ -53,113 +57,131 @@ class TxtField extends StatelessWidget {
Widget build(BuildContext context) {
controller.text = value ?? "";
controller.selection = TextSelection.fromPosition(TextPosition(offset: controller.text.length));
return InkWell(
onTap: isNeedClickAll == false
? null
: () {
onTap!();
},
customBorder: Utils.inkWellCorner(),
child: Row(
children: [
Expanded(
child: Container(
decoration: BoxDecoration(
color: isBackgroundEnabled ? MyColors.textFieldColor : Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(0)),
),
child: TextField(
keyboardType: keyboardType,
autofocus: false,
controller: controller,
enabled: isNeedClickAll == true ? false : true,
maxLines: maxLines,
onTap: () {},
obscureText: isPasswordEnabled ?? false,
onChanged: onChanged,
decoration: InputDecoration(
labelText: lable,
alignLabelWithHint: true,
fillColor: Colors.white,
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: MyColors.darkPrimaryColor, width: isNeedBorder ? 2.0 : 0),
borderRadius: BorderRadius.circular(0.0),
),
enabledBorder: OutlineInputBorder(
// borderSide: BorderSide(color: MyColors.textFieldColor, width: isNeedBorder ? 1.0 : 0),
borderSide: BorderSide(color: MyColors.darkPrimaryColor, width: isNeedBorder ? 2.0 : 0),
borderRadius: BorderRadius.circular(0.0),
return Column(
children: [
InkWell(
onTap: isNeedClickAll == false
? null
: () {
onTap!();
},
customBorder: Utils.inkWellCorner(),
child: Row(
children: [
Expanded(
child: Container(
decoration: BoxDecoration(
color: isBackgroundEnabled ? MyColors.textFieldColor : Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(0)),
),
disabledBorder: OutlineInputBorder(
// borderSide: BorderSide(color: MyColors.textFieldColor, width: isNeedBorder ? 1.0 : 0),
borderSide: BorderSide(color: MyColors.darkPrimaryColor, width: isNeedBorder ? 2.0 : 0),
borderRadius: BorderRadius.circular(0.0),
child: TextField(
keyboardType: keyboardType,
autofocus: false,
controller: controller,
enabled: isNeedClickAll == true ? false : true,
maxLines: maxLines,
onTap: () {},
obscureText: isPasswordEnabled ?? false,
onChanged: onChanged,
decoration: InputDecoration(
labelText: lable,
alignLabelWithHint: true,
fillColor: Colors.white,
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: MyColors.darkPrimaryColor, width: isNeedBorder ? 2.0 : 0),
borderRadius: BorderRadius.circular(0.0),
),
enabledBorder: OutlineInputBorder(
// borderSide: BorderSide(color: MyColors.textFieldColor, width: isNeedBorder ? 1.0 : 0),
borderSide: BorderSide(color: MyColors.darkPrimaryColor, width: isNeedBorder ? 2.0 : 0),
borderRadius: BorderRadius.circular(0.0),
),
disabledBorder: OutlineInputBorder(
// borderSide: BorderSide(color: MyColors.textFieldColor, width: isNeedBorder ? 1.0 : 0),
borderSide: BorderSide(color: MyColors.darkPrimaryColor, width: isNeedBorder ? 2.0 : 0),
borderRadius: BorderRadius.circular(0.0),
),
suffixIcon: postfixData != null
? Icon(
postfixData,
color: postFixDataColor,
)
: null,
prefixIcon: prefixData != null ? const Icon(Icons.search, color: borderColor) : null,
labelStyle: TextStyle(color: borderColor, fontSize: 13.sp),
hintStyle: TextStyle(color: borderColor, fontSize: 9.sp),
hintText: hint ?? "",
contentPadding: prefixData == null
? EdgeInsets.only(
left: 12,
right: 12,
top: maxLines != null ? 12 : 0,
bottom: maxLines != null ? 12 : 0,
)
: EdgeInsets.zero,
),
),
prefixIcon: prefixData != null ? const Icon(Icons.search, color: borderColor) : null,
labelStyle: TextStyle(color: borderColor, fontSize: 13.sp),
hintStyle: TextStyle(color: borderColor, fontSize: 9.sp),
hintText: hint ?? "",
contentPadding: prefixData == null
? EdgeInsets.only(
left: 12,
right: 12,
top: maxLines != null ? 12 : 0,
bottom: maxLines != null ? 12 : 0,
)
: EdgeInsets.zero,
),
),
),
),
if (isNeedFilterButton) 8.width,
if (isNeedFilterButton)
InkWell(
onTap: isNeedClickAll
? null
: () {
controller.clear();
},
child: SizedBox(
width: 55,
height: 55,
child: Card(
color: accentColor,
// margin: EdgeInsets.all(4),
// shape: cardRadius(0),
child: Icon(
postfixData ?? Icons.filter_alt,
color: Colors.white,
if (isNeedFilterButton) 8.width,
if (isNeedFilterButton)
InkWell(
onTap: isNeedClickAll
? null
: () {
controller.clear();
},
child: SizedBox(
width: 55,
height: 55,
child: Card(
color: accentColor,
// margin: EdgeInsets.all(4),
// shape: cardRadius(0),
child: Icon(
postfixData ?? Icons.filter_alt,
color: postFixDataColor,
),
),
),
),
),
),
if (isButtonEnable)
Material(
child: InkWell(
onTap: onTap,
customBorder: Utils.inkWellCorner(),
child: SizedBox(
height: 55,
child: Card(
color: accentColor,
// margin: EdgeInsets.all(4),
// shape: cardRadius(0),
child: Center(
child: Padding(
padding: const EdgeInsets.only(left: 12, right: 12),
child: (buttonTitle ?? "Search").toText(
color: Colors.white,
fontSize: 16,
letterSpacing: -0.64,
if (isButtonEnable)
Material(
child: InkWell(
onTap: onTap,
customBorder: Utils.inkWellCorner(),
child: SizedBox(
height: 55,
child: Card(
color: accentColor,
// margin: EdgeInsets.all(4),
// shape: cardRadius(0),
child: Center(
child: Padding(
padding: const EdgeInsets.only(left: 12, right: 12),
child: (buttonTitle ?? "Search").toText(
color: Colors.white,
fontSize: 16,
letterSpacing: -0.64,
),
),
),
),
),
),
),
),
),
],
),
],
),
),
if (errorValue != "")
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
errorValue.toText(fontSize: 14, color: Colors.red),
],
).paddingOnly(right: 10),
],
);
}
}

Loading…
Cancel
Save