diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index a2f0aa1..4178d17 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -517,6 +517,9 @@ "startingIn": "يبدأ في", "youAreOutOfContest": "أنت خارج المسابقة.", "winners": "الفائزين!!!", + "expireAfter":"تنتهي بعد", + "oneWeek":"أسبوع 1", + "twoWeek":"2 أسبوع", "noUpcoming": "لا يوجد قادم", "fakeLocation": ".لقد تتبعنا أنك تحاول استخدام موقع مزيف! يعتبر هذا مخالفة وقد تم إخطار الموارد البشرية", "noWinner": "حزين! لم يفز أحد اليوم.", diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index 2e6703a..e4a4266 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -517,6 +517,9 @@ "startingIn": "Starting in", "youAreOutOfContest": "You are out of the contest.", "winners": "WINNERS!!!", + "expireAfter":"Expires After", + "oneWeek":"1 Week", + "twoWeek":"2 Week", "noUpcoming": "There is no upcoming", "fakeLocation": "We traced out that you try to use a fake location! This is considered a violation, and HR has been notified.", "noWinner": "Sad! No one won today.", diff --git a/lib/api/offers_and_discounts_api_client.dart b/lib/api/offers_and_discounts_api_client.dart index 1d3153c..8c92539 100644 --- a/lib/api/offers_and_discounts_api_client.dart +++ b/lib/api/offers_and_discounts_api_client.dart @@ -17,7 +17,7 @@ class OffersAndDiscountsApiClient { List getSaleCategoriesList = []; String url = "${ApiConsts.cocRest}Mohemm_ITG_GetCategories"; - Map postParams = {"EmployeeNumber": AppState().memberInformationList?.eMPLOYEENUMBER, "ItgPageSize": 100, "ItgPageNo": 1}; + Map postParams = {"EmployeeNumber": AppState().memberInformationList?.eMPLOYEENUMBER, "ItgPageSize": 100, "ItgPageNo": 1, "ItgIsActive": true}; postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject( @@ -55,12 +55,12 @@ class OffersAndDiscountsApiClient { (response) { var body = json.decode(response['Mohemm_ITG_ResponseItem']); - var bodyData = json.decode(body['result']['data']); + var bodyData = body['result']['data']; - if(bodyData != null) { + if (bodyData != null) { bodyData.forEach((v) { - getSaleCategoriesList.add(OffersListModel.fromJson(v)); - }); + getSaleCategoriesList.add(OffersListModel.fromJson(v)); + }); } return getSaleCategoriesList; }, diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index 1671b72..184748a 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 mohemm = 'mohemm'; static const english = 'english'; static const arabic = 'arabic'; @@ -250,7 +250,7 @@ abstract class LocaleKeys { static const Payroll = 'Payroll'; static const civilIdentityNumber = 'civilIdentityNumber'; static const dateOfBirth = 'dateOfBirth'; - static const maritalStatus = 'maritalStatus '; + static const maritalStatus = 'maritalStatus '; static const fullName = 'fullName'; static const remove = 'remove'; static const submit = 'submit'; @@ -280,7 +280,7 @@ abstract class LocaleKeys { static const enterNewInfo = 'enterNewInfo'; static const endDate = 'endDate'; static const removeThisMember = 'removeThisMember'; - static const wantUpdateThisMember = 'wantUpdateThisMember '; + static const wantUpdateThisMember = 'wantUpdateThisMember '; static const addNewFamilyMember = 'addNewFamilyMember'; static const addRow = 'addRow'; static const pleaseSelect = 'pleaseSelect'; @@ -505,8 +505,10 @@ abstract class LocaleKeys { static const winners = 'winners'; static const noUpcoming = 'noUpcoming'; static const fakeLocation = 'fakeLocation'; + static const expireAfter = 'expireAfter'; + static const oneWeek = 'oneWeek'; + static const twoWeek = 'twoWeek'; static const noWinner = 'noWinner'; static const myTeam = 'myTeam'; static const youCanPlayDemo = 'youCanPlayDemo'; - } diff --git a/lib/generated_plugin_registrant.dart b/lib/generated_plugin_registrant.dart index 37be8d8..642c8ec 100644 --- a/lib/generated_plugin_registrant.dart +++ b/lib/generated_plugin_registrant.dart @@ -6,6 +6,8 @@ // ignore_for_file: lines_longer_than_80_chars // ignore_for_file: depend_on_referenced_packages +import 'package:audio_session/audio_session_web.dart'; +import 'package:camera_web/camera_web.dart'; import 'package:file_picker/_internal/file_picker_web.dart'; import 'package:firebase_core_web/firebase_core_web.dart'; import 'package:firebase_messaging_web/firebase_messaging_web.dart'; @@ -13,6 +15,8 @@ import 'package:fluttertoast/fluttertoast_web.dart'; import 'package:geolocator_web/geolocator_web.dart'; import 'package:google_maps_flutter_web/google_maps_flutter_web.dart'; import 'package:image_picker_for_web/image_picker_for_web.dart'; +import 'package:just_audio_web/just_audio_web.dart'; +import 'package:record_web/record_web.dart'; import 'package:shared_preferences_web/shared_preferences_web.dart'; import 'package:url_launcher_web/url_launcher_web.dart'; import 'package:video_player_web/video_player_web.dart'; @@ -21,6 +25,8 @@ import 'package:flutter_web_plugins/flutter_web_plugins.dart'; // ignore: public_member_api_docs void registerPlugins(Registrar registrar) { + AudioSessionWeb.registerWith(registrar); + CameraPlugin.registerWith(registrar); FilePickerWeb.registerWith(registrar); FirebaseCoreWeb.registerWith(registrar); FirebaseMessagingWeb.registerWith(registrar); @@ -28,6 +34,8 @@ void registerPlugins(Registrar registrar) { GeolocatorPlugin.registerWith(registrar); GoogleMapsPlugin.registerWith(registrar); ImagePickerPlugin.registerWith(registrar); + JustAudioPlugin.registerWith(registrar); + RecordPluginWeb.registerWith(registrar); SharedPreferencesPlugin.registerWith(registrar); UrlLauncherPlugin.registerWith(registrar); VideoPlayerPlugin.registerWith(registrar); diff --git a/lib/models/items_for_sale/get_employee_ads_list.dart b/lib/models/items_for_sale/get_employee_ads_list.dart index 68aa805..7b7b7a6 100644 --- a/lib/models/items_for_sale/get_employee_ads_list.dart +++ b/lib/models/items_for_sale/get_employee_ads_list.dart @@ -11,7 +11,7 @@ class EmployeePostedAds { String? countryName; String? currencyCode; String? startDate; - String? endDate; + DateTime? endDate; int? quotePrice; int? employeeNumber; String? profilePicture; @@ -29,32 +29,32 @@ class EmployeePostedAds { EmployeePostedAds( {this.itemSaleID, - this.title, - this.titleAr, - this.description, - this.descriptionAr, - this.categoryID, - this.categoryTitle, - this.regionID, - this.regionName, - this.countryName, - this.currencyCode, - this.startDate, - this.endDate, - this.quotePrice, - this.employeeNumber, - this.profilePicture, - this.fullName, - this.emailAddress, - this.mobileNumber, - this.isApproved, - this.status, - this.itemAttachments, - this.created, - this.isActive, - this.pageSize, - this.pageNo, - this.languageId}); + this.title, + this.titleAr, + this.description, + this.descriptionAr, + this.categoryID, + this.categoryTitle, + this.regionID, + this.regionName, + this.countryName, + this.currencyCode, + this.startDate, + this.endDate, + this.quotePrice, + this.employeeNumber, + this.profilePicture, + this.fullName, + this.emailAddress, + this.mobileNumber, + this.isApproved, + this.status, + this.itemAttachments, + this.created, + this.isActive, + this.pageSize, + this.pageNo, + this.languageId}); EmployeePostedAds.fromJson(Map json) { itemSaleID = json['itemSaleID']; @@ -115,8 +115,7 @@ class EmployeePostedAds { data['isApproved'] = this.isApproved; data['status'] = this.status; if (this.itemAttachments != null) { - data['itemAttachments'] = - this.itemAttachments!.map((v) => v.toJson()).toList(); + data['itemAttachments'] = this.itemAttachments!.map((v) => v.toJson()).toList(); } data['created'] = this.created; data['isActive'] = this.isActive; @@ -138,16 +137,7 @@ class ItemAttachments { String? content; String? filePath; - ItemAttachments( - {this.attachmentId, - this.fileName, - this.contentType, - this.attachFileStream, - this.base64String, - this.isActive, - this.referenceItemId, - this.content, - this.filePath}); + ItemAttachments({this.attachmentId, this.fileName, this.contentType, this.attachFileStream, this.base64String, this.isActive, this.referenceItemId, this.content, this.filePath}); ItemAttachments.fromJson(Map json) { attachmentId = json['attachmentId']; diff --git a/lib/models/items_for_sale/item_review_model.dart b/lib/models/items_for_sale/item_review_model.dart index 4aac997..1f6d9d2 100644 --- a/lib/models/items_for_sale/item_review_model.dart +++ b/lib/models/items_for_sale/item_review_model.dart @@ -9,16 +9,8 @@ class ItemReviewModel { num? itemPrice; List? itemPhotos; GetSaleCategoriesList? selectedSaleCategory; - - ItemReviewModel( - this.itemTitle, - this.itemDescription, - this.itemCondition, - this.selectedRegion, - this.itemPrice, - this.itemPhotos, - this.selectedSaleCategory, - ); + DateTime endDate; + ItemReviewModel(this.itemTitle, this.itemDescription, this.itemCondition, this.selectedRegion, this.itemPrice, this.itemPhotos, this.selectedSaleCategory, this.endDate); Map toJson() { Map data = new Map(); @@ -29,7 +21,7 @@ class ItemReviewModel { data['itemPrice'] = this.itemPrice; data['itemPhotos'] = this.itemPhotos; data['selectedSaleCategory'] = this.selectedSaleCategory; + data['endDate'] = this.endDate; return data; } - } diff --git a/lib/models/offers_and_discounts/get_offers_list.dart b/lib/models/offers_and_discounts/get_offers_list.dart index 2ba42ea..e48f3f1 100644 --- a/lib/models/offers_and_discounts/get_offers_list.dart +++ b/lib/models/offers_and_discounts/get_offers_list.dart @@ -1,96 +1,192 @@ class OffersListModel { - String? title; - String? titleAR; - String? description; - String? descriptionAR; + int? offersDiscountId; + String? titleEn; + String? titleAr; + String? descriptionEn; + String? descriptionAr; String? startDate; String? endDate; - String? logo; - String? bannerImage; - String? discount; - String? rowID; + int? categoryId; String? categoryNameEn; String? categoryNameAr; - String? categoryID; - String? isHasLocation; + String? discount; + String? location; + int? statusId; + String? statusTitle; + bool? isHasLocation; + String? discountDescription; + String? websiteUrl; + bool? bookMarked; + bool? isHotDeal; + List? offersDiscountImageColl; + dynamic locationList; String? created; - String? publishedDesc; - String? published; - String? expireAfter; - String? status; - String? isActive; - String? totalItems; + String? bannerImage; + String? logo; + bool? isActive; + int? pageSize; + int? pageNo; + int? languageId; OffersListModel( - {this.title, - this.titleAR, - this.description, - this.descriptionAR, - this.startDate, - this.endDate, - this.logo, - this.bannerImage, - this.discount, - this.rowID, - this.categoryNameEn, - this.categoryNameAr, - this.categoryID, - this.isHasLocation, - this.created, - this.publishedDesc, - this.published, - this.expireAfter, - this.status, - this.isActive, - this.totalItems}); + {this.offersDiscountId, + this.titleEn, + this.titleAr, + this.descriptionEn, + this.descriptionAr, + this.startDate, + this.endDate, + this.categoryId, + this.categoryNameEn, + this.categoryNameAr, + this.discount, + this.location, + this.statusId, + this.statusTitle, + this.isHasLocation, + this.discountDescription, + this.websiteUrl, + this.bookMarked, + this.isHotDeal, + this.offersDiscountImageColl, + this.locationList, + this.created, + this.bannerImage, + this.logo, + this.isActive, + this.pageSize, + this.pageNo, + this.languageId}); OffersListModel.fromJson(Map json) { - title = json['Title']; - titleAR = json['Title_AR']; - description = json['Description']; - descriptionAR = json['Description_AR']; - startDate = json['Start Date']; - endDate = json['End Date']; - logo = json['Logo']; - bannerImage = json['Banner_Image']; - discount = json['Discount']; - rowID = json['rowID']; + offersDiscountId = json['offersDiscountId']; + titleEn = json['titleEn']; + titleAr = json['titleAr']; + descriptionEn = json['descriptionEn']; + descriptionAr = json['descriptionAr']; + startDate = json['startDate']; + endDate = json['endDate']; + categoryId = json['categoryId']; categoryNameEn = json['categoryName_en']; categoryNameAr = json['categoryName_ar']; - categoryID = json['categoryID']; - isHasLocation = json['IsHasLocation']; + discount = json['discount']; + location = json['location']; + statusId = json['statusId']; + statusTitle = json['statusTitle']; + isHasLocation = json['isHasLocation']; + discountDescription = json['discountDescription']; + websiteUrl = json['websiteUrl']; + bookMarked = json['bookMarked']; + isHotDeal = json['isHotDeal']; + if (json['offersDiscountImageColl'] != null) { + offersDiscountImageColl = []; + json['offersDiscountImageColl'].forEach((v) { + offersDiscountImageColl!.add(new OffersDiscountImageColl.fromJson(v)); + }); + } + locationList = json['locationList']; created = json['created']; - publishedDesc = json['PublishedDesc']; - published = json['Published']; - expireAfter = json['ExpireAfter']; - status = json['Status']; - isActive = json['IsActive']; - totalItems = json['TotalItems']; + bannerImage = json['banner_Image']; + logo = json['logo']; + isActive = json['isActive']; + pageSize = json['pageSize']; + pageNo = json['pageNo']; + languageId = json['languageId']; } Map toJson() { Map data = new Map(); - data['Title'] = this.title; - data['Title_AR'] = this.titleAR; - data['Description'] = this.description; - data['Description_AR'] = this.descriptionAR; - data['Start Date'] = this.startDate; - data['End Date'] = this.endDate; - data['Logo'] = this.logo; - data['Banner_Image'] = this.bannerImage; - data['Discount'] = this.discount; - data['rowID'] = this.rowID; + data['offersDiscountId'] = this.offersDiscountId; + data['titleEn'] = this.titleEn; + data['titleAr'] = this.titleAr; + data['descriptionEn'] = this.descriptionEn; + data['descriptionAr'] = this.descriptionAr; + data['startDate'] = this.startDate; + data['endDate'] = this.endDate; + data['categoryId'] = this.categoryId; data['categoryName_en'] = this.categoryNameEn; data['categoryName_ar'] = this.categoryNameAr; - data['categoryID'] = this.categoryID; - data['IsHasLocation'] = this.isHasLocation; + data['discount'] = this.discount; + data['location'] = this.location; + data['statusId'] = this.statusId; + data['statusTitle'] = this.statusTitle; + data['isHasLocation'] = this.isHasLocation; + data['discountDescription'] = this.discountDescription; + data['websiteUrl'] = this.websiteUrl; + data['bookMarked'] = this.bookMarked; + data['isHotDeal'] = this.isHotDeal; + if (this.offersDiscountImageColl != null) { + data['offersDiscountImageColl'] = this.offersDiscountImageColl!.map((v) => v.toJson()).toList(); + } + data['locationList'] = this.locationList; data['created'] = this.created; - data['PublishedDesc'] = this.publishedDesc; - data['Published'] = this.published; - data['ExpireAfter'] = this.expireAfter; - data['Status'] = this.status; - data['IsActive'] = this.isActive; - data['TotalItems'] = this.totalItems; + data['banner_Image'] = this.bannerImage; + data['logo'] = this.logo; + data['isActive'] = this.isActive; + data['pageSize'] = this.pageSize; + data['pageNo'] = this.pageNo; + data['languageId'] = this.languageId; + return data; + } +} + +class OffersDiscountImageColl { + int? imageAttachmentId; + String? fileName; + String? contentType; + String? attachFileStream; + String? base64String; + int? referenceItemId; + String? filePath; + String? imageTag; + bool? isActive; + int? pageSize; + int? pageNo; + int? languageId; + + OffersDiscountImageColl( + {this.imageAttachmentId, + this.fileName, + this.contentType, + this.attachFileStream, + this.base64String, + this.referenceItemId, + this.filePath, + this.imageTag, + this.isActive, + this.pageSize, + this.pageNo, + this.languageId}); + + OffersDiscountImageColl.fromJson(Map json) { + imageAttachmentId = json['imageAttachmentId']; + fileName = json['fileName']; + contentType = json['contentType']; + attachFileStream = json['attachFileStream']; + base64String = json['base64String']; + referenceItemId = json['referenceItemId']; + filePath = json['filePath']; + imageTag = json['imageTag']; + isActive = json['isActive']; + pageSize = json['pageSize']; + pageNo = json['pageNo']; + languageId = json['languageId']; + } + + Map toJson() { + Map data = new Map(); + data['imageAttachmentId'] = this.imageAttachmentId; + data['fileName'] = this.fileName; + data['contentType'] = this.contentType; + data['attachFileStream'] = this.attachFileStream; + data['base64String'] = this.base64String; + data['referenceItemId'] = this.referenceItemId; + data['filePath'] = this.filePath; + data['imageTag'] = this.imageTag; + data['isActive'] = this.isActive; + data['pageSize'] = this.pageSize; + data['pageNo'] = this.pageNo; + data['languageId'] = this.languageId; return data; } } diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index 03bf9cd..af6f903 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -445,7 +445,7 @@ class _DashboardScreenState extends State with WidgetsBindingOb Radius.circular(50), ), child: Hero( - tag: "ItemImage" + data.getOffersList[index].rowID!, + tag: "ItemImage" + data.getOffersList[index].offersDiscountId.toString()!, transitionOnUserGestures: true, child: Image.network( data.getOffersList[index].bannerImage!, @@ -457,8 +457,8 @@ class _DashboardScreenState extends State with WidgetsBindingOb 4.height, Expanded( child: AppState().isArabic(context) - ? data.getOffersList[index].titleAR!.toText12(isCenter: true, maxLine: 1) - : data.getOffersList[index].title!.toText12(isCenter: true, maxLine: 1), + ? data.getOffersList[index].titleAr!.toText12(isCenter: true, maxLine: 1) + : data.getOffersList[index].titleEn!.toText12(isCenter: true, maxLine: 1), ), ], ), @@ -612,7 +612,7 @@ class _DashboardScreenState extends State with WidgetsBindingOb data.getOffersList.forEach((OffersListModel element) { if (counter <= 4) { - if (element.rowID != offersListModelObj.rowID) { + if (element.offersDiscountId != offersListModelObj.offersDiscountId) { getOffersDetailList.add(element); counter++; } diff --git a/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart b/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart index c79f929..4d11bb8 100644 --- a/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart +++ b/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart @@ -137,6 +137,7 @@ class _DynamicInputScreenState extends State { getEitDffStructureList = abc; int index = getEitDffStructureList!.indexWhere((element) => element.sEGMENTNAME == segmentId); getEitDffStructureList![index].eSERVICESVS!.clear(); + getEitDffStructureList![index].eSERVICESDV = ESERVICESDV(); if (eServicesResponseModel.isNotEmpty) getEitDffStructureList![index].eSERVICESVS!.addAll(eServicesResponseModel); // getEitDffStructureList = genericResponseModel?.getEITDFFStructureList ?? []; //getEitDffStructureList = getEitDffStructureList!.where((element) => element.dISPLAYFLAG != "N").toList(); diff --git a/lib/ui/screens/items_for_sale/fragments/add_details_fragment.dart b/lib/ui/screens/items_for_sale/fragments/add_details_fragment.dart index 9b82d9d..5e3f749 100644 --- a/lib/ui/screens/items_for_sale/fragments/add_details_fragment.dart +++ b/lib/ui/screens/items_for_sale/fragments/add_details_fragment.dart @@ -37,7 +37,7 @@ class _AddItemDetailsFragmentState extends State { String itemTitle = ""; String itemDescription = ""; num itemPrice = 0; - String selectedItemCondition = "new"; + String selectedItemCondition = "1"; List getRegionsList = []; GetRegionsList selectedRegion = GetRegionsList(); @@ -88,16 +88,16 @@ class _AddItemDetailsFragmentState extends State { itemDescription = value; }, ).paddingOnly(top: 12), - LocaleKeys.itemCondition.tr().toText14().paddingOnly(top: 21), + LocaleKeys.expireAfter.tr().toText14().paddingOnly(top: 21), Row( children: [ - ShowRadio(title: LocaleKeys.newString.tr(), value: "new", groupValue: selectedItemCondition, selectedColor: MyColors.gradiantStartColor).onPress(() { - selectedItemCondition = "new"; + ShowRadio(title: LocaleKeys.oneWeek.tr(), value: "1", groupValue: selectedItemCondition, selectedColor: MyColors.gradiantStartColor).onPress(() { + selectedItemCondition = "1"; setState(() {}); }), 12.width, - ShowRadio(title: LocaleKeys.used.tr(), value: "used", groupValue: selectedItemCondition, selectedColor: MyColors.gradiantStartColor).onPress(() { - selectedItemCondition = "used"; + ShowRadio(title: LocaleKeys.twoWeek.tr(), value: "2", groupValue: selectedItemCondition, selectedColor: MyColors.gradiantStartColor).onPress(() { + selectedItemCondition = "2"; setState(() {}); }), ], @@ -166,8 +166,18 @@ class _AddItemDetailsFragmentState extends State { ); } + DateTime getEndDate() { + DateTime date = DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day); + DateTime endDate; + if (selectedItemCondition == "1") { + return endDate = DateTime(date.year, date.month, date.day + 7); + } else { + return endDate = DateTime(date.year, date.month, date.day + 7); + } + } + ItemReviewModel getItemReviewObject() { - ItemReviewModel itemReviewModel = ItemReviewModel(itemTitle, itemDescription, selectedItemCondition, selectedRegion, itemPrice, images, widget.selectedSaleCategory); + ItemReviewModel itemReviewModel = ItemReviewModel(itemTitle, itemDescription, selectedItemCondition, selectedRegion, itemPrice, images, widget.selectedSaleCategory, getEndDate()); return itemReviewModel; } @@ -246,7 +256,7 @@ class _AddItemDetailsFragmentState extends State { Future getAdDetails() async { // todo need to change this method later , its not a good approach to do it like this. String details = await Utils.getStringFromPrefs(SharedPrefsConsts.editItemForSale); - if(details.isNotEmpty) { + if (details.isNotEmpty) { var body = json.decode(details); AddItemDetailsFragment.isUpdate = true; @@ -259,6 +269,7 @@ class _AddItemDetailsFragmentState extends State { selectedItemCondition = body["itemCondition"].toString().toLowerCase(); selectedRegionAd.regionID = body["selectedRegion"]["regionID"]; selectedRegionAd.regionName = body["selectedRegion"]["regionName"]; + selectedRegion = selectedRegionAd; itemPrice = body["itemPrice"]; selectedSaleCategoryAd.categoryID = body["selectedSaleCategory"]["categoryID"]; @@ -266,8 +277,8 @@ class _AddItemDetailsFragmentState extends State { if (body["itemPhotos"].length != 0) { images.add(body["itemPhotos"][0]); } - ItemReviewModel itemReviewModel = - ItemReviewModel(body["itemTitle"], body["itemDescription"], body["itemCondition"].toString().toLowerCase(), selectedRegionAd, body["itemPrice"], images, selectedSaleCategoryAd); + ItemReviewModel itemReviewModel = ItemReviewModel( + body["itemTitle"], body["itemDescription"], body["itemCondition"].toString().toLowerCase(), selectedRegionAd, body["itemPrice"], images, selectedSaleCategoryAd, getEndDate()); AddItemDetailsFragment.itemReviewModel = itemReviewModel; SelectCategoryFragment.selectedSaleCategory = selectedSaleCategoryAd; diff --git a/lib/ui/screens/items_for_sale/fragments/item_review_fragment.dart b/lib/ui/screens/items_for_sale/fragments/item_review_fragment.dart index 190460e..1e3581a 100644 --- a/lib/ui/screens/items_for_sale/fragments/item_review_fragment.dart +++ b/lib/ui/screens/items_for_sale/fragments/item_review_fragment.dart @@ -27,12 +27,13 @@ class ItemReviewFragment extends StatefulWidget { class _ItemReviewFragmentState extends State { ItemReviewModel? itemReviewModel; late bool isUpdate; - + String? validFor = ''; @override void initState() { itemReviewModel = AddItemDetailsFragment.itemReviewModel; itemReviewModel!.selectedSaleCategory = SelectCategoryFragment.selectedSaleCategory; isUpdate = AddItemDetailsFragment.isUpdate; + validFor = itemReviewModel?.itemCondition; super.initState(); } @@ -105,7 +106,7 @@ class _ItemReviewFragmentState extends State { size: 20, color: MyColors.redColor, ).paddingOnly(top: 21), - "This ad will be valid for 2 weeks after approval.".toText11(color: MyColors.redColor).paddingOnly(left: 10, right: 10), + "This ad will be valid for $validFor weeks after approval.".toText11(color: MyColors.redColor).paddingOnly(left: 10, right: 10), ], ), const Spacer(), diff --git a/lib/ui/screens/items_for_sale/fragments/my_posted_ads_fragment.dart b/lib/ui/screens/items_for_sale/fragments/my_posted_ads_fragment.dart index 02db148..ffce243 100644 --- a/lib/ui/screens/items_for_sale/fragments/my_posted_ads_fragment.dart +++ b/lib/ui/screens/items_for_sale/fragments/my_posted_ads_fragment.dart @@ -154,7 +154,7 @@ class _MyPostedAdsFragmentState extends State { List itemPhotos = []; itemPhotos.add(employeePostedAdsList[index].itemAttachments![0].content!.toString()); ItemReviewModel itemReviewModel = ItemReviewModel(employeePostedAdsList[index].title, employeePostedAdsList[index].description, employeePostedAdsList[index].status, - selectedRegion, employeePostedAdsList[index].quotePrice, itemPhotos, selectedSaleCategory); + selectedRegion, employeePostedAdsList[index].quotePrice, itemPhotos, selectedSaleCategory, employeePostedAdsList[index].endDate!); Utils.saveStringFromPrefs(SharedPrefsConsts.editItemForSale, jsonEncode(itemReviewModel.toJson())); Navigator.pushNamed(context, AppRoutes.addNewItemForSale, arguments: 1); }).expanded, @@ -188,6 +188,7 @@ class _MyPostedAdsFragmentState extends State { request.fields['ItgQuotePrice'] = employeePostedAds.quotePrice.toString(); request.fields['RegionID'] = employeePostedAds.regionID.toString(); request.fields['Itg_EndDate'] = employeePostedAds.endDate.toString(); + request.fields['endDate'] = employeePostedAds.endDate.toString(); request.fields['Channel'] = "31"; request.fields['ItgIsActive'] = "false"; request.fields['LogInToken'] = loginTokenID!; diff --git a/lib/ui/screens/offers_and_discounts/offers_and_discounts_details.dart b/lib/ui/screens/offers_and_discounts/offers_and_discounts_details.dart index e9f46d7..d980728 100644 --- a/lib/ui/screens/offers_and_discounts/offers_and_discounts_details.dart +++ b/lib/ui/screens/offers_and_discounts/offers_and_discounts_details.dart @@ -57,14 +57,14 @@ class _OffersAndDiscountsDetailsState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Hero( - tag: "ItemImage" + getOffersList[0].rowID!, + tag: "ItemImage" + getOffersList[0].offersDiscountId.toString()!, // transitionOnUserGestures: true, child: RepaintBoundary( key: _globalKey, child: ClipRRect( borderRadius: BorderRadius.circular(6), child: Image.network( - getOffersList[0].bannerImage!, + getOffersList[0].bannerImage ?? "", fit: BoxFit.contain, ), ).paddingAll(12), @@ -72,10 +72,10 @@ class _OffersAndDiscountsDetailsState extends State { ), 8.height, AppState().isArabic(context) - ? getOffersList[0].titleAR!.toText22(isBold: true, color: const Color(0xff2B353E)).center - : getOffersList[0].title!.toText22(isBold: true, color: const Color(0xff2B353E)).center, + ? getOffersList[0].titleAr!.toText22(isBold: true, color: const Color(0xff2B353E)).center + : getOffersList[0].titleEn!.toText22(isBold: true, color: const Color(0xff2B353E)).center, Html( - data: AppState().isArabic(context) ? getOffersList[0].descriptionAR! : getOffersList[0].description ?? "", + data: AppState().isArabic(context) ? getOffersList[0].descriptionAr! : getOffersList[0].descriptionEn ?? "", onLinkTap: (String? url, RenderContext context, Map attributes, _) { launchUrl(Uri.parse(url!)); }, @@ -127,7 +127,7 @@ class _OffersAndDiscountsDetailsState extends State { Directory tempDir = await getTemporaryDirectory(); File file = await File('${tempDir.path}/${DateTime.now().toString()}.png').create(); await file.writeAsBytes(pngBytes); - await Share.shareFiles([(file.path)], text: AppState().isArabic(context) ? getOffersList[0].titleAR : getOffersList[0].title); + await Share.shareFiles([(file.path)], text: AppState().isArabic(context) ? getOffersList[0].titleAr : getOffersList[0].titleEn); } catch (ex) { debugPrint(ex.toString()); } @@ -155,21 +155,21 @@ class _OffersAndDiscountsDetailsState extends State { mainAxisSize: MainAxisSize.min, children: [ Hero( - tag: "ItemImage" + getOffersList.rowID!, + tag: "ItemImage" + getOffersList.offersDiscountId.toString()!, transitionOnUserGestures: true, child: AspectRatio( aspectRatio: 148 / 127, child: ClipRRect( borderRadius: BorderRadius.circular(6), child: Image.network( - getOffersList.bannerImage!, + getOffersList.bannerImage ?? "", fit: BoxFit.contain, ), ), ), ), 5.height, - getOffersList.title!.toText16(isBold: true, color: const Color(0xff2B353E), maxlines: 1), + getOffersList.titleEn!.toText16(isBold: true, color: const Color(0xff2B353E), maxlines: 1), // Html( // data: AppState().isArabic(context) ? getOffersList.descriptionAR! : getOffersList.description ?? "", // // onLinkTap: (String? url, RenderContext context, Map attributes, _) { @@ -178,7 +178,7 @@ class _OffersAndDiscountsDetailsState extends State { // ), // getOffersList.description!.toText12(maxLine: 2, color: const Color(0xff535353)), // 16.height, - getOffersList.discount!.toText14(isBold: true, maxlines: 1), + getOffersList.discountDescription!.toText14(isBold: true, maxlines: 1), 8.height, Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -195,11 +195,12 @@ class _OffersAndDiscountsDetailsState extends State { void getOfferLocation() {} Widget checkDate(String endDate) { - DateTime endDateObj = DateFormat("yyyy-MM-dd").parse(endDate); - if (endDateObj.isAfter(DateTime.now())) { - return "Offer Valid".toText16(isBold: true, color: MyColors.greenColor); - } else { - return "Offer Expired".toText16(isBold: true, color: MyColors.redColor); - } + // this new api always return valid offer and discount so commenting the expired one + // DateTime endDateObj = DateFormat("yyyy-MM-dd").parse(endDate); + // if (endDateObj.isAfter(DateTime.now())) { + return "Offer Valid".toText16(isBold: true, color: MyColors.greenColor); + // } else { + // return "Offer Expired".toText16(isBold: true, color: MyColors.redColor); + // } } } diff --git a/lib/ui/screens/offers_and_discounts/offers_and_discounts_home.dart b/lib/ui/screens/offers_and_discounts/offers_and_discounts_home.dart index c62cc9c..fd2c19e 100644 --- a/lib/ui/screens/offers_and_discounts/offers_and_discounts_home.dart +++ b/lib/ui/screens/offers_and_discounts/offers_and_discounts_home.dart @@ -157,22 +157,22 @@ class _OffersAndDiscountsHomeState extends State { mainAxisSize: MainAxisSize.min, children: [ Hero( - tag: "ItemImage" + getOffersList.rowID!, + tag: "ItemImage" + getOffersList.offersDiscountId.toString()!, transitionOnUserGestures: true, child: AspectRatio( aspectRatio: 118 / 127, child: ClipRRect( borderRadius: BorderRadius.circular(6), child: Image.network( - getOffersList.bannerImage!, + getOffersList.bannerImage ?? "", fit: BoxFit.contain, ), ), ), ), AppState().isArabic(context) - ? getOffersList.titleAR!.toText16(isBold: true, color: const Color(0xff2B353E), maxlines: 1) - : getOffersList.title!.toText16(isBold: true, color: const Color(0xff2B353E), maxlines: 1), + ? getOffersList.titleAr!.toText16(isBold: true, color: const Color(0xff2B353E), maxlines: 1) + : getOffersList.titleEn!.toText16(isBold: true, color: const Color(0xff2B353E), maxlines: 1), // Html( // data: AppState().isArabic(context) ? getOffersList.descriptionAR! : getOffersList.description ?? "", // // onLinkTap: (String? url, RenderContext context, Map attributes, _) { @@ -181,7 +181,7 @@ class _OffersAndDiscountsHomeState extends State { // ), // getOffersList.description!.toText12(maxLine: 2, color: const Color(0xff535353)), // 8.height, - getOffersList.discount!.toText14(isBold: true, maxlines: 1), + getOffersList.discountDescription!.toText14(isBold: true, maxlines: 1), 20.height, Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -199,9 +199,9 @@ class _OffersAndDiscountsHomeState extends State { results = getOffersList; } else { if (AppState().isArabic(context)) { - results = getOffersList.where((offer) => offer.titleAR!.toLowerCase().contains(enteredKeyword.toLowerCase())).toList(); + results = getOffersList.where((offer) => offer.titleAr!.toLowerCase().contains(enteredKeyword.toLowerCase())).toList(); } else { - results = getOffersList.where((offer) => offer.title!.toLowerCase().contains(enteredKeyword.toLowerCase())).toList(); + results = getOffersList.where((offer) => offer.titleEn!.toLowerCase().contains(enteredKeyword.toLowerCase())).toList(); } } setState(() { @@ -218,7 +218,7 @@ class _OffersAndDiscountsHomeState extends State { getOffersList.forEach((element) { if (counter <= 4) { - if (element.rowID != offersListModelObj.rowID) { + if (element.offersDiscountId != offersListModelObj.offersDiscountId) { getOffersDetailList.add(element); counter++; } @@ -229,12 +229,13 @@ class _OffersAndDiscountsHomeState extends State { } Widget checkDate(String endDate) { - DateTime endDateObj = DateFormat("yyyy-MM-dd").parse(endDate); - if (endDateObj.isAfter(DateTime.now())) { - return LocaleKeys.offerValid.tr().toText14(isBold: true, color: MyColors.greenColor); - } else { - return LocaleKeys.offerExpired.tr().toText14(isBold: true, color: MyColors.redColor); - } + // this new api always return valid offer and discount so commenting the expired one + // DateTime endDateObj = DateFormat("yyyy-MM-dd").parse(endDate); + // if (endDateObj.isAfter(DateTime.now())) { + return LocaleKeys.offerValid.tr().toText14(isBold: true, color: MyColors.greenColor); + // } else { + // return LocaleKeys.offerExpired.tr().toText14(isBold: true, color: MyColors.redColor); + // } } void getCategoriesListAPI() async {