Manos Chorianopoulos

add MarketAnalysisItemViewCell

......@@ -7,7 +7,7 @@
<key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
</dict>
</dict>
......
......@@ -7,7 +7,7 @@
<key>SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>0</integer>
</dict>
</dict>
</dict>
......
......@@ -14,7 +14,8 @@ class MarketAnalysisItemViewCell: UITableViewCell {
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var priceLabel: UILabel!
@IBOutlet weak var subtitleLabel: UILabel!
@IBOutlet weak var productTitleLabel: UILabel!
var postImageURL: String? {
didSet {
if let url = postImageURL {
......@@ -43,7 +44,7 @@ class MarketAnalysisItemViewCell: UITableViewCell {
// title
titleLabel.textColor = UIColor(rgb: 0x212121)
titleLabel.font = UIFont(name: "PeridotPE-Regular", size: 17.0)
titleLabel.font = UIFont(name: "PeridotPE-SBold", size: 17.0)
// price
priceLabel.textColor = UIColor(rgb: 0x212121)
......@@ -52,74 +53,15 @@ class MarketAnalysisItemViewCell: UITableViewCell {
// subtitle
// subtitleLabel.textColor = UIColor(rgb: 0x9D9D9C)
subtitleLabel.textColor = UIColor(rgb: 0x212121)
subtitleLabel.font = UIFont(name: "PeridotPE-Regular", size: 14.0)
subtitleLabel.font = UIFont(name: "PeridotPE-SBold", size: 14.0)
// productTitleLabel
productTitleLabel.textColor = UIColor(rgb: 0x212121)
productTitleLabel.font = UIFont(name: "PeridotPE-Regular", size: 14.0)
}
}
extension AnalysisItemViewCell {
func configureCell(item: swiftApi.SharingCouponModel) {
let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList()
titleLabel.text = ""
for merchant in merchantList {
if (merchant._uuid == item._merchant_uuid) {
// itemImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache())
self.postImageURL = merchant._img_preview
titleLabel.text = merchant._admin_name
break;
}
}
dateLabel.text = item._date
// titleLabel.text = item._name
let priceFloat = Float(round(100 * (Float(item._final_price) )) / 100)
var priceString = "0"
priceString = String(format: "%.2f", priceFloat).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
priceLabel.text = priceString + "€"
if ("sent" == item._sharing_type) {
subtitleLabel.text = String(format: "Εκπτωτικό κουπόνι προς " + item._receiver_msisdn)
} else if ("received" == item._sharing_type) {
subtitleLabel.text = String(format: "Εκπτωτικό κουπόνι από " + item._sender_msisdn)
}
}
func configureCell(item: swiftApi.SharingCouponModel, isMarket: Bool) {
let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList()
let couponSetData: swiftApi.CouponSetItemModel? = item._sm_couponset_data
titleLabel.text = ""
for merchant in merchantList {
if (merchant._uuid == item._merchant_uuid) {
// itemImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache())
self.postImageURL = merchant._img_preview
titleLabel.text = merchant._admin_name
break;
}
}
dateLabel.text = item._date
// titleLabel.text = item._name
// titleLabel.text = couponSetData?.name ?? ""
// let priceFloat = Float(round(100 * (Float(item._final_price) )) / 100)
let priceFloat = Float(round(100 * (Float(couponSetData?.final_price ?? 0.0) )) / 100)
var priceString = "0"
priceString = String(format: "%.2f", priceFloat).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
priceLabel.text = priceString + "€"
if ("sent" == item._sharing_type) {
subtitleLabel.text = String(format: "Εκπτωτικό κουπόνι προς " + item._receiver_msisdn)
} else if ("received" == item._sharing_type) {
subtitleLabel.text = String(format: "Εκπτωτικό κουπόνι από " + item._sender_msisdn)
}
}
extension MarketAnalysisItemViewCell {
func configureCell(item: swiftApi.CouponItemModel) {
// COUPONSET: desc, img_preview, name, terms, merchant_uuid
......@@ -154,12 +96,15 @@ extension AnalysisItemViewCell {
priceString = String(format: "%.2f", priceFloat).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
priceLabel.text = priceString + "€"
subtitleLabel.text = "Έκπτωτικό κουπόνι"
subtitleLabel.text = "Έκπτωτικό κουπόνι" // TODO: FIX
// subtitleLabel.text = couponSetData?.short_description ?? ""
// OR
// let htmlText = couponSetData?.inner_text ?? ""
// subtitleLabel.text = htmlText.htmlToString
let htmlText = couponSetData?.inner_text ?? ""
productTitleLabel.text = htmlText.htmlToString
}
func configureCell(item: swiftApi.CouponItemModel, isMarket: Bool) {
......
......@@ -139,7 +139,7 @@ class MarketHistoryViewController: AnalysisChildViewController {
return cell
}
let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisItemViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisItemViewCell
let cell = tableView.dequeueReusableCell(withIdentifier: "MarketAnalysisItemViewCell", for: indexPath) as! SwiftWarplyFramework.MarketAnalysisItemViewCell
// cell.configureCell(item: items[indexPath.row], isMarket: true)
cell.configureCell(item: items[indexPath.row])
......