Manos Chorianopoulos

delete unnecessary files and code, add openSuperMarketsFlow function

Showing 416 changed files with 2 additions and 2844 deletions
{
"originHash" : "a973e37718e3a158b792c38b1b8ebf4fb41961343f7a99be3fa56123caed92c7",
"pins" : [
{
"identity" : "rsbarcodes_swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/yeahdongcn/RSBarcodes_Swift",
"state" : {
"revision" : "86d8b1a1439e7edb19793d17732b15fd784a0a15",
"version" : "5.1.1"
}
},
{
"identity" : "swifteventbus",
"kind" : "remoteSourceControl",
"location" : "https://github.com/cesarferreira/SwiftEventBus",
......@@ -19,5 +11,5 @@
}
}
],
"version" : 2
"version" : 3
}
......
//
// ActiveCodeTableViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 3/4/23.
//
import UIKit
@objc public class ActiveCodeTableViewCell: UITableViewCell {
@IBOutlet weak var activeCodeView: UIView!
@IBOutlet weak var activeCodeViewHeight: NSLayoutConstraint!
@IBOutlet weak var activeCodesCountLabel: UILabel!
@IBOutlet weak var activeCodeLabel: UILabel!
@IBOutlet weak var activeCodeExpirationLabel: UILabel!
@IBOutlet weak var activeCodeImage: UIImageView!
@IBOutlet weak var activeCodeScrollView: UIScrollView!
@IBOutlet weak var activeCodeScrollViewHeight: NSLayoutConstraint!
@IBOutlet weak var activeCodeContentView: UIView!
@IBOutlet weak var activeCodeContentViewHeight: NSLayoutConstraint!
public var dfyCoupons:Array<swiftApi.ActiveDFYCouponModel> = swiftApi().getActiveDFYCoupons()
public override func awakeFromNib() {
super.awakeFromNib()
// TODO: DELETE ===>
// let coupon = swiftApi.ActiveDFYCouponModel()
// coupon._value = "12"
// // coupon._date = "2022-12-05 01:55:01"
// coupon._date = "2022-10-26 23:59:01"
// coupon._code = "123456789"
// let coupon2 = swiftApi.ActiveDFYCouponModel()
// coupon2._value = "23"
// coupon2._date = "2022-11-05 01:55"
// coupon2._code = "234567891"
// let coupon3 = swiftApi.ActiveDFYCouponModel()
// coupon3._value = "34"
// coupon3._date = "2022-07-01 01:55"
// coupon3._code = "345678912"
// let couponsArray: Array<swiftApi.ActiveDFYCouponModel> = [coupon, coupon2, coupon3, coupon3, coupon3]
// swiftApi().setActiveDFYCoupons(dfyCoupons: couponsArray)
// dfyCoupons = swiftApi().getActiveDFYCoupons()
// TODO: DELETE <===
// Add shadow
self.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
self.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
self.layer.shadowOpacity = 1.0
self.layer.shadowRadius = 1.0
activeCodeView.layer.cornerRadius = 16.5
// activeCodeView.layer.borderWidth = 1
// activeCodeView.layer.borderColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor
activeCodeImage.image = UIImage(named: "active_code_logo_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
if (dfyCoupons.count > 0) {
if (dfyCoupons.count == 1) {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
// dateFormatter.dateFormat = "yyyy-MM-dd HH:mm"
// sort dfyCoupons by date
dfyCoupons.sort(by: {
let date1 = dateFormatter.date(from: $0._date)
let date2 = dateFormatter.date(from: $1._date)
if ((date1 != nil) && (date2 != nil)) {
return date1!.compare(date2!) == .orderedAscending
} else {
return false
}
})
// Get days from now of the most recet coupon
var daysFromNow = ""
let calendar = Calendar.current
// Replace the hour (time) of both dates with 00:00
let date1 = calendar.startOfDay(for: Date())
if let date2 = dateFormatter.date(from: dfyCoupons[0]._date) {
let components = calendar.dateComponents([.day], from: date1, to: date2)
daysFromNow = (components.day) != nil ? String((components.day ?? 0) + 1) : ""
}
activeCodesCountLabel.text = "Ενεργός κωδικός:"
// activeCodeLabel.text = dfyCoupons[0]._code
let newLabel = CopyableLabel()
newLabel.text = String(dfyCoupons[0]._code)
newLabel.font = UIFont(name: "PeridotPE-Bold", size: 18)
newLabel.textColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)
newLabel.frame.size.width = newLabel.intrinsicContentSize.width
newLabel.frame.size.height = newLabel.intrinsicContentSize.height // tagHeight
activeCodeContentView.addSubview(newLabel)
// set the btn frame origin
newLabel.frame.origin.x = 0
newLabel.frame.origin.y = 0
let scrollHeight = newLabel.intrinsicContentSize.height
activeCodeContentViewHeight.constant = scrollHeight
activeCodeScrollViewHeight.constant = scrollHeight
activeCodeExpirationLabel.isHidden = false
if (daysFromNow == "1") {
activeCodeExpirationLabel.text = "Λήγει σε " + daysFromNow + " ημέρα"
} else {
activeCodeExpirationLabel.text = "Λήγει σε " + daysFromNow + " ημέρες"
}
} else {
var tagHeight:CGFloat = 30
let tagPadding: CGFloat = 0
let tagSpacingX: CGFloat = 0
let tagSpacingY: CGFloat = 2
let containerWidth = activeCodeContentView.frame.size.width
var currentOriginX: CGFloat = 0
var currentOriginY: CGFloat = 0
// var couponCodesString = ""
for (index, item) in dfyCoupons.enumerated() {
let newLabel = CopyableLabel()
newLabel.font = UIFont(name: "PeridotPE-Bold", size: 18)
newLabel.textColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)
if (index == (dfyCoupons.endIndex - 1)) {
// couponCodesString += String(item._code)
newLabel.text = String(item._code)
} else {
// couponCodesString += String(item._code) + ", "
newLabel.text = String(item._code) + ", "
}
newLabel.frame.size.width = newLabel.intrinsicContentSize.width + tagPadding
newLabel.frame.size.height = newLabel.intrinsicContentSize.height // tagHeight
tagHeight = newLabel.intrinsicContentSize.height
activeCodeContentView.addSubview(newLabel)
// if current X + label width will be greater than container view width
// "move to next row"
if currentOriginX + newLabel.frame.width > containerWidth {
currentOriginX = 0
currentOriginY += tagHeight + tagSpacingY
}
// set the btn frame origin
newLabel.frame.origin.x = currentOriginX
newLabel.frame.origin.y = currentOriginY
// increment current X by btn width + spacing
currentOriginX += newLabel.frame.width + tagSpacingX
}
activeCodesCountLabel.text = String(dfyCoupons.count) + " Ενεργοί κωδικοί:"
// activeCodeLabel.text = couponCodesString
activeCodeExpirationLabel.isHidden = true
// update container view height
activeCodeContentViewHeight.constant = currentOriginY + tagHeight
if ((currentOriginY + tagHeight) <= (2 * tagHeight + tagSpacingY)) {
activeCodeScrollViewHeight.constant = currentOriginY + tagHeight
} else {
activeCodeScrollViewHeight.constant = 2 * tagHeight + tagSpacingY
}
}
} else {
activeCodeLabel.text = "-"
activeCodeExpirationLabel.text = ""
activeCodeView.isHidden = true
activeCodeViewHeight.constant = 0
}
}
public override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
public override func layoutSubviews() {
super.layoutSubviews()
//set the values for top,left,bottom,right margins
let margins = UIEdgeInsets(top: 2, left: 0, bottom: 4, right: 0)
contentView.frame = contentView.frame.inset(by: margins)
}
}
//
// ActiveGiftsViewController.swift
// SwiftWarplyFramework
//
// Created by Βασιλης Σκουρας on 11/5/22.
//
import Foundation
import UIKit
@objc public class ActiveGiftsViewController: UIViewController {
@IBOutlet weak var couponButton: UIButton!
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.hidesBottomBarWhenPushed = true
setBackButton()
setNavigationTitle("Ενεργά δώρα")
}
@IBAction func navigateToCoupon(_ sender: Any) {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "CouponViewController") as! SwiftWarplyFramework.CouponViewController
self.navigationController?.pushViewController(vc, animated: true)
}
}
//
// AnalysisChildViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 18/7/22.
//
import UIKit
class AnalysisChildViewController: UITableViewController {
public var index: Int = -1
}
//
// AnalysisHeaderMessageViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 18/7/22.
//
import UIKit
class AnalysisHeaderMessageViewCell: UITableViewCell {
// attributes
@IBOutlet weak var itemImage: UIImageView!
@IBOutlet weak var messageLabelView: UIView!
@IBOutlet weak var messageLabel: UILabel!
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var emptyLabel: UILabel!
@IBOutlet weak var emptyLabelHeight: NSLayoutConstraint!
@IBOutlet weak var emptyLabelTopSpace: NSLayoutConstraint!
@IBOutlet weak var emptyLabelBottomSpace: NSLayoutConstraint!
public var loyaltyBadge:swiftApi.LoyaltyBadgeModel = swiftApi().getLoyaltyBadge()
// lifecycle
override func awakeFromNib() {
super.awakeFromNib()
// image
// itemImage.image = UIImage(named: "ic_gift_circle_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
// title
titleLabel.textColor = UIColor(rgb: 0x212121)
titleLabel.text = "Αναλυτικά:"
// message
messageLabel.textColor = UIColor(rgb: 0x212121)
// messageLabelView.layer.borderWidth = 1.0
// messageLabelView.layer.borderColor = UIColor(rgb: 0xE6E6E6).cgColor
messageLabelView.layer.cornerRadius = 16.5
messageLabelView.backgroundColor = .white
// messageLabel.text = "Μέχρι τώρα έχεις κερδίσει " + totalCouponDiscountString + "€ σε προσφορές από " + String(loyaltyBadge._couponCount) + " κουπόνια!"
}
}
extension AnalysisHeaderMessageViewCell {
func configureCell(isEmpty: Bool, isMarket: Bool) {
if (isEmpty == true) {
emptyLabel.isHidden = false
emptyLabelHeight.constant = 18.5
emptyLabelTopSpace.constant = 30.0
emptyLabelBottomSpace.constant = 10.0
} else {
emptyLabel.isHidden = true
emptyLabelHeight.constant = 0.0
emptyLabelTopSpace.constant = 0.0
emptyLabelBottomSpace.constant = 0.0
}
if (isMarket == true) {
itemImage.image = UIImage(named: "ic_history_market_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
let oldUnifiedCouponList: Array<swiftApi.CouponItemModel> = swiftApi().getOldUnifiedCouponList()
let oldUnifiedCouponListLength = oldUnifiedCouponList.count
var unifiedCouponsDiscount: Float = 0.0
for coupon in oldUnifiedCouponList {
if let discountFloat = Float(coupon.discount ?? "0.0") {
unifiedCouponsDiscount += discountFloat
}
}
let totalCouponDiscount = Float(round(100 * unifiedCouponsDiscount) / 100)
var totalCouponDiscountString = "0"
totalCouponDiscountString = String(format: "%.2f", totalCouponDiscount).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
let coupNormalText1 = "Μέχρι τώρα έχεις κερδίσει "
let coupBoldText = totalCouponDiscountString + "€"
let coupNormalText2 = " σε προσφορές από "
let coupBoldText2 = String(oldUnifiedCouponListLength)
let coupNormalText3 = " κουπόνια!"
let attrRegular = [NSAttributedString.Key.font : UIFont(name: "PeridotPE-Regular", size: 17) ?? UIFont.systemFont(ofSize: 16)]
let attrBold = [NSAttributedString.Key.font : UIFont(name: "PeridotPE-Bold", size: 17) ?? UIFont.boldSystemFont(ofSize: 16)]
let coupAttributedString = NSMutableAttributedString(string:coupNormalText1, attributes:attrRegular)
let coupBoldString = NSMutableAttributedString(string: coupBoldText, attributes:attrBold)
let coupNormalString2 = NSMutableAttributedString(string:coupNormalText2, attributes:attrRegular)
let coupBoldString2 = NSMutableAttributedString(string: coupBoldText2, attributes:attrBold)
let coupNormalString3 = NSMutableAttributedString(string:coupNormalText3, attributes:attrRegular)
coupAttributedString.append(coupBoldString)
coupAttributedString.append(coupNormalString2)
coupAttributedString.append(coupBoldString2)
coupAttributedString.append(coupNormalString3)
messageLabel.attributedText = coupAttributedString
} else {
itemImage.image = UIImage(named: "ic_gift_history", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
let totalCouponDiscount = Float(round(100 * loyaltyBadge._value) / 100)
var totalCouponDiscountString = "0"
totalCouponDiscountString = String(format: "%.2f", totalCouponDiscount).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
let coupNormalText1 = "Μέχρι τώρα έχεις κερδίσει "
let coupBoldText = totalCouponDiscountString + "€"
let coupNormalText2 = " σε προσφορές από "
let coupBoldText2 = String(loyaltyBadge._couponCount)
let coupNormalText3 = " κουπόνια!"
let attrRegular = [NSAttributedString.Key.font : UIFont(name: "PeridotPE-Regular", size: 17) ?? UIFont.systemFont(ofSize: 16)]
let attrBold = [NSAttributedString.Key.font : UIFont(name: "PeridotPE-Bold", size: 17) ?? UIFont.boldSystemFont(ofSize: 16)]
let coupAttributedString = NSMutableAttributedString(string:coupNormalText1, attributes:attrRegular)
let coupBoldString = NSMutableAttributedString(string: coupBoldText, attributes:attrBold)
let coupNormalString2 = NSMutableAttributedString(string:coupNormalText2, attributes:attrRegular)
let coupBoldString2 = NSMutableAttributedString(string: coupBoldText2, attributes:attrBold)
let coupNormalString3 = NSMutableAttributedString(string:coupNormalText3, attributes:attrRegular)
coupAttributedString.append(coupBoldString)
coupAttributedString.append(coupNormalString2)
coupAttributedString.append(coupBoldString2)
coupAttributedString.append(coupNormalString3)
messageLabel.attributedText = coupAttributedString
}
}
}
//
// AnalysisHeaderViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 18/7/22.
//
import UIKit
class AnalysisHeaderViewCell: UITableViewCell {
// attributes
@IBOutlet weak var itemImage: UIImageView!
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var emptyLabel: UILabel!
@IBOutlet weak var emptyLabelHeight: NSLayoutConstraint!
@IBOutlet weak var emptyLabelTopSpace: NSLayoutConstraint!
@IBOutlet weak var emptyLabelBottomSpace: NSLayoutConstraint!
// lifecycle
override func awakeFromNib() {
super.awakeFromNib()
// image
// itemImage.image = UIImage(named: "ic_gift_circle_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
// title
// titleLabel.textColor = UIColor(rgb: 0x435563)
// titleLabel.text = "Αναλυτικά:"
}
}
extension AnalysisHeaderViewCell {
func configureCell(isEmpty: Bool, isMarket: Bool) {
if (isEmpty == true) {
emptyLabel.isHidden = false
emptyLabelHeight.constant = 18.5
// emptyLabelTopSpace.constant = 30.0
emptyLabelBottomSpace.constant = 10.0
} else {
emptyLabel.isHidden = true
emptyLabelHeight.constant = 0.0
// emptyLabelTopSpace.constant = 0.0
emptyLabelBottomSpace.constant = 0.0
}
if (isMarket == true) {
itemImage.image = UIImage(named: "ic_history_market_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
} else {
itemImage.image = UIImage(named: "ic_gift_history", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
}
}
}
//
// AnalysisItem.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 18/7/22.
//
import UIKit
public class AnalysisItem: Codable {
// attributes
public var date: Date
public var image_url: String?
public var title: String?
public let subtitle: String?
public var price: Float
// initialization
public init() {
self.date = Date()
self.image_url = ""
self.title = ""
self.subtitle = ""
self.price = 4.0
}
}
//
// AnalysisItemViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 18/7/22.
//
import UIKit
class AnalysisItemViewCell: UITableViewCell {
@IBOutlet weak var dateLabel: UILabel!
@IBOutlet weak var itemImage: UIImageView!
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var priceLabel: UILabel!
@IBOutlet weak var subtitleLabel: UILabel!
var postImageURL: String? {
didSet {
if let url = postImageURL {
self.itemImage.image = UIImage() // UIImage(named: "loading")
UIImage.loadImageUsingCacheWithUrlString(url) { image in
// set the image only when we are still displaying the content for the image we finished downloading
if url == self.postImageURL {
self.itemImage.image = image
}
}
}
else {
self.itemImage.image = nil
}
}
}
// lifecycle
override func awakeFromNib() {
super.awakeFromNib()
// date
dateLabel.textColor = UIColor(rgb: 0x212121)
dateLabel.font = UIFont(name: "PeridotPE-Bold", size: 12.0)
// title
titleLabel.textColor = UIColor(rgb: 0x212121)
titleLabel.font = UIFont(name: "PeridotPE-Regular", size: 17.0)
// price
priceLabel.textColor = UIColor(rgb: 0x212121)
priceLabel.font = UIFont(name: "PeridotPE-Bold", size: 17.0)
// subtitle
// subtitleLabel.textColor = UIColor(rgb: 0x9D9D9C)
subtitleLabel.textColor = UIColor(rgb: 0x212121)
subtitleLabel.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)
}
}
func configureCell(item: swiftApi.CouponItemModel) {
// COUPONSET: desc, img_preview, name, terms, merchant_uuid
// COUPON: coupon, expiration, discount, status
// MERCHANT: _img_preview,_admin_name
let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList()
let couponSetData: swiftApi.CouponSetItemModel? = item.couponset_data
titleLabel.text = ""
// for merchant in merchantList {
// // if (merchant._uuid == couponSetData?.merchant_uuid) {
// 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;
// }
// }
let merchantDetails: swiftApi.MerchantModel? = item.merchant_details
self.postImageURL = merchantDetails?._img_preview
titleLabel.text = merchantDetails?._admin_name
dateLabel.text = item.redeemed ?? "" // expiration
// itemImage.load(link: couponSetData?.img_preview ?? "", placeholder: UIImage(), cache: URLCache())
// titleLabel.text = couponSetData?.name ?? ""
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 + "€"
subtitleLabel.text = "Έκπτωτικό κουπόνι"
// subtitleLabel.text = couponSetData?.short_description ?? ""
// OR
// let htmlText = couponSetData?.inner_text ?? ""
// subtitleLabel.text = htmlText.htmlToString
}
func configureCell(item: swiftApi.CouponItemModel, isMarket: Bool) {
// COUPONSET: desc, img_preview, name, terms, merchant_uuid
// COUPON: coupon, expiration, discount, status
// MERCHANT: _img_preview,_admin_name
let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList()
// let couponSetData: swiftApi.CouponSetItemModel? = item.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;
// }
// }
let merchantDetails: swiftApi.MerchantModel? = item.merchant_details
self.postImageURL = merchantDetails?._img_preview
titleLabel.text = merchantDetails?._admin_name
// titleLabel.text = item.name
// self.postImageURL = item.image
dateLabel.text = item.redeemed ?? ""
let priceFloat = Float(round(100 * (Float(item.discount ?? "0.0") ?? 0.0 )) / 100)
var priceString = "0"
priceString = String(format: "%.2f", priceFloat).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
priceLabel.text = priceString + "€"
subtitleLabel.text = "Έκπτωτικό κουπόνι"
// subtitleLabel.text = couponSetData?.short_description ?? ""
// OR
// let htmlText = couponSetData?.inner_text ?? ""
// subtitleLabel.text = htmlText.htmlToString
}
}
//
// AnalysisMoreViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 21/9/22.
//
import UIKit
@objc public class AnalysisMoreViewCell: UITableViewCell {
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var arrowImage: UIImageView!
// lifecycle
public override func awakeFromNib() {
super.awakeFromNib()
// title
titleLabel.font = UIFont(name: "PeridotPE-Bold", size: 15)
titleLabel.textColor = UIColor(rgb: 0x212121)
titleLabel.text = "Δες Περισσότερα"
arrowImage.image = UIImage(named: "ic_down_dark_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
}
}
//
// CSMButton.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 20/9/22.
//
import UIKit
// @IBDesignable
@objc public class CSMButton: UIButton {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
configure()
}
override init(frame: CGRect = .zero) {
super.init(frame: frame)
configure()
}
public override func prepareForInterfaceBuilder() {
super.prepareForInterfaceBuilder()
configure()
}
}
private extension CSMButton {
func configure() {
setImage(UIImage(named: "ic_directions", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 18)
setTitleColor(.white, for: .normal)
// backgroundColor = UIColor(rgb: 0x79BF14)
backgroundColor = UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00)
layer.cornerRadius = 12.0
imageEdgeInsets = UIEdgeInsets(top:0.0, left:0.0, bottom:0.0, right:5.0);
titleEdgeInsets = UIEdgeInsets(top:0.0, left:5.0, bottom:0.0, right:0.0);
}
}
//
// CampaignCategory.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 11/10/22.
//
import Foundation
public class CampaignCategory: Codable {
// attributes
public var name: String?
public var index: Int
public var items: Array<swiftApi.CampaignItemModel>
// initialization
public init(_ name: String) {
self.name = name == "ΑΛΛΕΣ" ? name : String(name.dropFirst())
self.index = Int(name.prefix(1)) ?? 0
self.items = [swiftApi.CampaignItemModel]()
}
public init(_ name: String, index: Int) {
self.name = name == "ΑΛΛΕΣ" ? name : String(name.dropFirst())
self.index = index
self.items = [swiftApi.CampaignItemModel]()
}
}
enum CampaignCategoryFactory {
static func create(withTitle title: String) -> CampaignCategory {
var index = 100
let indexChr:Character = title[title.index(title.startIndex, offsetBy: 1)]
if indexChr.isNumber {
index = indexChr.wholeNumberValue!
}
return CampaignCategory(title, index: index)
}
}
//
// CopyableLabel.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 26/10/22.
//
import Foundation
import UIKit
class CopyableLabel: UILabel {
override init(frame: CGRect) {
super.init(frame: frame)
sharedInit()
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)!
sharedInit()
}
func sharedInit() {
isUserInteractionEnabled = true
addGestureRecognizer(UILongPressGestureRecognizer(target: self, action: #selector(showMenu(sender:))))
}
@objc
func showMenu(sender: AnyObject?) {
becomeFirstResponder()
let menu = UIMenuController.shared
if !menu.isMenuVisible {
menu.setTargetRect(bounds, in: self)
menu.setMenuVisible(true, animated: true)
}
}
override var canBecomeFirstResponder: Bool {
return true
}
override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
if action == #selector(UIResponderStandardEditActions.copy(_:)) {
return true
}
return false
}
override func copy(_ sender: Any?) {
let board = UIPasteboard.general
if var textToCopy = text {
if (textToCopy.contains(", ")) {
textToCopy = textToCopy.replacingOccurrences(of: ", ", with: "")
}
print(textToCopy)
board.string = textToCopy
}
// board.string = text
let menu = UIMenuController.shared
menu.setMenuVisible(false, animated: true)
}
}
//
// CouponsViewController.swift
// WarplySDKFrameworkIOS
//
// Created by Βασιλης Σκουρας on 4/5/22.
//
import Foundation
import UIKit
import SwiftEventBus
@objc public class CouponsViewController: UIViewController {
@IBOutlet weak var backgroundImage: UIImageView!
@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var emptyView: UIView!
@IBOutlet weak var emptyViewHeight: NSLayoutConstraint!
@IBOutlet weak var emptyLabel: UILabel!
public var coupons:Array<swiftApi.CouponItemModel> = []
public override func viewDidLoad() {
super.viewDidLoad()
self.hidesBottomBarWhenPushed = true
SwiftEventBus.onBackgroundThread(self, name: "coupons_fetched") { result in
DispatchQueue.main.async {
self.coupons = swiftApi().getCouponList()
self.tableView.reloadData()
self.handleEmptyView()
}
}
getCouponsRequest()
setBackButton()
// setNavigationTitle("GIFTS FOR YOU")
setNavigationTitle("FREE COUPONS")
// backgroundImage.image = UIImage(named: "coupons_scrollview_dark", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
tableView.delegate = self
tableView.dataSource = self
// tableView.clipsToBounds = true
// tableView.layer.cornerRadius = 30
// tableView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius
tableView.contentInset.top = 30
emptyLabel.text = "Αυτήν τη στιγμή δεν έχεις κάποιο ενεργό κουπόνι. Στην ενότητα FOR YOU μπορείς να βρεις κουπόνια αποκλειστικά για σένα!"
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
swiftApi().logTrackersEvent("screen", "ActiveCouponsScreen")
self.coupons = swiftApi().getCouponList()
self.tableView.reloadData()
self.handleEmptyView()
self.navigationController?.hideHairline()
}
// MARK: - Functions
func handleEmptyView() {
if (self.coupons.count == 0) {
self.emptyView.isHidden = false
self.emptyViewHeight.constant = self.emptyView.intrinsicContentSize.height
} else {
self.emptyView.isHidden = true
self.emptyViewHeight.constant = 0
}
}
// MARK: - API Functions
func getCouponsRequest() {
swiftApi().getCouponsAsync(getCouponsCallback, failureCallback: {errorCode in
self.coupons = []
})
}
func getCouponsCallback (_ couponsData: Array<swiftApi.CouponItemModel>?) -> Void {
if (couponsData != nil) {
let activeCouponData = swiftApi().filterActiveCoupons(couponsData ?? [])
self.coupons = activeCouponData
DispatchQueue.main.async {
SwiftEventBus.post("coupons_fetched")
// self.tableView.reloadData()
// self.handleEmptyView()
}
} else {
self.coupons = []
}
}
}
// MARK: - TableView
extension CouponsViewController: UITableViewDelegate, UITableViewDataSource{
public func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.coupons.count
}
public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 130.0 + 8.0
// return UITableViewAutomaticDimension
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CouponsTableViewCellId", for: indexPath) as! CouponsTableViewCell
cell.configureCell(coupon: coupons[indexPath.row])
return cell
}
public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
// SwiftEventBus.post("couponBarcodePressed", sender: coupons[indexPath.row])
// Logs
let couponSetData: swiftApi.CouponSetItemModel? = coupons[indexPath.row].couponset_data
print("Coupon clicked: " + (coupons[indexPath.row].coupon ?? ""))
print("Coupon Name clicked: " + (couponSetData?.name ?? ""))
print("Coupon Description clicked: " + (couponSetData?.short_description ?? ""))
print("Coupon Expiration clicked: " + (coupons[indexPath.row].expiration ?? ""))
swiftApi().logTrackersEvent("click", ("Coupon:" + (couponSetData?.name ?? "")))
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "CouponBarcodeViewController") as! SwiftWarplyFramework.CouponBarcodeViewController
vc.coupon = coupons[indexPath.row]
self.navigationController?.pushViewController(vc, animated: true)
}
}
//
// DetailsViewController.swift
// WarplySDKFrameworkIOS
//
// Created by Βασιλης Σκουρας on 5/5/22.
//
import Foundation
import UIKit
@objc public class DetailsViewController: UIViewController {
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.hidesBottomBarWhenPushed = true
setBackButton()
setNavigationTitle("Ανάλυση")
}
}
//
// HistoryViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 18/7/22.
//
import UIKit
class HistoryViewController: AnalysisChildViewController {
var loading: Bool = false
var items: Array<swiftApi.CouponItemModel> = swiftApi().getOldCouponList()
var showMore = false
// TODO: remove this when configuring model
let hasMessage = true
// lifecycle
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.delegate = self
self.tableView.dataSource = self
// Add shadow
self.tableView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
self.tableView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
self.tableView.layer.shadowOpacity = 1.0
self.tableView.layer.shadowRadius = 1.0
self.refreshControl = UIRefreshControl()
self.refreshControl?.addTarget(self, action: #selector(handleRefresh(_:)), for: .valueChanged)
handleRefresh(self.refreshControl!)
}
// mvp
@objc func load() {
if (loading) {
return;
}
showLoading()
items = swiftApi().getOldCouponList()
self.showMore = (self.items.count > 3)
if (self.showMore == true) {
self.items = Array(self.items[0...2])
}
showContent()
self.tableView.reloadData()
}
private func showLoading() {
loading = true
if (self.refreshControl!.isRefreshing) {
return;
}
self.refreshControl!.beginRefreshing()
}
private func showError() {
}
private func showContent() {
loading = false
self.refreshControl!.endRefreshing()
}
// private
func responseCallback (_ data: Array<swiftApi.CouponItemModel>?) -> Void {
self.items = data!
self.showMore = (self.items.count > 3)
if (self.showMore == true) {
self.items = Array(self.items[0...2])
}
showContent()
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
@objc func handleRefresh(_ refreshControl: UIRefreshControl) {
self.perform(_: #selector(load), with: nil, afterDelay: 0.5)
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
return 2
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if (section == 0) {
return 1
}
if (self.showMore == true) {
return 4
}
return items.count
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
// if (indexPath.section == 0) {
//// return hasMessage ? (items.count > 0 ? 380.0 : 480.0) : 280
// return hasMessage ? UITableView.automaticDimension : 280
// }
//
//// return 140.0
return UITableView.automaticDimension
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// header
if (indexPath.section == 0) {
if (hasMessage) {
let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisHeaderMessageViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisHeaderMessageViewCell
cell.configureCell(isEmpty: items.count == 0, isMarket: false)
return cell
}
return tableView.dequeueReusableCell(withIdentifier: "AnalysisHeaderViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisHeaderViewCell
}
if (self.showMore && indexPath.row == 3) {
let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisMoreViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisMoreViewCell
return cell
}
let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisItemViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisItemViewCell
cell.configureCell(item: items[indexPath.row])
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if (indexPath.section == 0) {
return
}
if (self.showMore && indexPath.row == 3) {
self.items = swiftApi().getOldCouponList()
self.showMore = false
self.tableView.reloadData()
}
}
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if (section == 0){
return nil
} else if (section == 1) {
if (self.items.count > 0) {
let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 50))
let viewBorder = UIView(frame: CGRect(x: 10, y: 0, width: view.frame.width-20, height: view.frame.height))
viewBorder.backgroundColor = .white
// viewBorder.backgroundColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00)
viewBorder.layer.cornerRadius = 16.5
viewBorder.layer.maskedCorners = [ .layerMinXMinYCorner, .layerMaxXMinYCorner] // Top left, bottom right corner radius
let viewInner = UIView(frame: CGRect(x: 1, y: 1, width: viewBorder.frame.width-2, height: viewBorder.frame.height-1))
viewInner.backgroundColor = .white
viewInner.layer.cornerRadius = 16.5
viewInner.layer.maskedCorners = [ .layerMinXMinYCorner, .layerMaxXMinYCorner] // Top left, bottom right corner radius
let titleLabel = UILabel(frame: CGRect(x: 20, y: 20, width: viewInner.frame.width - 40, height: 20))
titleLabel.font = UIFont(name: "BTCosmo-Bold", size: 20)
titleLabel.textColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)
titleLabel.text = "Αναλυτικά"
view.addSubview(viewBorder)
viewBorder.addSubview(viewInner)
viewInner.addSubview(titleLabel)
return view
} else {
return nil
}
} else {
return nil
}
}
override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if (section == 0) {
return 0.0
} else if (section == 1) {
if (self.items.count > 0) {
return 50.0
} else {
return 0.0
}
} else {
return 0.0
}
}
override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
// return CGFloat.leastNormalMagnitude
if (section == 1 && self.items.count > 0) {
return 20.0
} else {
return 0.0
}
}
override func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
if (section == 1) {
if (self.items.count > 0) {
let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 30))
let viewBorder = UIView(frame: CGRect(x: 10, y: 0, width: view.frame.width-20, height: view.frame.height))
viewBorder.backgroundColor = .white
// viewBorder.backgroundColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00)
viewBorder.layer.cornerRadius = 16.5
viewBorder.layer.maskedCorners = [ .layerMinXMaxYCorner, .layerMaxXMaxYCorner] // bottom left, bottom right corner radius
let viewInner = UIView(frame: CGRect(x: 1, y: 0, width: viewBorder.frame.width-2, height: viewBorder.frame.height-1))
viewInner.backgroundColor = .white
viewInner.layer.cornerRadius = 16.5
viewInner.layer.maskedCorners = [ .layerMinXMaxYCorner, .layerMaxXMaxYCorner] // bottom left, bottom right corner radius
view.addSubview(viewBorder)
viewBorder.addSubview(viewInner)
return view
} else {
return nil
}
} else {
return nil
}
}
}
//
// InboxTableViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 24/6/22.
//
import UIKit
@objc public class InboxTableViewCell: UITableViewCell {
@IBOutlet weak var inboxView: UIView!
@IBOutlet weak var campaignImage: UIImageView!
@IBOutlet weak var newBadgeImage: UIImageView!
@IBOutlet weak var campaignTitleLabel: UILabel!
var postImageURL: String? {
didSet {
if let url = postImageURL {
self.campaignImage.image = UIImage() // UIImage(named: "loading")
UIImage.loadImageUsingCacheWithUrlString(url) { image in
// set the image only when we are still displaying the content for the image we finished downloading
if url == self.postImageURL {
self.campaignImage.image = image
}
}
}
else {
self.campaignImage.image = nil
}
}
}
public override func awakeFromNib() {
super.awakeFromNib()
// Add shadow
self.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
self.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
self.layer.shadowOpacity = 1.0
self.layer.shadowRadius = 1.0
inboxView.layer.cornerRadius = 16.0
inboxView.clipsToBounds = true
newBadgeImage.image = UIImage(named: "new_icon_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
newBadgeImage.isHidden = true
}
public override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
public override func layoutSubviews() {
super.layoutSubviews()
//set the values for top,left,bottom,right margins
let margins = UIEdgeInsets(top: 0, left: 0, bottom: 10, right: 0)
contentView.frame = contentView.frame.inset(by: margins)
}
func configureCell(campaign: swiftApi.CampaignItemModel) {
// campaignImage.load(link: campaign.logo_url ?? "", placeholder: UIImage(), cache: URLCache())
self.postImageURL = campaign.logo_url ?? ""
campaignTitleLabel.text = campaign.title ?? ""
if (campaign.is_new == true) {
newBadgeImage.isHidden = false
} else{
newBadgeImage.isHidden = true
}
}
func configureCell(ccms: swiftApi.LoyaltyContextualOfferModel) {
// campaignImage.load(link: ccms._imageUrl , placeholder: UIImage(), cache: URLCache())
self.postImageURL = ccms._imageUrl
campaignTitleLabel.text = ccms._title
newBadgeImage.isHidden = true
}
}
//
// LoyaltyAnalysisViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 18/7/22.
//
import UIKit
import SwiftEventBus
@objc public class LoyaltyAnalysisViewController: UIViewController {
@IBOutlet weak var leftButton: UIButton!
@IBOutlet weak var rightButton: UIButton!
@IBOutlet weak var leftLineView: UIView!
@IBOutlet weak var rightLineView: UIView!
@IBOutlet weak var contentView: UIView!
var pageController: UIPageViewController!
var tabSelected = 0
var timerHistory: DispatchSourceTimer?
var seconds: Int = 0
public override func viewDidLoad() {
super.viewDidLoad()
self.hidesBottomBarWhenPushed = true
// setup view
setBackButton()
setNavigationTitle("Ανάλυση")
// tab
leftButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 15)
leftButton.setTitle("Εξαργυρωμένα", for:.normal)
leftButton.backgroundColor = . clear
leftButton.setTitleColor(UIColor(rgb: 0x212121), for:.normal)
rightButton.titleLabel?.font = UIFont(name: "PeridotPE-SBold", size: 15)
rightButton.setTitle("Μοιρασμένα δώρα", for:.normal)
rightButton.backgroundColor = . clear
rightButton.setTitleColor(UIColor(rgb: 0x848484), for:.normal)
// leftLineView.applyGradient(colours: [UIColor(rgb: 0x1DA6B9), UIColor(rgb: 0xB2CE69)], gradient: GradientOrientation.horizontal, cornerRadius: 0.0)
// rightLineView.applyGradient(colours: [UIColor(rgb: 0x1DA6B9), UIColor(rgb: 0xB2CE69)], gradient: GradientOrientation.horizontal, cornerRadius: 0.0)
leftLineView.isHidden = false
rightLineView.isHidden = true
// pages
pageController = UIPageViewController(transitionStyle:.scroll, navigationOrientation:.horizontal)
pageController.dataSource = self;
pageController.delegate = self;
pageController.view.frame = contentView.bounds;
addChild(pageController)
contentView.addSubview(pageController.view)
pageController .didMove(toParent: self)
let analysisVC = self.viewControllerAt(0)
pageController.setViewControllers([analysisVC!], direction:.forward, animated:false)
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
swiftApi().logTrackersEvent("screen", "LoyaltyHistoryScreen")
self.startTimer()
self.navigationController?.hideHairline()
}
public override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
self.stopTimer()
}
// MARK: - Functions
func startTimer() {
print("========= GiftsCalculator Timer Started! =========")
let queue = DispatchQueue(label: Bundle.main.bundleIdentifier! + ".history.timer")
timerHistory = DispatchSource.makeTimerSource(queue: queue)
timerHistory!.schedule(deadline: .now(), repeating: .seconds(1))
timerHistory!.setEventHandler { [weak self] in
// do whatever stuff you want on the background queue here here
print("========= GiftsCalculator interval! =========")
DispatchQueue.main.async {
// update your model objects and/or UI here
self?.seconds = (self?.seconds ?? 0) + 1
}
}
timerHistory!.resume()
}
func stopTimer() {
print("========= GiftsCalculator Timer Stopped! =========")
timerHistory?.cancel()
timerHistory = nil
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "time_spent_on_loyalty_sdk"
firebaseEvent.setParameter = ("name", "GiftsCalculator")
firebaseEvent.setParameter = ("seconds", String(seconds))
SwiftEventBus.post("firebase", sender: firebaseEvent)
seconds = 0
}
////////////////////////////////////////////////////////////////////////////////
private func viewControllerAt(_ index:Int) -> AnalysisChildViewController?
{
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
if (index == 1) {
swiftApi().logTrackersEvent("click", ("LoyaltyHistoryScreen:" + "TabShared"))
let analysisVC = storyboard.instantiateViewController(withIdentifier:"SharingHistoryViewController") as! SwiftWarplyFramework.SharingHistoryViewController
analysisVC.index = index;
return analysisVC;
}
swiftApi().logTrackersEvent("click", ("LoyaltyHistoryScreen:" + "TabExpired"))
let analysisVC = storyboard.instantiateViewController(withIdentifier:"HistoryViewController") as! SwiftWarplyFramework.HistoryViewController
analysisVC.index = index;
return analysisVC;
}
// MARK: - Handlers
@IBAction func handleLeft() {
if (tabSelected != 0) {
self.tabSelected = 0
UIView.animate(withDuration: 2.0, delay: 0.0) {
self.leftLineView.isHidden = false
self.rightLineView.isHidden = true
self.leftButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 15)
self.rightButton.titleLabel?.font = UIFont(name: "PeridotPE-SBold", size: 15)
self.leftButton.setTitleColor(UIColor(rgb: 0x212121), for:.normal)
self.rightButton.setTitleColor(UIColor(rgb: 0x848484), for:.normal)
}
let analysisVC = self.viewControllerAt(0)
pageController.setViewControllers([analysisVC!], direction:.reverse, animated:true)
}
}
@IBAction func handleRight() {
if (tabSelected != 1) {
self.tabSelected = 1
UIView.animate(withDuration: 2.0, delay: 0.0) {
self.leftLineView.isHidden = true
self.rightLineView.isHidden = false
self.leftButton.titleLabel?.font = UIFont(name: "PeridotPE-SBold", size: 15)
self.rightButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 15)
self.rightButton.setTitleColor(UIColor(rgb: 0x212121), for:.normal)
self.leftButton.setTitleColor(UIColor(rgb: 0x848484), for:.normal)
}
let analysisVC = self.viewControllerAt(1)
pageController.setViewControllers([analysisVC!], direction:.forward, animated:true)
}
}
}
// MARK: - PageViewController
extension LoyaltyAnalysisViewController: UIPageViewControllerDataSource, UIPageViewControllerDelegate {
public func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
if let analysisVC = viewController as? AnalysisChildViewController {
var index = analysisVC.index
if (index == 0) {
return nil;
}
index -= 1;
return viewControllerAt(index);
}
return nil;
}
public func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
if let analysisVC = viewController as? AnalysisChildViewController {
var index = analysisVC.index
if (index == 1) {
return nil;
}
index += 1;
return viewControllerAt(index);
}
return nil;
}
public func pageViewController(_ pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool) {
if (!completed) {
return;
}
if let childVCs = pageViewController.viewControllers as? [AnalysisChildViewController] {
let currentIndex = childVCs[0].index
if (currentIndex == 0) {
self.leftButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 15)
self.rightButton.titleLabel?.font = UIFont(name: "PeridotPE-SBold", size: 15)
self.leftButton.setTitleColor(UIColor(rgb: 0x212121), for:.normal)
self.rightButton.setTitleColor(UIColor(rgb: 0x848484), for:.normal)
self.tabSelected = 0
self.leftLineView.isHidden = false
self.rightLineView.isHidden = true
} else {
self.leftButton.titleLabel?.font = UIFont(name: "PeridotPE-SBold", size: 15)
self.rightButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 15)
self.rightButton.setTitleColor(UIColor(rgb: 0x212121), for:.normal)
self.leftButton.setTitleColor(UIColor(rgb: 0x848484), for:.normal)
self.tabSelected = 1
self.leftLineView.isHidden = true
self.rightLineView.isHidden = false
}
}
}
}
//
// MFYInboxTableViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 24/6/22.
//
import UIKit
@objc public class MFYInboxTableViewCell: UITableViewCell {
@IBOutlet weak var inboxView: UIView!
@IBOutlet weak var campaignImage: UIImageView!
@IBOutlet weak var newBadgeImage: UIImageView!
@IBOutlet weak var campaignTitleLabel: UILabel!
@IBOutlet weak var curvedBgImage: UIImageView!
@IBOutlet weak var subtitleLabel: UILabel!
@IBOutlet weak var descriptionLabel: UILabel!
var postImageURL: String? {
didSet {
if let url = postImageURL {
self.campaignImage.image = UIImage() // UIImage(named: "loading")
UIImage.loadImageUsingCacheWithUrlString(url) { image in
// set the image only when we are still displaying the content for the image we finished downloading
if url == self.postImageURL {
self.campaignImage.image = image
}
}
}
else {
self.campaignImage.image = nil
}
}
}
public override func awakeFromNib() {
super.awakeFromNib()
// inboxView.layer.cornerRadius = 5.0
// inboxView.clipsToBounds = true
// Add shadow
self.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
self.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
self.layer.shadowOpacity = 1.0
self.layer.shadowRadius = 1.0
newBadgeImage.image = UIImage(named: "new_icon_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
curvedBgImage.image = UIImage(named: "curved_bg_white_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
newBadgeImage.isHidden = true
}
public override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
public override func layoutSubviews() {
super.layoutSubviews()
//set the values for top,left,bottom,right margins
let margins = UIEdgeInsets(top: 0, left: 0, bottom: 10, right: 0)
contentView.frame = contentView.frame.inset(by: margins)
// Add different corner radius - Do it here, otherwise it won't be applied to all cells
inboxView.roundCorners(topLeft: 20, topRight: 45, bottomLeft: 20, bottomRight: 0)
// // Delete extra borderLayers added
// for layer in (inboxView.layer.sublayers ?? []) {
// if(layer.name == "MFYItemBorderLayer"){
// layer.removeFromSuperlayer()
// }
// }
//
// // Add borderLayer
// let borderLayer = CAShapeLayer()
// borderLayer.path = (inboxView.layer.mask! as! CAShapeLayer).path! // Reuse the Bezier path
// borderLayer.strokeColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor
// borderLayer.fillColor = UIColor.clear.cgColor
// borderLayer.lineWidth = 1
// borderLayer.frame = inboxView.bounds
// borderLayer.name = "MFYItemBorderLayer"
// inboxView.layer.addSublayer(borderLayer)
}
func configureCell(campaign: swiftApi.CampaignItemModel) {
// campaignImage.load(link: campaign.logo_url ?? "", placeholder: UIImage(), cache: URLCache())
self.postImageURL = campaign.logo_url ?? ""
campaignTitleLabel.text = campaign.title ?? ""
campaignTitleLabel.font = UIFont(name: "BTCosmo-Bold", size: 17)
subtitleLabel.text = campaign.subtitle ?? ""
subtitleLabel.font = UIFont(name: "PeridotPE-Regular", size: 15)
descriptionLabel.text = campaign.message ?? ""
descriptionLabel.font = UIFont(name: "PeridotPE-SBold", size: 15)
if (campaign.is_new == true) {
newBadgeImage.isHidden = false
} else{
newBadgeImage.isHidden = true
}
}
func configureCell(ccms: swiftApi.LoyaltyContextualOfferModel) {
// campaignImage.load(link: ccms._imageUrl , placeholder: UIImage(), cache: URLCache())
self.postImageURL = ccms._imageUrl
campaignTitleLabel.text = ccms._title
campaignTitleLabel.font = UIFont(name: "BTCosmo-Bold", size: 17)
subtitleLabel.text = ccms._subtitle
subtitleLabel.font = UIFont(name: "PeridotPE-Regular", size: 15)
descriptionLabel.text = ccms._description
descriptionLabel.font = UIFont(name: "PeridotPE-SBold", size: 15)
newBadgeImage.isHidden = true
}
}
This diff could not be displayed because it is too large.
//
// MakeItAPresentViewController.swift
// SwiftWarplyFramework
//
// Created by Βασιλης Σκουρας on 11/5/22.
//
import Foundation
import UIKit
@objc public class MakeItAPresentViewController: UIViewController {
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.hidesBottomBarWhenPushed = true
setBackButton()
setNavigationTitle("Κάνε δώρο")
}
}
//
// MarketAnalysisItemViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 14/1/25.
//
import UIKit
class MarketAnalysisItemViewCell: UITableViewCell {
@IBOutlet weak var dateLabel: UILabel!
@IBOutlet weak var itemImage: UIImageView!
@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 {
self.itemImage.image = UIImage() // UIImage(named: "loading")
UIImage.loadImageUsingCacheWithUrlString(url) { image in
// set the image only when we are still displaying the content for the image we finished downloading
if url == self.postImageURL {
self.itemImage.image = image
}
}
}
else {
self.itemImage.image = nil
}
}
}
// lifecycle
override func awakeFromNib() {
super.awakeFromNib()
// date
dateLabel.textColor = UIColor(rgb: 0x212121)
dateLabel.font = UIFont(name: "PeridotPE-Bold", size: 12.0)
// title
titleLabel.textColor = UIColor(rgb: 0x212121)
titleLabel.font = UIFont(name: "PeridotPE-SBold", size: 17.0)
// price
priceLabel.textColor = UIColor(rgb: 0x212121)
priceLabel.font = UIFont(name: "PeridotPE-Bold", size: 17.0)
// subtitle
// subtitleLabel.textColor = UIColor(rgb: 0x9D9D9C)
subtitleLabel.textColor = UIColor(rgb: 0x212121)
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 MarketAnalysisItemViewCell {
func configureCell(item: swiftApi.CouponItemModel) {
// COUPONSET: desc, img_preview, name, terms, merchant_uuid
// COUPON: coupon, expiration, discount, status
// MERCHANT: _img_preview,_admin_name
let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList()
let couponSetData: swiftApi.CouponSetItemModel? = item.couponset_data
titleLabel.text = ""
// for merchant in merchantList {
// // if (merchant._uuid == couponSetData?.merchant_uuid) {
// 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;
// }
// }
let merchantDetails: swiftApi.MerchantModel? = item.merchant_details
self.postImageURL = merchantDetails?._img_preview
titleLabel.text = merchantDetails?._admin_name
dateLabel.text = item.redeemed ?? "" // expiration
// itemImage.load(link: couponSetData?.img_preview ?? "", placeholder: UIImage(), cache: URLCache())
// titleLabel.text = couponSetData?.name ?? ""
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 + "€"
// subtitleLabel.text = "Έκπτωτικό κουπόνι"
subtitleLabel.text = item.redeemed_merchant_details?._name ?? ""
// 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) {
// COUPONSET: desc, img_preview, name, terms, merchant_uuid
// COUPON: coupon, expiration, discount, status
// MERCHANT: _img_preview,_admin_name
let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList()
// let couponSetData: swiftApi.CouponSetItemModel? = item.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;
// }
// }
let merchantDetails: swiftApi.MerchantModel? = item.merchant_details
self.postImageURL = merchantDetails?._img_preview
titleLabel.text = merchantDetails?._admin_name
// titleLabel.text = item.name
// self.postImageURL = item.image
dateLabel.text = item.redeemed ?? ""
let priceFloat = Float(round(100 * (Float(item.discount ?? "0.0") ?? 0.0 )) / 100)
var priceString = "0"
priceString = String(format: "%.2f", priceFloat).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
priceLabel.text = priceString + "€"
// subtitleLabel.text = "Έκπτωτικό κουπόνι"
subtitleLabel.text = item.redeemed_merchant_details?._name ?? ""
// subtitleLabel.text = couponSetData?.short_description ?? ""
// OR
// let htmlText = couponSetData?.inner_text ?? ""
// subtitleLabel.text = htmlText.htmlToString
}
}
//
// MarketHistoryViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 5/4/23.
//
import UIKit
class MarketHistoryViewController: AnalysisChildViewController {
var loading: Bool = false
var items: Array<swiftApi.CouponItemModel> = swiftApi().getOldUnifiedCouponList()
var showMore = false
// TODO: remove this when configuring model
let hasMessage = true
// lifecycle
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.delegate = self
self.tableView.dataSource = self
// Add shadow
self.tableView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
self.tableView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
self.tableView.layer.shadowOpacity = 1.0
self.tableView.layer.shadowRadius = 1.0
self.refreshControl = UIRefreshControl()
self.refreshControl?.addTarget(self, action: #selector(handleRefresh(_:)), for: .valueChanged)
handleRefresh(self.refreshControl!)
}
// mvp
@objc func load() {
if (loading) {
return;
}
showLoading()
// items = swiftApi().getOldUnifiedCouponList()
items = swiftApi().getOldUnifiedCouponList()
self.showMore = (self.items.count > 3)
if (self.showMore == true) {
self.items = Array(self.items[0...2])
}
showContent()
self.tableView.reloadData()
}
private func showLoading() {
loading = true
if (self.refreshControl!.isRefreshing) {
return;
}
self.refreshControl!.beginRefreshing()
}
private func showError() {
}
private func showContent() {
loading = false
self.refreshControl!.endRefreshing()
}
// private
func responseCallback (_ data: Array<swiftApi.CouponItemModel>?) -> Void {
self.items = data!
self.showMore = (self.items.count > 3)
if (self.showMore == true) {
self.items = Array(self.items[0...2])
}
showContent()
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
@objc func handleRefresh(_ refreshControl: UIRefreshControl) {
self.perform(_: #selector(load), with: nil, afterDelay: 0.5)
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
return 2
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if (section == 0) {
return 1
}
if (self.showMore == true) {
return 4
}
return items.count
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
// if (indexPath.section == 0) {
// return hasMessage ? (items.count > 0 ? 380.0 : 480.0) : 280
// }
//
// return 140.0
return UITableView.automaticDimension
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// header
if (indexPath.section == 0) {
if (hasMessage) {
let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisHeaderMessageViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisHeaderMessageViewCell
cell.configureCell(isEmpty: items.count == 0, isMarket: true)
return cell
}
return tableView.dequeueReusableCell(withIdentifier: "AnalysisHeaderViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisHeaderViewCell
}
if (self.showMore && indexPath.row == 3) {
let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisMoreViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisMoreViewCell
return cell
}
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])
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if (indexPath.section == 0) {
return
}
if (self.showMore && indexPath.row == 3) {
self.items = swiftApi().getOldUnifiedCouponList()
self.showMore = false
self.tableView.reloadData()
}
}
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if (section == 0){
return nil
} else if (section == 1) {
if (self.items.count > 0) {
let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 50))
let viewBorder = UIView(frame: CGRect(x: 10, y: 0, width: view.frame.width-20, height: view.frame.height))
viewBorder.backgroundColor = .white
// viewBorder.backgroundColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00)
viewBorder.layer.cornerRadius = 16.5
viewBorder.layer.maskedCorners = [ .layerMinXMinYCorner, .layerMaxXMinYCorner] // Top left, bottom right corner radius
let viewInner = UIView(frame: CGRect(x: 1, y: 1, width: viewBorder.frame.width-2, height: viewBorder.frame.height-1))
viewInner.backgroundColor = .white
viewInner.layer.cornerRadius = 16.5
viewInner.layer.maskedCorners = [ .layerMinXMinYCorner, .layerMaxXMinYCorner] // Top left, bottom right corner radius
let titleLabel = UILabel(frame: CGRect(x: 20, y: 20, width: viewInner.frame.width - 40, height: 20))
titleLabel.font = UIFont(name: "BTCosmo-Bold", size: 20)
titleLabel.textColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)
titleLabel.text = "Αναλυτικά"
view.addSubview(viewBorder)
viewBorder.addSubview(viewInner)
viewInner.addSubview(titleLabel)
return view
} else {
return nil
}
} else {
return nil
}
}
override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if (section == 0) {
return 0.0
} else if (section == 1) {
if (self.items.count > 0) {
return 50.0
} else {
return 0.0
}
} else {
return 0.0
}
}
override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
// return CGFloat.leastNormalMagnitude
if (section == 1 && self.items.count > 0) {
return 20.0
} else {
return 0.0
}
}
override func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
if (section == 1) {
if (self.items.count > 0) {
let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 30))
let viewBorder = UIView(frame: CGRect(x: 10, y: 0, width: view.frame.width-20, height: view.frame.height))
viewBorder.backgroundColor = .white
// viewBorder.backgroundColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00)
viewBorder.layer.cornerRadius = 16.5
viewBorder.layer.maskedCorners = [ .layerMinXMaxYCorner, .layerMaxXMaxYCorner] // bottom left, bottom right corner radius
let viewInner = UIView(frame: CGRect(x: 1, y: 0, width: viewBorder.frame.width-2, height: viewBorder.frame.height-1))
viewInner.backgroundColor = .white
viewInner.layer.cornerRadius = 16.5
viewInner.layer.maskedCorners = [ .layerMinXMaxYCorner, .layerMaxXMaxYCorner] // bottom left, bottom right corner radius
view.addSubview(viewBorder)
viewBorder.addSubview(viewInner)
return view
} else {
return nil
}
} else {
return nil
}
}
}
//
// MarketPassInfoViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 14/1/25.
//
import UIKit
@objc public class MarketPassInfoViewController: UIViewController {
@IBOutlet weak var heroImage: UIImageView!
@IBOutlet weak var heroTitleLabel: UILabel!
@IBOutlet weak var storeInfoImage: UIImageView!
@IBOutlet weak var storeInfoTitleLabel: UILabel!
@IBOutlet weak var storeInfoSubtitleLabel: UILabel!
@IBOutlet weak var eshopInfoImage: UIImageView!
@IBOutlet weak var eshopInfoTitleLabel: UILabel!
@IBOutlet weak var eshopInfoSubtitleLabel: UILabel!
@IBOutlet weak var abInfoImage: UIImageView!
@IBOutlet weak var abInfoTitleLabel: UILabel!
@IBOutlet weak var abInfoSubtitleLabel: UILabel!
@IBOutlet weak var okButton: UIButton!
public override func viewDidLoad() {
super.viewDidLoad()
self.hidesBottomBarWhenPushed = true
setBackButton()
setNavigationTitle("Οδηγίες χρήσης")
setupUI()
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
swiftApi().logTrackersEvent("screen", "MarketPassInfoScreen")
self.navigationController?.hideHairline()
}
// MARK: - Functions
func setupUI() {
heroImage.image = UIImage(named: "pass_info_hero", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
storeInfoImage.image = UIImage(named: "pass_info_cart", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
eshopInfoImage.image = UIImage(named: "pass_info_globe", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
abInfoImage.image = UIImage(named: "pass_info_ab", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
heroTitleLabel.text = "Πως λειτουργεί:"
heroTitleLabel.font = UIFont(name: "BTCosmo-Bold", size: 24)
heroTitleLabel.textColor = UIColor(rgb: 0x212121)
// StoreInfoView
storeInfoTitleLabel.text = "Εξαργύρωση σε φυσικά καταστήματα"
storeInfoTitleLabel.font = UIFont(name: "PeridotPE-Bold", size: 19.0)
storeInfoTitleLabel.textColor = UIColor(rgb: 0x212121)
storeInfoSubtitleLabel.text = "Σκάναρε το barcode από το κινητό σου στο ταμείο του καταστήματος και κέρδισε απευθείας έκπτωση από τα διαθέσιμα κουπόνια."
storeInfoSubtitleLabel.font = UIFont(name: "PeridotPE-Regular", size: 17.0)
storeInfoSubtitleLabel.textColor = UIColor(rgb: 0x212121)
// EshopInfoView
eshopInfoTitleLabel.text = "Εξαργύρωση στο eshop"
eshopInfoTitleLabel.font = UIFont(name: "PeridotPE-Bold", size: 19.0)
eshopInfoTitleLabel.textColor = UIColor(rgb: 0x212121)
eshopInfoSubtitleLabel.text = "Πληκτρολόγησε τον κωδικό σου στο αντίστοιχο πεδίο κατά το checkout στο eshop και κέρδισε απευθείας έκπτωση από τα διαθέσιμα κουπόνια."
eshopInfoSubtitleLabel.font = UIFont(name: "PeridotPE-Regular", size: 17.0)
eshopInfoSubtitleLabel.textColor = UIColor(rgb: 0x212121)
// ABInfoView
abInfoTitleLabel.text = "Ειδικά για τον ΑΒ"
abInfoTitleLabel.font = UIFont(name: "PeridotPE-Bold", size: 19.0)
abInfoTitleLabel.textColor = UIColor(rgb: 0x212121)
abInfoSubtitleLabel.text = "1. Eνεργοποίησε τον κωδικό στην κάρτα ΑΒ PLUS στο kiosk του καταστήματος ή μέσω eshop / app στην ενοτητα στην ενότητα Συνεργασίες – SUPERMARKET DEALS.\n\n2. Κάνε τις αγορές σου και κέρδισε απευθείας έκπτωση με χρήση της AB PLUS από τα διαθέσιμα κουπόνια."
abInfoSubtitleLabel.font = UIFont(name: "PeridotPE-Regular", size: 17.0)
abInfoSubtitleLabel.textColor = UIColor(rgb: 0x212121)
// okButton
okButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 15)
okButton.setTitle("Επιστροφή στο Supermarket Deals", for: .normal)
okButton.setTitleColor(.white, for: .normal)
okButton.backgroundColor = UIColor(rgb: 0x0EA600)
okButton.layer.cornerRadius = 10.0
}
// MARK: - Actions
@IBAction func okButtonAction(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
}
}
//
// MarketSharingHistoryViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 5/4/23.
//
import UIKit
class MarketSharingHistoryViewController: AnalysisChildViewController {
var loading: Bool = false
var items: Array<swiftApi.SharingCouponModel> = Array()
var allItems: Array<swiftApi.SharingCouponModel> = Array()
var showMore = false
// TODO: remove this when configuring model
let hasMessage = false
// lifecycle
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.delegate = self
self.tableView.dataSource = self
// Add shadow
self.tableView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
self.tableView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
self.tableView.layer.shadowOpacity = 1.0
self.tableView.layer.shadowRadius = 1.0
self.refreshControl = UIRefreshControl()
self.refreshControl?.addTarget(self, action: #selector(handleRefresh(_:)), for: .valueChanged)
handleRefresh(self.refreshControl!)
}
// mvp
@objc func load() {
if (loading) {
return;
}
showLoading()
swiftApi().getSharingHistoryAsync(isMarketHistory: true, getSharingHistoryCallback: responseCallback, failureCallback: {errorCode in })
}
private func showLoading() {
loading = true
if (self.refreshControl!.isRefreshing) {
return;
}
self.refreshControl!.beginRefreshing()
}
private func showError() {
}
private func showContent() {
loading = false
self.refreshControl!.endRefreshing()
}
// private
func responseCallback (_ data: Array<swiftApi.SharingCouponModel>?) -> Void {
self.items = data!
self.allItems = data!
self.showMore = (self.items.count > 3)
if (self.showMore == true) {
self.items = Array(self.items[0...2])
}
showContent()
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
@objc func handleRefresh(_ refreshControl: UIRefreshControl) {
self.perform(_: #selector(load), with: nil, afterDelay: 0.5)
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
return 2
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if (section == 0) {
return 1;
}
if (self.showMore == true) {
return 4
}
return items.count
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
// if (indexPath.section == 0) {
// return hasMessage ? 380.0 : (items.count > 0 ? 280 : 380)
// }
//
// return 140.0
return UITableView.automaticDimension
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// header
if (indexPath.section == 0) {
if (hasMessage) {
return tableView.dequeueReusableCell(withIdentifier: "AnalysisHeaderMessageViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisHeaderMessageViewCell
}
let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisHeaderViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisHeaderViewCell
cell.configureCell(isEmpty: items.count == 0, isMarket: true)
return cell
}
if ((self.showMore == true) && (indexPath.row == 3)) {
let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisMoreViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisMoreViewCell
return cell
}
let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisItemViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisItemViewCell
cell.configureCell(item: items[indexPath.row], isMarket: true)
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if (indexPath.section == 0) {
return
}
if ((self.showMore == true) && (indexPath.row == 3)) {
self.items = self.allItems
self.showMore = false
self.tableView.reloadData()
}
}
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if (section == 0){
return nil
} else if (section == 1) {
if (self.items.count > 0) {
let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 50))
let viewBorder = UIView(frame: CGRect(x: 10, y: 0, width: view.frame.width-20, height: view.frame.height))
viewBorder.backgroundColor = .white
// viewBorder.backgroundColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00)
viewBorder.layer.cornerRadius = 16.5
viewBorder.layer.maskedCorners = [ .layerMinXMinYCorner, .layerMaxXMinYCorner] // Top left, bottom right corner radius
let viewInner = UIView(frame: CGRect(x: 1, y: 1, width: viewBorder.frame.width-2, height: viewBorder.frame.height-1))
viewInner.backgroundColor = .white
viewInner.layer.cornerRadius = 16.5
viewInner.layer.maskedCorners = [ .layerMinXMinYCorner, .layerMaxXMinYCorner] // Top left, bottom right corner radius
let titleLabel = UILabel(frame: CGRect(x: 20, y: 20, width: viewInner.frame.width - 40, height: 20))
titleLabel.font = UIFont(name: "BTCosmo-Bold", size: 20)
titleLabel.textColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)
titleLabel.text = "Αναλυτικά"
view.addSubview(viewBorder)
viewBorder.addSubview(viewInner)
viewInner.addSubview(titleLabel)
return view
} else {
return nil
}
} else {
return nil
}
}
override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if (section == 0) {
return 0.0
} else if (section == 1) {
if (self.items.count > 0) {
return 50.0
} else {
return 0.0
}
} else {
return 0.0
}
}
override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
// return CGFloat.leastNormalMagnitude
if (section == 1 && self.items.count > 0) {
return 20.0
} else {
return 0.0
}
}
override func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
if (section == 1) {
if (self.items.count > 0) {
let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 30))
let viewBorder = UIView(frame: CGRect(x: 10, y: 0, width: view.frame.width-20, height: view.frame.height))
viewBorder.backgroundColor = .white
// viewBorder.backgroundColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00)
viewBorder.layer.cornerRadius = 16.5
viewBorder.layer.maskedCorners = [ .layerMinXMaxYCorner, .layerMaxXMaxYCorner] // bottom left, bottom right corner radius
let viewInner = UIView(frame: CGRect(x: 1, y: 0, width: viewBorder.frame.width-2, height: viewBorder.frame.height-1))
viewInner.backgroundColor = .white
viewInner.layer.cornerRadius = 16.5
viewInner.layer.maskedCorners = [ .layerMinXMaxYCorner, .layerMaxXMaxYCorner] // bottom left, bottom right corner radius
view.addSubview(viewBorder)
viewBorder.addSubview(viewInner)
return view
} else {
return nil
}
} else {
return nil
}
}
}
{
"images" : [
{
"filename" : "active_code_logo.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "active_code_logo-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "active_code_logo-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "active_code_logo_2.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "active_code_logo_2 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "active_code_logo_2 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "arrow_right_black.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "arrow_right_black 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "arrow_right_black 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "circle_checked.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "circle_checked 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "circle_checked 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "circle_unchecked.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "circle_unchecked 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "circle_unchecked 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "coupon_bg.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "coupon_bg-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "coupon_bg-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "coupon_bg_2.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "coupon_bg_2 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "coupon_bg_2 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "coupon_bg_2_selected.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "coupon_bg_2_selected 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "coupon_bg_2_selected 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "coupon_bg_grey.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "coupon_bg_grey 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "coupon_bg_grey 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "coupon_bg_shadow.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "coupon_bg_shadow 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "coupon_bg_shadow 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "coupon_bg_shadow_grey.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "coupon_bg_shadow_grey 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "coupon_bg_shadow_grey 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "coupon_market.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "coupon_market 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "coupon_market 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "coupon_market_2.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "coupon_market_2 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "coupon_market_2 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "coupons_scrollview_dark.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "coupons_scrollview_dark-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "coupons_scrollview_dark-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "coupons_scrollview_white.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "coupons_scrollview_white-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "coupons_scrollview_white-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "curved_bg_white.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "curved_bg_white-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "curved_bg_white-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.