Manos Chorianopoulos

add MFYViewController

......@@ -13,6 +13,7 @@
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 */; };
1EBE97212865EE460080EFF7 /* MFYInboxTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EBE97202865EE460080EFF7 /* MFYInboxTableViewCell.swift */; };
1EBF5F072840E13F00B8B17F /* SwiftEventBus in Frameworks */ = {isa = PBXBuildFile; productRef = 1EBF5F062840E13F00B8B17F /* SwiftEventBus */; };
7630AD9A6242D60846D6750C /* Pods_SwiftWarplyFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C0D5F56DD4E5371A50AD2D87 /* Pods_SwiftWarplyFramework.framework */; };
E6A77853282933340045BBA8 /* SwiftWarplyFramework.docc in Sources */ = {isa = PBXBuildFile; fileRef = E6A77852282933340045BBA8 /* SwiftWarplyFramework.docc */; };
......@@ -149,6 +150,7 @@
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>"; };
1EBE97202865EE460080EFF7 /* MFYInboxTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MFYInboxTableViewCell.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>"; };
B9EB8A451EF0C5AD75094EEE /* Pods-SwiftWarplyFramework.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftWarplyFramework.release.xcconfig"; path = "Target Support Files/Pods-SwiftWarplyFramework/Pods-SwiftWarplyFramework.release.xcconfig"; sourceTree = "<group>"; };
C0D5F56DD4E5371A50AD2D87 /* Pods_SwiftWarplyFramework.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SwiftWarplyFramework.framework; sourceTree = BUILT_PRODUCTS_DIR; };
......@@ -340,6 +342,7 @@
E6A77863282933E50045BBA8 /* DetailsViewController.swift */,
E6A778DE282933E60045BBA8 /* GiftsViewController.swift */,
1EA2BB782865BFE8003F2AB0 /* InboxTableViewCell.swift */,
1EBE97202865EE460080EFF7 /* MFYInboxTableViewCell.swift */,
E6A778DB282933E60045BBA8 /* MFYViewController.swift */,
E6A7785F282933E40045BBA8 /* WalletViewController.swift */,
E6A77A31282BA9C60045BBA8 /* CampaignViewController.swift */,
......@@ -791,6 +794,7 @@
E6A778ED282933E60045BBA8 /* WLCustomNativeCollectionViewCell.m in Sources */,
E6A7790D282933E60045BBA8 /* WLLocationManager.m in Sources */,
E6A7793D282933E70045BBA8 /* AFURLResponseSerialization.m in Sources */,
1EBE97212865EE460080EFF7 /* MFYInboxTableViewCell.swift in Sources */,
E6A778FD282933E60045BBA8 /* WLInboxItem.m in Sources */,
E6A778EE282933E60045BBA8 /* WLNativeAdsTableMode.m in Sources */,
E6A778DF282933E60045BBA8 /* WarplyReactMethods.m in Sources */,
......
//
// MFYInboxTableViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 24/6/22.
//
import UIKit
@objc public class MFYInboxTableViewCell: UITableViewCell {
@IBOutlet weak var inboxView: UIView!
@IBOutlet weak var campaignImage: UIImageView!
@IBOutlet weak var newBadgeImage: UIImageView!
@IBOutlet weak var campaignTitleLabel: UILabel!
@IBOutlet weak var curvedBgImage: UIImageView!
@IBOutlet weak var subtitleLabel: UILabel!
@IBOutlet weak var descriptionLabel: UILabel!
public override func awakeFromNib() {
super.awakeFromNib()
inboxView.layer.cornerRadius = 5.0
inboxView.clipsToBounds = true
newBadgeImage.image = UIImage(named: "new_icon", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil)
curvedBgImage.image = UIImage(named: "curved_bg_white", 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 ?? ""
subtitleLabel.text = campaign.subtitle ?? ""
descriptionLabel.text = campaign.message ?? ""
if (campaign.is_new ?? false) {
newBadgeImage.isHidden = false
}
}
}
......@@ -9,9 +9,87 @@ import Foundation
import UIKit
@objc public class MFYViewController: UIViewController {
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
@IBOutlet weak var mainView: UIView!
@IBOutlet weak var tableView: UITableView!
public var campaigns:Array<swiftApi.CampaignItemModel> = []
public override func viewDidLoad() {
super.viewDidLoad()
getCampaignsRequest()
setBackButton()
setNavigationTitle("More for you")
setNavigationTitle("MORE 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)
}
func getCampaignsRequest() {
swiftApi().getCampaignsAsync(getCampaignsCallback)
}
func getCampaignsCallback (_ campaignsData: Array<swiftApi.CampaignItemModel>?) -> Void {
if (campaignsData != nil) {
self.campaigns = campaignsData?.filter { $0.offer_category == "more_for_you" } ?? []
DispatchQueue.main.async {
self.tableView.reloadData()
swiftApi().setUniqueCampaignList(campaignsData ?? [])
}
} else {
self.campaigns = []
}
}
}
// MARK: - TableView
extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
public func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.campaigns.count
}
public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 220.0 + 10.0
// return UITableViewAutomaticDimension
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "MFYInboxTableViewCellId", for: indexPath) as! MFYInboxTableViewCell
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: "CampaignViewController") as! CampaignViewController
let url = swiftApi().constructCampaignUrl(campaigns[indexPath.row])
vc.campaignUrl = url
self.navigationController?.pushViewController(vc, animated: true)
}
}
......
{
"images" : [
{
"filename" : "curved_bg_white.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "curved_bg_white-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "curved_bg_white-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
......@@ -391,6 +391,7 @@ public class swiftApi {
public let session_uuid: String?
public let subcategory: String?
public let is_new: Bool?
public let message: String?
init(dictionary: [String: Any]) {
self.index_url = dictionary["index_url"] as? String? ?? ""
......@@ -400,6 +401,7 @@ public class swiftApi {
self.subtitle = dictionary["subtitle"] as? String? ?? ""
self.session_uuid = dictionary["session_uuid"] as? String? ?? ""
self.is_new = dictionary["is_new"] as? Bool? ?? false
self.message = dictionary["message"] as? String? ?? ""
// let extra_fields = dictionary["extra_fields"] as? [String: Any]? ?? ["":""]
let extra_fields = dictionary["extra_fields"] as AnyObject
......