Dimitris Togias

fix table view cell items

......@@ -123,7 +123,7 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 60))
view.backgroundColor = .clear
let titleLabel = UILabel(frame: CGRect(x: 15, y: 20, width: view.frame.width - 15, height: 40))
let titleLabel = UILabel(frame: CGRect(x: 18, y: 20, width: view.frame.width - 18, height: 40))
titleLabel.font = UIFont(name: "PFSquareSansPro-Bold", size: 21)
titleLabel.textColor = .white
titleLabel.text = categories[section].name
......@@ -156,30 +156,33 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
}
public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if (campaigns[indexPath.row]._ccms != nil) {
let campaign = categories[indexPath.section].items[indexPath.row]
if (campaign._ccms != nil) {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "ContextualViewController") as! SwiftWarplyFramework.ContextualViewController
vc.ccms = campaigns[indexPath.row]._ccms
vc.ccms = campaign._ccms
self.navigationController?.pushViewController(vc, animated: true)
} else if (campaigns[indexPath.row]._type != nil && campaigns[indexPath.row]._type == "telco") {
} else if (campaign._type != nil && campaign._type == "telco") {
let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].session_uuid }
let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaign.session_uuid }
if (loyaltyCampaignIdExists == true) {
for item in ccmsCampaigns {
if (item._loyaltyCampaignId == campaigns[indexPath.row].session_uuid) {
if (item._loyaltyCampaignId == campaign.session_uuid) {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "TelcoViewController") as! SwiftWarplyFramework.TelcoViewController
vc.ccms = item
vc.campaign = campaigns[indexPath.row]
vc.campaign = campaign
self.navigationController?.pushViewController(vc, animated: true)
}
}
}
} else if (campaigns[indexPath.row]._campaign_type == "coupon") {
let couponsetUuid = campaigns[indexPath.row]._couponset
} else if (campaign._campaign_type == "coupon") {
let couponsetUuid = campaign._couponset
if (couponsetUuid != "") {
let couponsetsList = swiftApi().getCouponSetList()
......@@ -189,14 +192,14 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "CouponViewController") as! SwiftWarplyFramework.CouponViewController
vc.couponset = item
vc.campaign = campaigns[indexPath.row]
vc.campaign = campaign
let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].session_uuid }
let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaign.session_uuid }
if (loyaltyCampaignIdExists == true) {
for item in ccmsCampaigns {
if (item._loyaltyCampaignId == campaigns[indexPath.row].session_uuid) {
if (item._loyaltyCampaignId == campaign.session_uuid) {
vc.ccms = item
break;
}
......@@ -222,42 +225,42 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController
var url = ""
var params = ""
let isCcmsOffer = (campaigns[indexPath.row].ccms_offer != nil) && (campaigns[indexPath.row].ccms_offer != "") && (campaigns[indexPath.row].ccms_offer == "true")
let isCcmsOffer = (campaign.ccms_offer != nil) && (campaign.ccms_offer != "") && (campaign.ccms_offer == "true")
if (isCcmsOffer) {
let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].session_uuid }
let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaign.session_uuid }
if (loyaltyCampaignIdExists == true) {
var ccmsCampaignFound:swiftApi.LoyaltyContextualOfferModel = swiftApi.LoyaltyContextualOfferModel()
for item in ccmsCampaigns {
if (item._loyaltyCampaignId == campaigns[indexPath.row].session_uuid) {
if (item._loyaltyCampaignId == campaign.session_uuid) {
ccmsCampaignFound = item
}
}
url = swiftApi().constructCcmsUrl(campaigns[indexPath.row], ccmsCampaignFound)
params = swiftApi().constructCcmsParams(campaigns[indexPath.row], ccmsCampaignFound)
url = swiftApi().constructCcmsUrl(campaign, ccmsCampaignFound)
params = swiftApi().constructCcmsParams(campaign, ccmsCampaignFound)
} else {
url = swiftApi().constructCampaignUrl(campaigns[indexPath.row])
params = swiftApi().constructCampaignParams(campaigns[indexPath.row])
url = swiftApi().constructCampaignUrl(campaign)
params = swiftApi().constructCampaignParams(campaign)
}
let encoder = JSONEncoder()
encoder.outputFormatting = .prettyPrinted
let data = try! encoder.encode(campaigns[indexPath.row])
let data = try! encoder.encode(campaign)
print("CCMS_CLICK " + String(data: data, encoding: .utf8)!)
} else {
url = swiftApi().constructCampaignUrl(campaigns[indexPath.row])
params = swiftApi().constructCampaignParams(campaigns[indexPath.row])
url = swiftApi().constructCampaignUrl(campaign)
params = swiftApi().constructCampaignParams(campaign)
let encoder = JSONEncoder()
encoder.outputFormatting = .prettyPrinted
let data = try! encoder.encode(campaigns[indexPath.row])
let data = try! encoder.encode(campaign)
print("GFY_CLICK " + String(data: data, encoding: .utf8)!)
}
......