Manos Chorianopoulos

add seasonals at GiftsVC

......@@ -7,12 +7,14 @@
import Foundation
import UIKit
import SwiftEventBus
@objc public class GiftsViewController: UIViewController {
@IBOutlet weak var mainView: UIView!
@IBOutlet weak var tableView: UITableView!
public var campaigns:Array<swiftApi.CampaignItemModel> = swiftApi().getCampaignList().filter { $0.offer_category == "gifts_for_you" }
public var seasonalList:Array<swiftApi.LoyaltyGiftsForYouPackage> = swiftApi().getSeasonalList()
public override func viewDidLoad() {
......@@ -20,6 +22,16 @@ import UIKit
self.hidesBottomBarWhenPushed = true
if (seasonalList.count > 0) {
for seasonalItem in seasonalList {
let newCampaign = swiftApi.CampaignItemModel()
newCampaign._title = seasonalItem._title
newCampaign._logo_url = seasonalItem._imageUrl
newCampaign._loyaltyPackageId = seasonalItem._loyaltyPackageId
campaigns.append(newCampaign)
}
}
setBackButton()
setNavigationTitle("GIFTS for YOU")
......@@ -66,6 +78,7 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
}
public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if (campaigns[indexPath.row].session_uuid != nil && campaigns[indexPath.row].session_uuid != "") {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController
var url = ""
......@@ -92,6 +105,14 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
}
vc.campaignUrl = url
self.navigationController?.pushViewController(vc, animated: true)
} else {
let seasonalEvent = swiftApi.LoyaltyGiftsForYouOfferClickEvent()
seasonalEvent._title = campaigns[indexPath.row]._title ?? ""
seasonalEvent._imageUrl = campaigns[indexPath.row]._logo_url ?? ""
seasonalEvent._loyaltyPackageId = campaigns[indexPath.row]._loyaltyPackageId ?? ""
SwiftEventBus.post("seasonal", sender: seasonalEvent)
}
}
}
......