diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 497c578..aeac85a 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -720,5 +720,7 @@ "noAvailableItems": "لا توجد عناصر متاحة.", "serviceDeliveryType": "نوع تقديم الخدمة", "noImagesToShow": "لا توجد صور للعرض", - "updateGroupServices": "تحديث خدمات المجموعة" + "updateGroupServices": "تحديث خدمات المجموعة", + "addCommentsHere": "أضف التعليقات هنا", + "waitForBranchVerification": "يرجى الانتظار حتى يتم التحقق من الفرع." } \ No newline at end of file diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index c29fde3..bccf819 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -718,5 +718,8 @@ "noAvailableItems": "There are no available items.", "serviceDeliveryType": "Service Delivery Type", "noImagesToShow": "No Images to Show", - "updateGroupServices": "Update Group Services" + "updateGroupServices": "Update Group Services", + "addCommentsHere": "Add comments here", + "waitForBranchVerification": "Please wait for the branch verification." + } \ No newline at end of file diff --git a/lib/classes/consts.dart b/lib/classes/consts.dart index 52d3c6d..33757fd 100644 --- a/lib/classes/consts.dart +++ b/lib/classes/consts.dart @@ -14,7 +14,7 @@ class ApiConsts { static String basicComplete = "${baseUrlServices}api/Register/BasicComplete"; static String refreshToken = "${baseUrlServices}api/Account/RefreshToken"; - static String signalRUrl = "$baseUrl/McHub"; + static String signalRUrl = "${baseUrl}McHub"; //User static String Login_V1 = "${baseUrlServices}api/Account/Login_V1"; diff --git a/lib/generated/codegen_loader.g.dart b/lib/generated/codegen_loader.g.dart index 066bb54..fa1d932 100644 --- a/lib/generated/codegen_loader.g.dart +++ b/lib/generated/codegen_loader.g.dart @@ -736,7 +736,9 @@ class CodegenLoader extends AssetLoader{ "noAvailableItems": "لا توجد عناصر متاحة.", "serviceDeliveryType": "نوع تقديم الخدمة", "noImagesToShow": "لا توجد صور للعرض", - "updateGroupServices": "تحديث خدمات المجموعة" + "updateGroupServices": "تحديث خدمات المجموعة", + "addCommentsHere": "أضف التعليقات هنا", + "waitForBranchVerification": "يرجى الانتظار حتى يتم التحقق من الفرع." }; static const Map en_US = { "firstTimeLogIn": "First Time Log In", @@ -1458,7 +1460,9 @@ static const Map en_US = { "noAvailableItems": "There are no available items.", "serviceDeliveryType": "Service Delivery Type", "noImagesToShow": "No Images to Show", - "updateGroupServices": "Update Group Services" + "updateGroupServices": "Update Group Services", + "addCommentsHere": "Add comments here", + "waitForBranchVerification": "Please wait for the branch verification." }; static const Map> mapLocales = {"ar_SA": ar_SA, "en_US": en_US}; } diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index de86937..3cc4d69 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -1,6 +1,6 @@ // DO NOT EDIT. This is code generated via package:easy_localization/generate.dart -abstract class LocaleKeys { +abstract class LocaleKeys { static const firstTimeLogIn = 'firstTimeLogIn'; static const signUp = 'signUp'; static const changeMobile = 'changeMobile'; @@ -47,7 +47,7 @@ abstract class LocaleKeys { static const emailChangedSuccessfully = 'emailChangedSuccessfully'; static const passwordIsUpdated = 'passwordIsUpdated'; static const passwordShouldContains = 'passwordShouldContains'; - static const successfullyRegistered = ' successfullyRegistered'; + static const successfullyRegistered = ' successfullyRegistered'; static const pleaseEnterSamePassword = 'pleaseEnterSamePassword'; static const firstNameMandatory = 'firstNameMandatory'; static const surnameNameMandatory = 'surnameNameMandatory'; @@ -700,4 +700,7 @@ abstract class LocaleKeys { static const serviceDeliveryType = 'serviceDeliveryType'; static const noImagesToShow = 'noImagesToShow'; static const updateGroupServices = 'updateGroupServices'; + static const addCommentsHere = 'addCommentsHere'; + static const waitForBranchVerification = 'waitForBranchVerification'; + } diff --git a/lib/models/advertisment_models/ad_details_model.dart b/lib/models/advertisment_models/ad_details_model.dart index 3a4af29..fb9ba56 100644 --- a/lib/models/advertisment_models/ad_details_model.dart +++ b/lib/models/advertisment_models/ad_details_model.dart @@ -411,6 +411,7 @@ class DamageReport { isActive = json['isActive']; vehicleDamagePartID = json['vehicleDamagePartID']; partName = json['partName']; + comment = json['comment']; } Map toJson() { diff --git a/lib/models/advertisment_models/ads_duration_model.dart b/lib/models/advertisment_models/ads_duration_model.dart index aaf3b5c..4602dcf 100644 --- a/lib/models/advertisment_models/ads_duration_model.dart +++ b/lib/models/advertisment_models/ads_duration_model.dart @@ -6,9 +6,20 @@ class AdsDurationModel { int? countryID; bool? isActive; String? countryName; + String? currency; bool? isSelected; - AdsDurationModel({this.id, this.name, this.days, this.price, this.countryID, this.isActive, this.countryName, this.isSelected}); + AdsDurationModel({ + this.id, + this.name, + this.days, + this.price, + this.countryID, + this.isActive, + this.countryName, + this.currency, + this.isSelected, + }); AdsDurationModel.fromJson(Map json) { id = json['id']; @@ -18,6 +29,7 @@ class AdsDurationModel { countryID = json['countryID']; isActive = json['isActive']; countryName = json['countryName']; + currency = json['currency']; isSelected = false; } @@ -30,6 +42,7 @@ class AdsDurationModel { data['countryID'] = countryID; data['isActive'] = isActive; data['countryName'] = countryName; + data['currency'] = currency; return data; } } diff --git a/lib/models/advertisment_models/special_service_model.dart b/lib/models/advertisment_models/special_service_model.dart index 73204b5..ab9a882 100644 --- a/lib/models/advertisment_models/special_service_model.dart +++ b/lib/models/advertisment_models/special_service_model.dart @@ -81,7 +81,7 @@ class Office { String? officeAreaName; String? officeAreaNameN; int? cityID; - String? city; + CitySSModel? city; int? specialServiceID; Office({this.id, this.officeAreaName, this.officeAreaNameN, this.cityID, this.city, this.specialServiceID}); @@ -91,11 +91,41 @@ class Office { officeAreaName = json['officeAreaName']; officeAreaNameN = json['officeAreaNameN']; cityID = json['cityID']; - city = json['city']; + if (json['city'] != null) { + city = json['city'] != null ? CitySSModel.fromJson(json['city']) : null; + } specialServiceID = json['specialServiceID']; } } +class CitySSModel { + int? id; + String? cityName; + String? cityNameN; + int? countryID; + String? country; + bool? isActive; + int? createdBy; + String? createdOn; + String? modifiedBy; + String? modifiedOn; + + CitySSModel({this.id, this.cityName, this.cityNameN, this.countryID, this.country, this.isActive, this.createdBy, this.createdOn, this.modifiedBy, this.modifiedOn}); + + CitySSModel.fromJson(Map json) { + id = json['id']; + cityName = json['cityName']; + cityNameN = json['cityNameN']; + countryID = json['countryID']; + country = json['country']; + isActive = json['isActive']; + createdBy = json['createdBy']; + createdOn = json['createdOn']; + modifiedBy = json['modifiedBy']; + modifiedOn = json['modifiedOn']; + } +} + class SpecialServiceModelForAds { int? adsID; int? specialServiceID; @@ -126,7 +156,6 @@ class SpecialServiceModelForAds { appointmentStatusEnum = (json['appointmentStatus'] as int).toAppointmentStatusEnum(); appointmentDate = json['appointmentDate']; appointmentStatusId = json['appointmentStatus']; - } @override diff --git a/lib/models/provider_branches_models/profile/categroy.dart b/lib/models/provider_branches_models/profile/categroy.dart index cca86fd..1d0a0c1 100644 --- a/lib/models/provider_branches_models/profile/categroy.dart +++ b/lib/models/provider_branches_models/profile/categroy.dart @@ -26,17 +26,17 @@ class Category { String? message; factory Category.fromJson(Map json) => Category( - totalItemsCount: json["totalItemsCount"] == null ? null : json["totalItemsCount"], + totalItemsCount: json["totalItemsCount"], data: json["data"] == null ? null : List.from(json["data"].map((x) => CategoryData.fromJson(x))), - messageStatus: json["messageStatus"] == null ? null : json["messageStatus"], - message: json["message"] == null ? null : json["message"], + messageStatus: json["messageStatus"], + message: json["message"], ); Map toJson() => { - "totalItemsCount": totalItemsCount == null ? null : totalItemsCount, + "totalItemsCount": totalItemsCount, "data": data == null ? null : List.from(data!.map((x) => x.toJson())), - "messageStatus": messageStatus == null ? null : messageStatus, - "message": message == null ? null : message, + "messageStatus": messageStatus, + "message": message, }; } @@ -63,18 +63,18 @@ class CategoryData extends Equatable { List? services; factory CategoryData.fromJson(Map json) => CategoryData( - id: json["id"] == null ? null : json["id"], - categoryName: json["categoryName"] == null ? null : json["categoryName"], - categoryNameN: json["categoryNameN"] == null ? null : json["categoryNameN"], + id: json["id"], + categoryName: json["categoryName"], + categoryNameN: json["categoryNameN"], serviceCategoryIconUrl: json["serviceCategoryIconUrl"], serviceCategoryImageUrl: json["serviceCategoryImageUrl"], services: [], ); Map toJson() => { - "id": id == null ? null : id, - "categoryName": categoryName == null ? null : categoryName, - "categoryNameN": categoryNameN == null ? null : categoryNameN, + "id": id, + "categoryName": categoryName, + "categoryNameN": categoryNameN, "serviceCategoryIconUrl": serviceCategoryIconUrl, "serviceCategoryImageUrl": serviceCategoryImageUrl, }; diff --git a/lib/repositories/ads_repo.dart b/lib/repositories/ads_repo.dart index 1bdc877..9d97121 100644 --- a/lib/repositories/ads_repo.dart +++ b/lib/repositories/ads_repo.dart @@ -1,3 +1,5 @@ +import 'dart:developer'; + import 'package:mc_common_app/api/api_client.dart'; import 'package:mc_common_app/classes/app_state.dart'; import 'package:mc_common_app/classes/consts.dart'; @@ -76,6 +78,8 @@ class AdsRepoImp implements AdsRepo { @override Future createOrUpdateAd({required AdsCreationPayloadModel adsCreationPayloadModel, required bool isCreateNew}) async { List vehiclePostingImages = []; + + log("adsCreationPayloadModel.ads!.adsDurationID,: ${adsCreationPayloadModel.ads!.adsDurationID}"); adsCreationPayloadModel.vehiclePosting!.vehiclePostingImages?.forEach((element) { var imageMap = { "id": element.id ?? 0, @@ -90,6 +94,7 @@ class AdsRepoImp implements AdsRepo { List vehiclePostingDamageParts = []; adsCreationPayloadModel.vehiclePosting!.vehiclePostingDamageParts?.forEach((element) { + log("comment: ${element.comment}"); var imageMap = { "id": element.id ?? 0, "comment": element.comment, diff --git a/lib/services/common_auth_service.dart b/lib/services/common_auth_service.dart index 1f52e02..17baf4a 100644 --- a/lib/services/common_auth_service.dart +++ b/lib/services/common_auth_service.dart @@ -2,7 +2,6 @@ import 'dart:io'; import 'package:device_info_plus/device_info_plus.dart'; import 'package:flutter/services.dart'; -import 'package:huawei_fido/huawei_fido.dart'; import 'package:local_auth/local_auth.dart'; import 'package:local_auth_android/local_auth_android.dart'; import 'package:local_auth_darwin/types/auth_messages_ios.dart'; diff --git a/lib/view_models/ad_view_model.dart b/lib/view_models/ad_view_model.dart index 81a9558..cc28983 100644 --- a/lib/view_models/ad_view_model.dart +++ b/lib/view_models/ad_view_model.dart @@ -723,6 +723,7 @@ class AdVM extends BaseVM { SelectionModel vehicleAdDurationId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); void updateVehicleAdDurationId(SelectionModel id) { + log("vehicleAdDurationId is updated: ${vehicleAdDurationId.selectedId}"); vehicleAdDurationId = id; notifyListeners(); } @@ -1026,7 +1027,7 @@ class AdVM extends BaseVM { bool isAdDurationValidated() { bool isValidated = true; - if (vehicleAdDurationId.selectedId == -1) { + if (AppState().userType != UserType.providerDealer && vehicleAdDurationId.selectedId == -1) { vehicleAdDurationId.errorValue = LocaleKeys.vehicle_vehiclePart.tr(); isValidated = false; } else { @@ -1252,6 +1253,11 @@ class AdVM extends BaseVM { notifyListeners(); } + void updateDamagePartDescription(int index, String value) { + vehicleDamageCards[index].damagePartDescription = value; + notifyListeners(); + } + void removeDamageImageFromCard(int imageIndex, String filePath, int cardIndex) { VehicleDamageCard card = vehicleDamageCards.elementAt(cardIndex); if (card.partImages == null) return; @@ -1420,14 +1426,14 @@ class AdVM extends BaseVM { Utils.hideLoading(context); if (genericRespModel.messageStatus != 1) { - Utils.showToast(LocaleKeys.error.tr() + ": ${genericRespModel.message}"); + Utils.showToast("${LocaleKeys.error.tr()}: ${genericRespModel.message}"); } else { resetSpecialServiceBottomSheet(); navigateWithName(context, AppRoutes.paymentMethodsView, arguments: PaymentTypes.ads); } } catch (e) { Utils.hideLoading(context); - Utils.showToast(LocaleKeys.error.tr() + ": ${e.toString()}"); + Utils.showToast("${LocaleKeys.error.tr()}: ${e.toString()}"); } } @@ -1440,7 +1446,7 @@ class AdVM extends BaseVM { } Ads ads = Ads( id: isAdEditEnabled ? previousAdDetails!.id : null, - adsDurationID: vehicleAdDurationId.selectedId, + adsDurationID: vehicleAdDurationId.selectedId == -1 ? 0 : vehicleAdDurationId.selectedId, startDate: selectionDurationStartDate, countryId: vehicleCountryId.selectedId, specialServiceIDs: adsSelectedServices, @@ -1459,6 +1465,7 @@ class AdVM extends BaseVM { VehiclePostingDamageParts stringImage = await convertFileToVehiclePostingDamageParts( imageModel: image, damagePartId: card.partSelectedId!.selectedId, + commentParam: card.damagePartDescription ?? "", ); vehicleDamageImages.add(stringImage); } @@ -1523,7 +1530,7 @@ class AdVM extends BaseVM { return vehiclePostingImages; } - Future convertFileToVehiclePostingDamageParts({required ImageModel imageModel, required int damagePartId}) async { + Future convertFileToVehiclePostingDamageParts({required ImageModel imageModel, required int damagePartId, required String commentParam}) async { VehiclePostingDamageParts vehiclePostingDamageParts; if (imageModel.isFromNetwork ?? false) { @@ -1531,17 +1538,14 @@ class AdVM extends BaseVM { id: imageModel.id, vehicleDamagePartID: damagePartId, imageUrl: imageModel.filePath, + comment: commentParam, vehiclePostingID: isAdEditEnabled ? previousAdDetails!.vehiclePostingID : null, ); } else { File file = File(imageModel.filePath!); List imageBytes = await file.readAsBytes(); String image = base64Encode(imageBytes); - vehiclePostingDamageParts = VehiclePostingDamageParts( - vehicleImageBase64: image, - vehicleDamagePartID: damagePartId, - imageUrl: file.path, - ); + vehiclePostingDamageParts = VehiclePostingDamageParts(vehicleImageBase64: image, vehicleDamagePartID: damagePartId, imageUrl: file.path, comment: commentParam); } return vehiclePostingDamageParts; @@ -1775,7 +1779,6 @@ class AdVM extends BaseVM { Utils.showToast(e.toString()); return false; } - return false; } void autoFillSelectedVehicleType() async { @@ -1806,7 +1809,7 @@ class AdVM extends BaseVM { SelectionModel( selectedId: vehicleAdsDurations[index].id ?? 0, selectedOption: "${vehicleAdsDurations[index].days} Days", - itemPrice: vehicleAdsDurations[index].price!.toInt().toString(), + itemPrice: vehicleAdsDurations[index].price!.toString(), ), ); } @@ -1876,6 +1879,7 @@ class AdVM extends BaseVM { selectedId: element.vehicleDamagePartID!, selectedOption: element.partName ?? "", ), + damagePartDescription: "", partImages: [imageModel], ); addNewDamagePartCard(damageCard: vehicleDamageCard); @@ -1964,17 +1968,19 @@ class AdVM extends BaseVM { class VehicleDamageCard { List? partImages; SelectionModel? partSelectedId; + String? damagePartDescription; String partImageErrorValue; VehicleDamageCard({ this.partImages, this.partSelectedId, + this.damagePartDescription, this.partImageErrorValue = "", }); @override String toString() { - return 'VehicleDamageCard{partImages: $partImages, partSelectedId: $partSelectedId, partImageErrorValue: $partImageErrorValue}'; + return 'VehicleDamageCard{partImages: $partImages, partSelectedId: $partSelectedId,damagePartDescription: $damagePartDescription, partImageErrorValue: $partImageErrorValue}'; } } diff --git a/lib/view_models/service_view_model.dart b/lib/view_models/service_view_model.dart index 82a4973..43c3eb0 100644 --- a/lib/view_models/service_view_model.dart +++ b/lib/view_models/service_view_model.dart @@ -67,6 +67,8 @@ class ServiceVM extends BaseVM { List homePageBranches = []; List categories = []; + bool isNeedRefreshServicesList = false; + void updateSelectionOpenTime(String date) { openTime = date; notifyListeners(); diff --git a/lib/views/advertisement/ad_creation_steps/ad_duration_container.dart b/lib/views/advertisement/ad_creation_steps/ad_duration_container.dart index b8707e6..20a17fe 100644 --- a/lib/views/advertisement/ad_creation_steps/ad_duration_container.dart +++ b/lib/views/advertisement/ad_creation_steps/ad_duration_container.dart @@ -1,11 +1,13 @@ import 'package:country_code_picker/country_code_picker.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:mc_common_app/classes/app_state.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/generated/locale_keys.g.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/bottom_sheets/ad_special_service_sheet.dart'; @@ -60,19 +62,22 @@ class AdDuration extends StatelessWidget { children: [ LocaleKeys.adDuration.tr().toText(fontSize: 18, isBold: true), 8.height, - TxtField( - isBackgroundEnabled: true, - isButtonEnable: false, - isNeedBorder: false, - hint: LocaleKeys.adDuration.tr(), - value: adVM.vehicleAdDurationId.selectedOption, - isNeedClickAll: true, - postFixDataColor: MyColors.darkTextColor, - onTap: () async { - final formattedDate = await Utils.pickDateFromDatePicker(context); - adVM.updateSelectionDurationStartDate(formattedDate); - }, - ), + + if (AppState().userType != UserType.providerDealer) ...[ + TxtField( + isBackgroundEnabled: true, + isButtonEnable: false, + isNeedBorder: false, + hint: LocaleKeys.adDuration.tr(), + value: adVM.vehicleAdDurationId.selectedOption, + isNeedClickAll: true, + postFixDataColor: MyColors.darkTextColor, + onTap: () async { + final formattedDate = await Utils.pickDateFromDatePicker(context); + adVM.updateSelectionDurationStartDate(formattedDate); + }, + ), + ], // Builder(builder: (context) { // List vehicleAdsDurationsDrop = []; // for (var element in adVM.vehicleAdsDurations) { diff --git a/lib/views/advertisement/ad_creation_steps/ad_review_containers.dart b/lib/views/advertisement/ad_creation_steps/ad_review_containers.dart index 01a5af0..af32a90 100644 --- a/lib/views/advertisement/ad_creation_steps/ad_review_containers.dart +++ b/lib/views/advertisement/ad_creation_steps/ad_review_containers.dart @@ -1,8 +1,10 @@ import 'package:flutter/material.dart'; +import 'package:mc_common_app/classes/app_state.dart'; import 'package:mc_common_app/extensions/int_extensions.dart'; import 'package:mc_common_app/extensions/string_extensions.dart'; import 'package:mc_common_app/generated/locale_keys.g.dart'; import 'package:mc_common_app/theme/colors.dart'; +import 'package:mc_common_app/utils/enums.dart'; import 'package:mc_common_app/view_models/ad_view_model.dart'; import 'package:mc_common_app/views/advertisement/components/picked_images_container_widget.dart'; import 'package:mc_common_app/widgets/extensions/extensions_widget.dart'; @@ -10,7 +12,7 @@ import 'package:provider/provider.dart'; import 'package:easy_localization/easy_localization.dart'; class ReviewAd extends StatelessWidget { - const ReviewAd({Key? key}) : super(key: key); + const ReviewAd({super.key}); @override Widget build(BuildContext context) { @@ -30,7 +32,7 @@ class SingleDetailWidget extends StatelessWidget { final String text; final String type; - const SingleDetailWidget({Key? key, required this.text, required this.type}) : super(key: key); + const SingleDetailWidget({super.key, required this.text, required this.type}); @override Widget build(BuildContext context) { @@ -45,7 +47,7 @@ class SingleDetailWidget extends StatelessWidget { } class VehicleDetailsReview extends StatelessWidget { - const VehicleDetailsReview({Key? key}) : super(key: key); + const VehicleDetailsReview({super.key}); @override Widget build(BuildContext context) { @@ -127,7 +129,7 @@ class VehicleDetailsReview extends StatelessWidget { } class DamagePartsReview extends StatelessWidget { - const DamagePartsReview({Key? key}) : super(key: key); + const DamagePartsReview({super.key}); Widget buildDamagePartList(AdVM adVM) { List list = List.generate( @@ -138,11 +140,26 @@ class DamagePartsReview extends StatelessWidget { 8.height, Row( children: [ - SingleDetailWidget(type: LocaleKeys.vehiclePart.tr(), text: adVM.vehicleDamageCards[index].partSelectedId!.selectedOption), + ("${LocaleKeys.vehiclePart.tr()}:").toText(fontSize: 12, color: MyColors.lightTextColor), + 4.width, + (adVM.vehicleDamageCards[index].partSelectedId!.selectedOption ?? "").toText(fontSize: 14, color: MyColors.darkTextColor), ], ), + if (adVM.vehicleDamageCards[index].damagePartDescription != null && adVM.vehicleDamageCards[index].damagePartDescription!.isNotEmpty) ...[ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ("${LocaleKeys.comment.tr()}:").toText(fontSize: 12, color: MyColors.lightTextColor), + 4.width, + Flexible( + child: (adVM.vehicleDamageCards[index].damagePartDescription ?? "").toText(fontSize: 12, color: MyColors.darkTextColor), + ), + ], + ), + 5.height, + ], if (adVM.vehicleDamageCards[index].partImages != null && adVM.vehicleDamageCards[index].partImages!.isNotEmpty) ...[ - ("${LocaleKeys.damagePartPictures.tr()}:").toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true), + ("${LocaleKeys.damagePartPictures.tr()}:").toText(fontSize: 12, color: MyColors.lightTextColor), PickedFilesContainer( pickedFiles: adVM.vehicleDamageCards[index].partImages!, onCrossPressedPrimary: adVM.removeImageFromList, @@ -176,7 +193,7 @@ class DamagePartsReview extends StatelessWidget { } class AdDurationReview extends StatelessWidget { - const AdDurationReview({Key? key}) : super(key: key); + const AdDurationReview({super.key}); @override Widget build(BuildContext context) { @@ -189,10 +206,12 @@ class AdDurationReview extends StatelessWidget { 8.height, Row( children: [ - Expanded( - flex: 7, - child: SingleDetailWidget(type: LocaleKeys.duration.tr(), text: adVM.vehicleAdDurationId.selectedOption), - ), + if (AppState().userType != UserType.providerDealer) ...[ + Expanded( + flex: 7, + child: SingleDetailWidget(type: LocaleKeys.duration.tr(), text: adVM.vehicleAdDurationId.selectedOption), + ), + ], Expanded( flex: 5, child: SingleDetailWidget(type: LocaleKeys.startDate.tr(), text: adVM.selectionDurationStartDate), diff --git a/lib/views/advertisement/ad_creation_steps/damage_parts_container.dart b/lib/views/advertisement/ad_creation_steps/damage_parts_container.dart index be1b994..4e24abe 100644 --- a/lib/views/advertisement/ad_creation_steps/damage_parts_container.dart +++ b/lib/views/advertisement/ad_creation_steps/damage_parts_container.dart @@ -9,11 +9,12 @@ import 'package:mc_common_app/views/advertisement/bottom_sheets/ad_damage_parts_ import 'package:mc_common_app/views/advertisement/components/picked_images_container_widget.dart'; import 'package:mc_common_app/widgets/common_widgets/custom_add_button_widget.dart'; import 'package:mc_common_app/widgets/extensions/extensions_widget.dart'; +import 'package:mc_common_app/widgets/txt_field.dart'; import 'package:provider/provider.dart'; import 'package:easy_localization/easy_localization.dart'; class DamageParts extends StatelessWidget { - const DamageParts({Key? key}) : super(key: key); + const DamageParts({super.key}); bool getEnabledStatus(bool? isSelected) { if (isSelected == null) { @@ -79,7 +80,14 @@ class DamageParts extends StatelessWidget { ).onPress(() => adVM.removeDamagePartCard(index)) ], ), - 10.height, + 3.height, + TxtField( + isNeedBorder: false, + value: vehicleDamageCard.damagePartDescription, + hint: LocaleKeys.addCommentsHere.tr(), + onChanged: (v) => adVM.updateDamagePartDescription(index, v), + ), + 3.height, // Builder(builder: (context) { // List vehicleDamagePartsDrop = []; diff --git a/lib/views/advertisement/ad_creation_steps/vehicle_details_container.dart b/lib/views/advertisement/ad_creation_steps/vehicle_details_container.dart index 286e221..bfbf338 100644 --- a/lib/views/advertisement/ad_creation_steps/vehicle_details_container.dart +++ b/lib/views/advertisement/ad_creation_steps/vehicle_details_container.dart @@ -223,6 +223,7 @@ class VehicleDetails extends StatelessWidget { value: adVM.vehicleDemandAmount, errorValue: adVM.demandAmountError, keyboardType: TextInputType.number, + numbersOnly: true, hint: LocaleKeys.demandAmount.tr(), onChanged: (v) => adVM.updateVehicleDemandAmount(v), ), diff --git a/lib/views/advertisement/ads_detail_view/ads_detail_view.dart b/lib/views/advertisement/ads_detail_view/ads_detail_view.dart index 0634d1a..99afa00 100644 --- a/lib/views/advertisement/ads_detail_view/ads_detail_view.dart +++ b/lib/views/advertisement/ads_detail_view/ads_detail_view.dart @@ -147,7 +147,7 @@ class _AdsDetailViewState extends State { crossAxisAlignment: CrossAxisAlignment.end, children: [ widget.adDetails.vehicle!.demandAmount!.toInt().toString().toText(fontSize: 30, height: 1.2, isBold: true), - LocaleKeys.sar.tr().toText(fontSize: 15, color: MyColors.lightTextColor).paddingOnly(bottom: 5), + (widget.adDetails.vehicle!.currency ?? LocaleKeys.sar.tr()).toText(fontSize: 15, color: MyColors.lightTextColor).paddingOnly(bottom: 5), ], ), if (widget.adDetails.adPostStatus == AdPostStatus.expired) ...[ @@ -446,7 +446,7 @@ class _AdsDetailViewState extends State { crossAxisAlignment: CrossAxisAlignment.end, children: [ widget.adDetails.vehicle!.demandAmount!.toInt().toString().toText(fontSize: 30, isBold: true), - LocaleKeys.sar.tr().toText(fontSize: 15, isBold: true, color: MyColors.lightTextColor).paddingOnly(bottom: 5), + (widget.adDetails.vehicle!.currency ?? LocaleKeys.sar.tr()).toText(fontSize: 15, isBold: true, color: MyColors.lightTextColor).paddingOnly(bottom: 5), ], ), 14.height, diff --git a/lib/views/advertisement/bottom_sheets/ad_damage_parts_selection_sheet.dart b/lib/views/advertisement/bottom_sheets/ad_damage_parts_selection_sheet.dart index 6703a47..f1ee3b1 100644 --- a/lib/views/advertisement/bottom_sheets/ad_damage_parts_selection_sheet.dart +++ b/lib/views/advertisement/bottom_sheets/ad_damage_parts_selection_sheet.dart @@ -125,6 +125,7 @@ class _AdDamagePartsSelectionSheetState extends State { selectedId: element.vehicleDamagePartID!, selectedOption: element.partName ?? "", ), + damagePartDescription: element.comment ?? "", partImages: [imageModel], ); vehicleDamageCards.add(vehicleDamageCard); @@ -62,6 +65,9 @@ class _AdDamagePartPicturesSheetState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ vehicleDamageCard.partSelectedId!.selectedOption.toText(fontSize: 18, color: MyColors.darkTextColor), + if (vehicleDamageCard.damagePartDescription!.isNotEmpty) ...[ + vehicleDamageCard.damagePartDescription!.toText(fontSize: 14, color: MyColors.lightTextColor), + ], PickedFilesContainer( pickedFiles: vehicleDamageCard.partImages ?? [], isReview: true, @@ -78,7 +84,6 @@ class _AdDamagePartPicturesSheetState extends State { id: image.id, isFromNetwork: true, imageUrl: image.filePath, - )); } navigateWithName(context, AppRoutes.mediaViewerScreen, arguments: images); diff --git a/lib/views/advertisement/create_ad_view.dart b/lib/views/advertisement/create_ad_view.dart index 26e7da6..ef23f5e 100644 --- a/lib/views/advertisement/create_ad_view.dart +++ b/lib/views/advertisement/create_ad_view.dart @@ -17,7 +17,7 @@ import 'package:provider/provider.dart'; import 'package:easy_localization/easy_localization.dart'; class CreateAdView extends StatefulWidget { - const CreateAdView({Key? key}) : super(key: key); + const CreateAdView({super.key}); @override State createState() => _CreateAdViewState(); @@ -68,7 +68,7 @@ class _CreateAdViewState extends State { } class BuildFooterButton extends StatelessWidget { - const BuildFooterButton({Key? key}) : super(key: key); + const BuildFooterButton({super.key}); @override Widget build(BuildContext context) { @@ -187,13 +187,13 @@ class BuildAdStepContainer extends StatelessWidget { final AdCreationSteps adCreationStepsEnum; const BuildAdStepContainer({ - Key? key, + super.key, required this.onVehicleDetails, required this.onDamageParts, required this.onAdDuration, required this.onReviewAd, required this.adCreationStepsEnum, - }) : super(key: key); + }); @override Widget build(BuildContext context) { diff --git a/lib/views/advertisement/select_ad_type_view.dart b/lib/views/advertisement/select_ad_type_view.dart index ee4d0a2..9649132 100644 --- a/lib/views/advertisement/select_ad_type_view.dart +++ b/lib/views/advertisement/select_ad_type_view.dart @@ -14,6 +14,7 @@ import 'package:mc_common_app/theme/colors.dart'; import 'package:mc_common_app/utils/enums.dart'; import 'package:mc_common_app/utils/navigator.dart'; import 'package:mc_common_app/view_models/ad_view_model.dart'; +import 'package:mc_common_app/views/advertisement/ads_buyer_chats_view.dart'; import 'package:mc_common_app/views/advertisement/bottom_sheets/ad_duration_selection_sheet.dart'; import 'package:mc_common_app/widgets/bottom_sheet.dart'; import 'package:mc_common_app/widgets/common_widgets/app_bar.dart'; @@ -24,7 +25,7 @@ import 'package:easy_localization/easy_localization.dart'; class SelectAdTypeView extends StatelessWidget { final List arguments; // [0] isProviderOrCustomer [1] isFromExtendAd - const SelectAdTypeView({Key? key, required this.arguments}) : super(key: key); + const SelectAdTypeView({super.key, required this.arguments}); Widget getVehicleAdTypeIcon(VehicleType vehicleTypeEnum) { switch (vehicleTypeEnum) { @@ -74,12 +75,24 @@ class SelectAdTypeView extends StatelessWidget { itemBuilder: (BuildContext context, int index) { VehicleTypeModel vehicleTypeModel = adVM.vehicleTypes[index]; return InkWell( - onTap: () { + onTap: () async { adVM.updateSelectionVehicleTypeId(SelectionModel(selectedId: vehicleTypeModel.id!, selectedOption: vehicleTypeModel.vehicleTypeName ?? "", errorValue: "")); if (adVM.isAdEditEnabled) { adVM.autoFillSelectedVehicleAdsDetails(); } - showMyBottomSheet(context, child: AdDurationSelectionSheet(isUpdateAdSelected: adVM.isAdEditEnabled, isFromExtendAd: isFromExtendAd, adsID: adsId)); + if (AppState().currentAppType == AppType.provider && AppState().userType == UserType.providerDealer) { + if (isFromExtendAd && !adVM.isAdEditEnabled) { + bool status = await adVM.createAdExtensionOrder(context, adId: adsId, adsDurationId: adVM.vehicleAdDurationId.selectedId); + log("hereStatus: $status"); + if (status) { + navigateWithName(context, AppRoutes.paymentMethodsView, arguments: PaymentTypes.extendAds); + } + } else { + navigateReplaceWithName(context, AppRoutes.createAdView); + } + } else { + showMyBottomSheet(context, child: AdDurationSelectionSheet(isUpdateAdSelected: adVM.isAdEditEnabled, isFromExtendAd: isFromExtendAd, adsID: adsId)); + } }, child: SizedBox( width: double.infinity, @@ -95,21 +108,23 @@ class SelectAdTypeView extends StatelessWidget { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - vehicleTypeModel.vehicleTypeName.toString().toText(fontSize: 18, isBold: true), + vehicleTypeModel.vehicleTypeName.toString().toText(fontSize: 18), getVehicleAdTypeIcon(vehicleTypeModel.vehicleTypeEnum!), ], ), if (isProvider) ...[ Row( children: [ - LocaleKeys.duration.tr().toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true), - LocaleKeys.validUntilSubscriptionExpiration.tr().toText(fontSize: 13, isBold: true), + "${LocaleKeys.duration.tr()}: ".toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true), + 2.width, + LocaleKeys.validUntilSubscriptionExpiration.tr().toText(fontSize: 13), ], ).paddingOnly(top: 5, bottom: 5), ] else ...[ Row( children: [ LocaleKeys.duration.tr().toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true), + 4.width, adVM.vehicleAdDurationId.selectedOption.toText(fontSize: 13, isBold: true), const Icon(Icons.keyboard_arrow_down_sharp, color: MyColors.darkPrimaryColor, size: 20), ], @@ -150,7 +165,7 @@ class SelectAdTypeView extends StatelessWidget { Row( children: [ "$remainingAds ".toText(fontSize: 29, isBold: true, letterSpacing: 0, height: 1), - LocaleKeys.adsRemaining.tr().toText(fontSize: 17, color: MyColors.lightTextColor, isBold: true), + LocaleKeys.adsRemaining.tr().toText(fontSize: 17, color: MyColors.lightTextColor), ], ), Text.rich( diff --git a/lib/views/common_fragments/ads_fragment.dart b/lib/views/common_fragments/ads_fragment.dart index 9b08eb8..97c1116 100644 --- a/lib/views/common_fragments/ads_fragment.dart +++ b/lib/views/common_fragments/ads_fragment.dart @@ -7,6 +7,7 @@ import 'package:mc_common_app/extensions/int_extensions.dart'; import 'package:mc_common_app/extensions/string_extensions.dart'; import 'package:mc_common_app/generated/locale_keys.g.dart'; import 'package:mc_common_app/models/advertisment_models/ad_details_model.dart'; +import 'package:mc_common_app/models/general_models/widgets_models.dart'; import 'package:mc_common_app/theme/colors.dart'; import 'package:mc_common_app/utils/enums.dart'; import 'package:mc_common_app/utils/navigator.dart'; @@ -145,6 +146,17 @@ class AdsFragment extends StatelessWidget { ), floatingActionButton: FloatingActionButton( onPressed: () async { + if (AppState().userType != UserType.providerDealer) { + if (adVM.vehicleAdDurationId.selectedId == -1 && adVM.vehicleAdsDurations.isNotEmpty) { + SelectionModel selection = SelectionModel( + selectedId: adVM.vehicleAdsDurations.first.id ?? 0, + selectedOption: ("${adVM.vehicleAdsDurations.first.days} ${LocaleKeys.daysVar.tr()}"), + itemPrice: adVM.vehicleAdsDurations.first.price!.toString(), + ); + adVM.updateVehicleAdDurationId(selection); + } + } + navigateWithName(context, AppRoutes.selectAdTypeView, arguments: [injector.get().currentAppType == AppType.provider, false, -1]); }, backgroundColor: MyColors.darkPrimaryColor, diff --git a/pubspec.yaml b/pubspec.yaml index 8d2b33c..91acd57 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -61,7 +61,7 @@ dependencies: # Auth local_auth: ^2.2.0 - huawei_fido: ^6.3.0+305 +# huawei_fido: ^6.3.0+305 device_info_plus: ^10.1.0