Manos Chorianopoulos

add GiftsViewController

...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
7 <key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key> 7 <key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key>
8 <dict> 8 <dict>
9 <key>orderHint</key> 9 <key>orderHint</key>
10 - <integer>0</integer> 10 + <integer>1</integer>
11 </dict> 11 </dict>
12 </dict> 12 </dict>
13 </dict> 13 </dict>
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
10 1E2966EA2837A21D00F83FAC /* RSBarcodes_Swift in Frameworks */ = {isa = PBXBuildFile; productRef = 1E2966E92837A21D00F83FAC /* RSBarcodes_Swift */; }; 10 1E2966EA2837A21D00F83FAC /* RSBarcodes_Swift in Frameworks */ = {isa = PBXBuildFile; productRef = 1E2966E92837A21D00F83FAC /* RSBarcodes_Swift */; };
11 1E74838D28378AF40042A589 /* CouponBarcodeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E74838C28378AF40042A589 /* CouponBarcodeViewController.swift */; }; 11 1E74838D28378AF40042A589 /* CouponBarcodeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E74838C28378AF40042A589 /* CouponBarcodeViewController.swift */; };
12 1EA1AF0A2835346A008998AA /* CouponsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */; }; 12 1EA1AF0A2835346A008998AA /* CouponsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */; };
13 + 1EA2BB792865BFE8003F2AB0 /* InboxTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA2BB782865BFE8003F2AB0 /* InboxTableViewCell.swift */; };
13 1EB5F4C828536FD60016F36E /* StepsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EB5F4C728536FD60016F36E /* StepsViewController.swift */; }; 14 1EB5F4C828536FD60016F36E /* StepsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EB5F4C728536FD60016F36E /* StepsViewController.swift */; };
14 1EB5F4CA285370C90016F36E /* LoyaltyAnalysisViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EB5F4C9285370C90016F36E /* LoyaltyAnalysisViewController.swift */; }; 15 1EB5F4CA285370C90016F36E /* LoyaltyAnalysisViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EB5F4C9285370C90016F36E /* LoyaltyAnalysisViewController.swift */; };
15 1EBF5F072840E13F00B8B17F /* SwiftEventBus in Frameworks */ = {isa = PBXBuildFile; productRef = 1EBF5F062840E13F00B8B17F /* SwiftEventBus */; }; 16 1EBF5F072840E13F00B8B17F /* SwiftEventBus in Frameworks */ = {isa = PBXBuildFile; productRef = 1EBF5F062840E13F00B8B17F /* SwiftEventBus */; };
...@@ -145,6 +146,7 @@ ...@@ -145,6 +146,7 @@
145 /* Begin PBXFileReference section */ 146 /* Begin PBXFileReference section */
146 1E74838C28378AF40042A589 /* CouponBarcodeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponBarcodeViewController.swift; sourceTree = "<group>"; }; 147 1E74838C28378AF40042A589 /* CouponBarcodeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponBarcodeViewController.swift; sourceTree = "<group>"; };
147 1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponsTableViewCell.swift; sourceTree = "<group>"; }; 148 1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponsTableViewCell.swift; sourceTree = "<group>"; };
149 + 1EA2BB782865BFE8003F2AB0 /* InboxTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InboxTableViewCell.swift; sourceTree = "<group>"; };
148 1EB5F4C728536FD60016F36E /* StepsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StepsViewController.swift; sourceTree = "<group>"; }; 150 1EB5F4C728536FD60016F36E /* StepsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StepsViewController.swift; sourceTree = "<group>"; };
149 1EB5F4C9285370C90016F36E /* LoyaltyAnalysisViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoyaltyAnalysisViewController.swift; sourceTree = "<group>"; }; 151 1EB5F4C9285370C90016F36E /* LoyaltyAnalysisViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoyaltyAnalysisViewController.swift; sourceTree = "<group>"; };
150 A9B7BE01A4E812DE49866EF8 /* Pods-SwiftWarplyFramework.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftWarplyFramework.debug.xcconfig"; path = "Target Support Files/Pods-SwiftWarplyFramework/Pods-SwiftWarplyFramework.debug.xcconfig"; sourceTree = "<group>"; }; 152 A9B7BE01A4E812DE49866EF8 /* Pods-SwiftWarplyFramework.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftWarplyFramework.debug.xcconfig"; path = "Target Support Files/Pods-SwiftWarplyFramework/Pods-SwiftWarplyFramework.debug.xcconfig"; sourceTree = "<group>"; };
...@@ -337,6 +339,7 @@ ...@@ -337,6 +339,7 @@
337 1E74838C28378AF40042A589 /* CouponBarcodeViewController.swift */, 339 1E74838C28378AF40042A589 /* CouponBarcodeViewController.swift */,
338 E6A77863282933E50045BBA8 /* DetailsViewController.swift */, 340 E6A77863282933E50045BBA8 /* DetailsViewController.swift */,
339 E6A778DE282933E60045BBA8 /* GiftsViewController.swift */, 341 E6A778DE282933E60045BBA8 /* GiftsViewController.swift */,
342 + 1EA2BB782865BFE8003F2AB0 /* InboxTableViewCell.swift */,
340 E6A778DB282933E60045BBA8 /* MFYViewController.swift */, 343 E6A778DB282933E60045BBA8 /* MFYViewController.swift */,
341 E6A7785F282933E40045BBA8 /* WalletViewController.swift */, 344 E6A7785F282933E40045BBA8 /* WalletViewController.swift */,
342 E6A77A31282BA9C60045BBA8 /* CampaignViewController.swift */, 345 E6A77A31282BA9C60045BBA8 /* CampaignViewController.swift */,
...@@ -779,6 +782,7 @@ ...@@ -779,6 +782,7 @@
779 1EA1AF0A2835346A008998AA /* CouponsTableViewCell.swift in Sources */, 782 1EA1AF0A2835346A008998AA /* CouponsTableViewCell.swift in Sources */,
780 E6A77A32282BA9C60045BBA8 /* CampaignViewController.swift in Sources */, 783 E6A77A32282BA9C60045BBA8 /* CampaignViewController.swift in Sources */,
781 E6A77917282933E60045BBA8 /* UIViewController+WLAdditions.m in Sources */, 784 E6A77917282933E60045BBA8 /* UIViewController+WLAdditions.m in Sources */,
785 + 1EA2BB792865BFE8003F2AB0 /* InboxTableViewCell.swift in Sources */,
782 E6A77943282933E70045BBA8 /* AFNetworkReachabilityManager.m in Sources */, 786 E6A77943282933E70045BBA8 /* AFNetworkReachabilityManager.m in Sources */,
783 E6A77956282933E70045BBA8 /* GiftsViewController.swift in Sources */, 787 E6A77956282933E70045BBA8 /* GiftsViewController.swift in Sources */,
784 E6A778F1282933E60045BBA8 /* WLNativeAdTableViewCell.m in Sources */, 788 E6A778F1282933E60045BBA8 /* WLNativeAdTableViewCell.m in Sources */,
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
7 <key>SwiftWarplyFramework.xcscheme_^#shared#^_</key> 7 <key>SwiftWarplyFramework.xcscheme_^#shared#^_</key>
8 <dict> 8 <dict>
9 <key>orderHint</key> 9 <key>orderHint</key>
10 - <integer>1</integer> 10 + <integer>0</integer>
11 </dict> 11 </dict>
12 </dict> 12 </dict>
13 </dict> 13 </dict>
......
...@@ -9,27 +9,86 @@ import Foundation ...@@ -9,27 +9,86 @@ import Foundation
9 import UIKit 9 import UIKit
10 10
11 @objc public class GiftsViewController: UIViewController { 11 @objc public class GiftsViewController: UIViewController {
12 + @IBOutlet weak var mainView: UIView!
13 + @IBOutlet weak var tableView: UITableView!
12 14
13 - @IBOutlet weak var campaignButton: UIButton! 15 + public var campaigns:Array<swiftApi.CampaignItemModel> = []
14 16
15 - @IBOutlet weak var couponButton: UIButton!
16 17
17 - public override func viewWillAppear(_ animated: Bool) { 18 + public override func viewDidLoad() {
18 - super.viewWillAppear(animated) 19 + super.viewDidLoad()
20 +
21 + getCampaignsRequest()
22 +
19 setBackButton() 23 setBackButton()
20 - setNavigationTitle("Gifts for You") 24 + setNavigationTitle("GIFTS for YOU")
25 +
26 + tableView.delegate = self
27 + tableView.dataSource = self
28 +
29 + tableView.clipsToBounds = true
30 + tableView.layer.cornerRadius = 30
31 + tableView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius
32 + tableView.contentInset.top = 50
33 +
34 + // Add Top left corner radius
35 + mainView.clipsToBounds = true
36 + mainView.layer.cornerRadius = 30
37 + mainView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius
38 + mainView.backgroundColor = UIColor(red: 0.22, green: 0.32, blue: 0.40, alpha: 1.00)
39 +
21 } 40 }
22 41
23 - @IBAction func navigateToCampaign(_ sender: Any) { 42 +
24 - let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) 43 + func getCampaignsRequest() {
25 - let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! CampaignViewController 44 + swiftApi().getCampaignsAsync(getCampaignsCallback)
26 - vc.campaignUrl = "https://www.google.com" 45 + }
27 - self.navigationController?.pushViewController(vc, animated: true) 46 +
47 + func getCampaignsCallback (_ campaignsData: Array<swiftApi.CampaignItemModel>?) -> Void {
48 + if (campaignsData != nil) {
49 +
50 + self.campaigns = campaignsData?.filter { $0.offer_category == "gifts_for_you" } ?? []
51 +
52 + DispatchQueue.main.async {
53 + self.tableView.reloadData()
54 + swiftApi().setUniqueCampaignList(campaignsData ?? [])
55 + }
56 + } else {
57 + self.campaigns = []
58 + }
59 + }
60 +}
61 +
62 +// MARK: - TableView
63 +extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
64 +
65 + public func numberOfSections(in tableView: UITableView) -> Int {
66 + return 1
67 + }
68 +
69 + public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
70 + return self.campaigns.count
28 } 71 }
29 72
30 - @IBAction func navigateToCoupon(_ sender: Any) { 73 + public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
74 + return 140.0 + 10.0
75 +// return UITableViewAutomaticDimension
76 + }
77 +
78 + public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
79 + let cell = tableView.dequeueReusableCell(withIdentifier: "InboxTableViewCellId", for: indexPath) as! InboxTableViewCell
80 +
81 + cell.configureCell(campaign: campaigns[indexPath.row])
82 +
83 + return cell
84 + }
85 +
86 + public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
31 let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) 87 let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
32 - let vc = storyboard.instantiateViewController(withIdentifier: "CouponViewController") as UIViewController 88 + let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! CampaignViewController
89 + let url = swiftApi().constructCampaignUrl(campaigns[indexPath.row])
90 + vc.campaignUrl = url
33 self.navigationController?.pushViewController(vc, animated: true) 91 self.navigationController?.pushViewController(vc, animated: true)
34 } 92 }
93 +
35 } 94 }
......
1 +//
2 +// InboxTableViewCell.swift
3 +// SwiftWarplyFramework
4 +//
5 +// Created by Manos Chorianopoulos on 24/6/22.
6 +//
7 +
8 +import UIKit
9 +
10 +@objc public class InboxTableViewCell: UITableViewCell {
11 + @IBOutlet weak var inboxView: UIView!
12 + @IBOutlet weak var campaignImage: UIImageView!
13 + @IBOutlet weak var newBadgeImage: UIImageView!
14 + @IBOutlet weak var campaignTitleLabel: UILabel!
15 +
16 + public override func awakeFromNib() {
17 + super.awakeFromNib()
18 +
19 + inboxView.layer.cornerRadius = 5.0
20 + inboxView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.16).cgColor
21 + inboxView.layer.shadowOffset = CGSize(width: 0.0, height: 3.0)
22 + inboxView.layer.shadowOpacity = 1.0
23 + inboxView.layer.shadowRadius = 15.0
24 + inboxView.clipsToBounds = true
25 +
26 + newBadgeImage.image = UIImage(named: "new_icon", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil)
27 +
28 + newBadgeImage.isHidden = true
29 + }
30 +
31 + public override func setSelected(_ selected: Bool, animated: Bool) {
32 + super.setSelected(selected, animated: animated)
33 +
34 + // Configure the view for the selected state
35 + }
36 +
37 + public override func layoutSubviews() {
38 + super.layoutSubviews()
39 + //set the values for top,left,bottom,right margins
40 + let margins = UIEdgeInsets(top: 0, left: 0, bottom: 10, right: 0)
41 + contentView.frame = contentView.frame.inset(by: margins)
42 + }
43 +
44 +
45 + func configureCell(campaign: swiftApi.CampaignItemModel) {
46 + campaignImage.load(link: campaign.logo_url ?? "", placeholder: UIImage(), cache: URLCache())
47 +
48 + campaignTitleLabel.text = campaign.title ?? ""
49 +
50 + if (campaign.is_new ?? false) {
51 + newBadgeImage.isHidden = false
52 + }
53 + }
54 +
55 +}
1 +{
2 + "images" : [
3 + {
4 + "filename" : "new_icon.png",
5 + "idiom" : "universal",
6 + "scale" : "1x"
7 + },
8 + {
9 + "filename" : "new_icon-1.png",
10 + "idiom" : "universal",
11 + "scale" : "2x"
12 + },
13 + {
14 + "filename" : "new_icon-2.png",
15 + "idiom" : "universal",
16 + "scale" : "3x"
17 + }
18 + ],
19 + "info" : {
20 + "author" : "xcode",
21 + "version" : 1
22 + }
23 +}
...@@ -390,6 +390,7 @@ public class swiftApi { ...@@ -390,6 +390,7 @@ public class swiftApi {
390 public let subtitle: String? 390 public let subtitle: String?
391 public let session_uuid: String? 391 public let session_uuid: String?
392 public let subcategory: String? 392 public let subcategory: String?
393 + public let is_new: Bool?
393 394
394 init(dictionary: [String: Any]) { 395 init(dictionary: [String: Any]) {
395 self.index_url = dictionary["index_url"] as? String? ?? "" 396 self.index_url = dictionary["index_url"] as? String? ?? ""
...@@ -398,6 +399,7 @@ public class swiftApi { ...@@ -398,6 +399,7 @@ public class swiftApi {
398 self.title = dictionary["title"] as? String? ?? "" 399 self.title = dictionary["title"] as? String? ?? ""
399 self.subtitle = dictionary["subtitle"] as? String? ?? "" 400 self.subtitle = dictionary["subtitle"] as? String? ?? ""
400 self.session_uuid = dictionary["session_uuid"] as? String? ?? "" 401 self.session_uuid = dictionary["session_uuid"] as? String? ?? ""
402 + self.is_new = dictionary["is_new"] as? Bool? ?? false
401 403
402 // let extra_fields = dictionary["extra_fields"] as? [String: Any]? ?? ["":""] 404 // let extra_fields = dictionary["extra_fields"] as? [String: Any]? ?? ["":""]
403 let extra_fields = dictionary["extra_fields"] as AnyObject 405 let extra_fields = dictionary["extra_fields"] as AnyObject
......