Manos Chorianopoulos

add GiftsViewController

......@@ -7,7 +7,7 @@
<key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
</dict>
</dict>
......
......@@ -10,6 +10,7 @@
1E2966EA2837A21D00F83FAC /* RSBarcodes_Swift in Frameworks */ = {isa = PBXBuildFile; productRef = 1E2966E92837A21D00F83FAC /* RSBarcodes_Swift */; };
1E74838D28378AF40042A589 /* CouponBarcodeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E74838C28378AF40042A589 /* CouponBarcodeViewController.swift */; };
1EA1AF0A2835346A008998AA /* CouponsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */; };
1EA2BB792865BFE8003F2AB0 /* InboxTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA2BB782865BFE8003F2AB0 /* InboxTableViewCell.swift */; };
1EB5F4C828536FD60016F36E /* StepsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EB5F4C728536FD60016F36E /* StepsViewController.swift */; };
1EB5F4CA285370C90016F36E /* LoyaltyAnalysisViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EB5F4C9285370C90016F36E /* LoyaltyAnalysisViewController.swift */; };
1EBF5F072840E13F00B8B17F /* SwiftEventBus in Frameworks */ = {isa = PBXBuildFile; productRef = 1EBF5F062840E13F00B8B17F /* SwiftEventBus */; };
......@@ -145,6 +146,7 @@
/* Begin PBXFileReference section */
1E74838C28378AF40042A589 /* CouponBarcodeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponBarcodeViewController.swift; sourceTree = "<group>"; };
1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponsTableViewCell.swift; sourceTree = "<group>"; };
1EA2BB782865BFE8003F2AB0 /* InboxTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InboxTableViewCell.swift; sourceTree = "<group>"; };
1EB5F4C728536FD60016F36E /* StepsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StepsViewController.swift; sourceTree = "<group>"; };
1EB5F4C9285370C90016F36E /* LoyaltyAnalysisViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoyaltyAnalysisViewController.swift; sourceTree = "<group>"; };
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 @@
1E74838C28378AF40042A589 /* CouponBarcodeViewController.swift */,
E6A77863282933E50045BBA8 /* DetailsViewController.swift */,
E6A778DE282933E60045BBA8 /* GiftsViewController.swift */,
1EA2BB782865BFE8003F2AB0 /* InboxTableViewCell.swift */,
E6A778DB282933E60045BBA8 /* MFYViewController.swift */,
E6A7785F282933E40045BBA8 /* WalletViewController.swift */,
E6A77A31282BA9C60045BBA8 /* CampaignViewController.swift */,
......@@ -779,6 +782,7 @@
1EA1AF0A2835346A008998AA /* CouponsTableViewCell.swift in Sources */,
E6A77A32282BA9C60045BBA8 /* CampaignViewController.swift in Sources */,
E6A77917282933E60045BBA8 /* UIViewController+WLAdditions.m in Sources */,
1EA2BB792865BFE8003F2AB0 /* InboxTableViewCell.swift in Sources */,
E6A77943282933E70045BBA8 /* AFNetworkReachabilityManager.m in Sources */,
E6A77956282933E70045BBA8 /* GiftsViewController.swift in Sources */,
E6A778F1282933E60045BBA8 /* WLNativeAdTableViewCell.m in Sources */,
......
......@@ -7,7 +7,7 @@
<key>SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>0</integer>
</dict>
</dict>
</dict>
......
......@@ -9,27 +9,86 @@ import Foundation
import UIKit
@objc public class GiftsViewController: UIViewController {
@IBOutlet weak var mainView: UIView!
@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var campaignButton: UIButton!
public var campaigns:Array<swiftApi.CampaignItemModel> = []
@IBOutlet weak var couponButton: UIButton!
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
public override func viewDidLoad() {
super.viewDidLoad()
getCampaignsRequest()
setBackButton()
setNavigationTitle("Gifts for You")
setNavigationTitle("GIFTS for YOU")
tableView.delegate = self
tableView.dataSource = self
tableView.clipsToBounds = true
tableView.layer.cornerRadius = 30
tableView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius
tableView.contentInset.top = 50
// Add Top left corner radius
mainView.clipsToBounds = true
mainView.layer.cornerRadius = 30
mainView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius
mainView.backgroundColor = UIColor(red: 0.22, green: 0.32, blue: 0.40, alpha: 1.00)
}
@IBAction func navigateToCampaign(_ sender: Any) {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! CampaignViewController
vc.campaignUrl = "https://www.google.com"
self.navigationController?.pushViewController(vc, animated: true)
func getCampaignsRequest() {
swiftApi().getCampaignsAsync(getCampaignsCallback)
}
func getCampaignsCallback (_ campaignsData: Array<swiftApi.CampaignItemModel>?) -> Void {
if (campaignsData != nil) {
self.campaigns = campaignsData?.filter { $0.offer_category == "gifts_for_you" } ?? []
DispatchQueue.main.async {
self.tableView.reloadData()
swiftApi().setUniqueCampaignList(campaignsData ?? [])
}
} else {
self.campaigns = []
}
}
}
// MARK: - TableView
extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
public func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.campaigns.count
}
@IBAction func navigateToCoupon(_ sender: Any) {
public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 140.0 + 10.0
// return UITableViewAutomaticDimension
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "InboxTableViewCellId", for: indexPath) as! InboxTableViewCell
cell.configureCell(campaign: campaigns[indexPath.row])
return cell
}
public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "CouponViewController") as UIViewController
let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! CampaignViewController
let url = swiftApi().constructCampaignUrl(campaigns[indexPath.row])
vc.campaignUrl = url
self.navigationController?.pushViewController(vc, animated: true)
}
}
......
//
// 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!
public override func awakeFromNib() {
super.awakeFromNib()
inboxView.layer.cornerRadius = 5.0
inboxView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.16).cgColor
inboxView.layer.shadowOffset = CGSize(width: 0.0, height: 3.0)
inboxView.layer.shadowOpacity = 1.0
inboxView.layer.shadowRadius = 15.0
inboxView.clipsToBounds = true
newBadgeImage.image = UIImage(named: "new_icon", in: Bundle(for: MyEmptyClass.self), 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())
campaignTitleLabel.text = campaign.title ?? ""
if (campaign.is_new ?? false) {
newBadgeImage.isHidden = false
}
}
}
{
"images" : [
{
"filename" : "new_icon.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "new_icon-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "new_icon-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
......@@ -390,6 +390,7 @@ public class swiftApi {
public let subtitle: String?
public let session_uuid: String?
public let subcategory: String?
public let is_new: Bool?
init(dictionary: [String: Any]) {
self.index_url = dictionary["index_url"] as? String? ?? ""
......@@ -398,6 +399,7 @@ public class swiftApi {
self.title = dictionary["title"] as? String? ?? ""
self.subtitle = dictionary["subtitle"] as? String? ?? ""
self.session_uuid = dictionary["session_uuid"] as? String? ?? ""
self.is_new = dictionary["is_new"] as? Bool? ?? false
// let extra_fields = dictionary["extra_fields"] as? [String: Any]? ?? ["":""]
let extra_fields = dictionary["extra_fields"] as AnyObject
......