Dimitris Togias

fix table view cell items

...@@ -123,7 +123,7 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -123,7 +123,7 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
123 let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 60)) 123 let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 60))
124 view.backgroundColor = .clear 124 view.backgroundColor = .clear
125 125
126 - let titleLabel = UILabel(frame: CGRect(x: 15, y: 20, width: view.frame.width - 15, height: 40)) 126 + let titleLabel = UILabel(frame: CGRect(x: 18, y: 20, width: view.frame.width - 18, height: 40))
127 titleLabel.font = UIFont(name: "PFSquareSansPro-Bold", size: 21) 127 titleLabel.font = UIFont(name: "PFSquareSansPro-Bold", size: 21)
128 titleLabel.textColor = .white 128 titleLabel.textColor = .white
129 titleLabel.text = categories[section].name 129 titleLabel.text = categories[section].name
...@@ -156,30 +156,33 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -156,30 +156,33 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
156 } 156 }
157 157
158 public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 158 public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
159 - if (campaigns[indexPath.row]._ccms != nil) { 159 + let campaign = categories[indexPath.section].items[indexPath.row]
160 +
161 +
162 + if (campaign._ccms != nil) {
160 let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) 163 let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
161 let vc = storyboard.instantiateViewController(withIdentifier: "ContextualViewController") as! SwiftWarplyFramework.ContextualViewController 164 let vc = storyboard.instantiateViewController(withIdentifier: "ContextualViewController") as! SwiftWarplyFramework.ContextualViewController
162 - vc.ccms = campaigns[indexPath.row]._ccms 165 + vc.ccms = campaign._ccms
163 self.navigationController?.pushViewController(vc, animated: true) 166 self.navigationController?.pushViewController(vc, animated: true)
164 167
165 - } else if (campaigns[indexPath.row]._type != nil && campaigns[indexPath.row]._type == "telco") { 168 + } else if (campaign._type != nil && campaign._type == "telco") {
166 let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns() 169 let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
167 - let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].session_uuid } 170 + let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaign.session_uuid }
168 171
169 if (loyaltyCampaignIdExists == true) { 172 if (loyaltyCampaignIdExists == true) {
170 for item in ccmsCampaigns { 173 for item in ccmsCampaigns {
171 - if (item._loyaltyCampaignId == campaigns[indexPath.row].session_uuid) { 174 + if (item._loyaltyCampaignId == campaign.session_uuid) {
172 let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) 175 let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
173 let vc = storyboard.instantiateViewController(withIdentifier: "TelcoViewController") as! SwiftWarplyFramework.TelcoViewController 176 let vc = storyboard.instantiateViewController(withIdentifier: "TelcoViewController") as! SwiftWarplyFramework.TelcoViewController
174 vc.ccms = item 177 vc.ccms = item
175 - vc.campaign = campaigns[indexPath.row] 178 + vc.campaign = campaign
176 self.navigationController?.pushViewController(vc, animated: true) 179 self.navigationController?.pushViewController(vc, animated: true)
177 } 180 }
178 } 181 }
179 } 182 }
180 183
181 - } else if (campaigns[indexPath.row]._campaign_type == "coupon") { 184 + } else if (campaign._campaign_type == "coupon") {
182 - let couponsetUuid = campaigns[indexPath.row]._couponset 185 + let couponsetUuid = campaign._couponset
183 186
184 if (couponsetUuid != "") { 187 if (couponsetUuid != "") {
185 let couponsetsList = swiftApi().getCouponSetList() 188 let couponsetsList = swiftApi().getCouponSetList()
...@@ -189,14 +192,14 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -189,14 +192,14 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
189 let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) 192 let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
190 let vc = storyboard.instantiateViewController(withIdentifier: "CouponViewController") as! SwiftWarplyFramework.CouponViewController 193 let vc = storyboard.instantiateViewController(withIdentifier: "CouponViewController") as! SwiftWarplyFramework.CouponViewController
191 vc.couponset = item 194 vc.couponset = item
192 - vc.campaign = campaigns[indexPath.row] 195 + vc.campaign = campaign
193 196
194 let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns() 197 let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
195 - let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].session_uuid } 198 + let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaign.session_uuid }
196 199
197 if (loyaltyCampaignIdExists == true) { 200 if (loyaltyCampaignIdExists == true) {
198 for item in ccmsCampaigns { 201 for item in ccmsCampaigns {
199 - if (item._loyaltyCampaignId == campaigns[indexPath.row].session_uuid) { 202 + if (item._loyaltyCampaignId == campaign.session_uuid) {
200 vc.ccms = item 203 vc.ccms = item
201 break; 204 break;
202 } 205 }
...@@ -222,42 +225,42 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -222,42 +225,42 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
222 let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController 225 let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController
223 var url = "" 226 var url = ""
224 var params = "" 227 var params = ""
225 - let isCcmsOffer = (campaigns[indexPath.row].ccms_offer != nil) && (campaigns[indexPath.row].ccms_offer != "") && (campaigns[indexPath.row].ccms_offer == "true") 228 + let isCcmsOffer = (campaign.ccms_offer != nil) && (campaign.ccms_offer != "") && (campaign.ccms_offer == "true")
226 229
227 if (isCcmsOffer) { 230 if (isCcmsOffer) {
228 let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns() 231 let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
229 232
230 - let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].session_uuid } 233 + let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaign.session_uuid }
231 234
232 if (loyaltyCampaignIdExists == true) { 235 if (loyaltyCampaignIdExists == true) {
233 var ccmsCampaignFound:swiftApi.LoyaltyContextualOfferModel = swiftApi.LoyaltyContextualOfferModel() 236 var ccmsCampaignFound:swiftApi.LoyaltyContextualOfferModel = swiftApi.LoyaltyContextualOfferModel()
234 for item in ccmsCampaigns { 237 for item in ccmsCampaigns {
235 - if (item._loyaltyCampaignId == campaigns[indexPath.row].session_uuid) { 238 + if (item._loyaltyCampaignId == campaign.session_uuid) {
236 ccmsCampaignFound = item 239 ccmsCampaignFound = item
237 } 240 }
238 } 241 }
239 - url = swiftApi().constructCcmsUrl(campaigns[indexPath.row], ccmsCampaignFound) 242 + url = swiftApi().constructCcmsUrl(campaign, ccmsCampaignFound)
240 - params = swiftApi().constructCcmsParams(campaigns[indexPath.row], ccmsCampaignFound) 243 + params = swiftApi().constructCcmsParams(campaign, ccmsCampaignFound)
241 244
242 } else { 245 } else {
243 - url = swiftApi().constructCampaignUrl(campaigns[indexPath.row]) 246 + url = swiftApi().constructCampaignUrl(campaign)
244 - params = swiftApi().constructCampaignParams(campaigns[indexPath.row]) 247 + params = swiftApi().constructCampaignParams(campaign)
245 248
246 } 249 }
247 250
248 let encoder = JSONEncoder() 251 let encoder = JSONEncoder()
249 encoder.outputFormatting = .prettyPrinted 252 encoder.outputFormatting = .prettyPrinted
250 - let data = try! encoder.encode(campaigns[indexPath.row]) 253 + let data = try! encoder.encode(campaign)
251 254
252 print("CCMS_CLICK " + String(data: data, encoding: .utf8)!) 255 print("CCMS_CLICK " + String(data: data, encoding: .utf8)!)
253 256
254 } else { 257 } else {
255 - url = swiftApi().constructCampaignUrl(campaigns[indexPath.row]) 258 + url = swiftApi().constructCampaignUrl(campaign)
256 - params = swiftApi().constructCampaignParams(campaigns[indexPath.row]) 259 + params = swiftApi().constructCampaignParams(campaign)
257 260
258 let encoder = JSONEncoder() 261 let encoder = JSONEncoder()
259 encoder.outputFormatting = .prettyPrinted 262 encoder.outputFormatting = .prettyPrinted
260 - let data = try! encoder.encode(campaigns[indexPath.row]) 263 + let data = try! encoder.encode(campaign)
261 264
262 print("GFY_CLICK " + String(data: data, encoding: .utf8)!) 265 print("GFY_CLICK " + String(data: data, encoding: .utf8)!)
263 } 266 }
......