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)
}
@IBAction func navigateToCoupon(_ sender: Any) {
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
}
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
}
}
}
......@@ -708,35 +708,106 @@
<scene sceneID="Rnz-IX-el9">
<objects>
<viewController storyboardIdentifier="GiftsViewController" id="wy8-hC-CyC" customClass="GiftsViewController" customModule="SwiftWarplyFramework" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="rgt-dj-Aiw">
<view key="view" contentMode="scaleToFill" id="bZT-ov-2Ec">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="th4-Ic-fA6">
<rect key="frame" x="144" y="207" width="129" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="Go to Campaign"/>
<connections>
<action selector="navigateToCampaign:" destination="wy8-hC-CyC" eventType="touchUpInside" id="iyc-W4-thN"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="XdG-16-mhI">
<rect key="frame" x="152" y="343" width="114" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="Go to Coupon"/>
<connections>
<action selector="navigateToCoupon:" destination="wy8-hC-CyC" eventType="touchUpInside" id="nC7-rM-ykm"/>
</connections>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="gxz-nY-dFI" userLabel="Main View">
<rect key="frame" x="0.0" y="44" width="414" height="852"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="-1" estimatedSectionHeaderHeight="-1" sectionFooterHeight="-1" estimatedSectionFooterHeight="-1" translatesAutoresizingMaskIntoConstraints="NO" id="Obj-Bh-L89">
<rect key="frame" x="0.0" y="0.0" width="414" height="852"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="sectionIndexBackgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" selectionStyle="none" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="InboxTableViewCellId" id="5x6-NG-BBQ" customClass="InboxTableViewCell" customModule="swift_example" customModuleProvider="target">
<rect key="frame" x="0.0" y="44.5" width="414" height="78"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="5x6-NG-BBQ" id="7Ha-bG-aYy">
<rect key="frame" x="0.0" y="0.0" width="414" height="78"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Dwe-Hj-Zch">
<rect key="frame" x="20" y="0.0" width="374" height="78"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="jxX-dy-R3y">
<rect key="frame" x="0.0" y="0.0" width="205.5" height="78"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="DIv-Ip-CVk">
<rect key="frame" x="215.5" y="30" width="148.5" height="18"/>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="15"/>
<color key="textColor" red="0.22745098039215686" green="0.32156862745098036" blue="0.40000000000000002" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="DIv-Ip-CVk" secondAttribute="trailing" constant="10" id="3Ra-7J-3mc"/>
<constraint firstItem="DIv-Ip-CVk" firstAttribute="top" relation="greaterThanOrEqual" secondItem="Dwe-Hj-Zch" secondAttribute="top" constant="30" id="4gb-ai-Z4U"/>
<constraint firstItem="jxX-dy-R3y" firstAttribute="top" secondItem="Dwe-Hj-Zch" secondAttribute="top" id="6D5-rD-SvW"/>
<constraint firstItem="jxX-dy-R3y" firstAttribute="width" secondItem="Dwe-Hj-Zch" secondAttribute="width" multiplier="0.55" id="K81-aj-j4r"/>
<constraint firstItem="DIv-Ip-CVk" firstAttribute="centerY" secondItem="Dwe-Hj-Zch" secondAttribute="centerY" id="QEv-hk-GVr"/>
<constraint firstItem="jxX-dy-R3y" firstAttribute="leading" secondItem="Dwe-Hj-Zch" secondAttribute="leading" id="RHe-qO-Hwg"/>
<constraint firstAttribute="bottom" secondItem="jxX-dy-R3y" secondAttribute="bottom" id="Ycw-mz-744"/>
<constraint firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="DIv-Ip-CVk" secondAttribute="bottom" constant="10" id="kK3-nP-Frz"/>
<constraint firstItem="DIv-Ip-CVk" firstAttribute="leading" secondItem="jxX-dy-R3y" secondAttribute="trailing" constant="10" id="qGm-0y-8bE"/>
</constraints>
</view>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="new_icon" translatesAutoresizingMaskIntoConstraints="NO" id="aDf-3m-BKi">
<rect key="frame" x="344" y="5" width="60" height="25"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" constant="60" id="5bq-j3-TCg"/>
<constraint firstAttribute="height" constant="25" id="UUf-Oq-uje"/>
</constraints>
</imageView>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="Dwe-Hj-Zch" firstAttribute="leading" secondItem="7Ha-bG-aYy" secondAttribute="leading" constant="20" id="8zR-mB-P7r"/>
<constraint firstAttribute="trailing" secondItem="Dwe-Hj-Zch" secondAttribute="trailing" constant="20" id="D4E-bL-z1v"/>
<constraint firstAttribute="trailing" secondItem="aDf-3m-BKi" secondAttribute="trailing" constant="10" id="DgX-6a-x4J"/>
<constraint firstAttribute="bottom" secondItem="Dwe-Hj-Zch" secondAttribute="bottom" id="YTZ-W0-f3J"/>
<constraint firstItem="aDf-3m-BKi" firstAttribute="top" secondItem="7Ha-bG-aYy" secondAttribute="top" constant="5" id="faK-LY-2yt"/>
<constraint firstItem="Dwe-Hj-Zch" firstAttribute="top" secondItem="7Ha-bG-aYy" secondAttribute="top" id="nZu-aa-PoD"/>
</constraints>
</tableViewCellContentView>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<connections>
<outlet property="campaignImage" destination="jxX-dy-R3y" id="Nbj-xj-cuo"/>
<outlet property="campaignTitleLabel" destination="DIv-Ip-CVk" id="IRs-SM-c5g"/>
<outlet property="inboxView" destination="Dwe-Hj-Zch" id="L4s-8d-8xb"/>
<outlet property="newBadgeImage" destination="aDf-3m-BKi" id="8cY-S2-Q13"/>
</connections>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="wy8-hC-CyC" id="X8l-qa-Opx"/>
<outlet property="delegate" destination="wy8-hC-CyC" id="mdR-Aj-QGh"/>
</connections>
</tableView>
</subviews>
<color key="backgroundColor" red="0.2196078431372549" green="0.32156862745098036" blue="0.40392156862745099" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="Obj-Bh-L89" firstAttribute="top" secondItem="gxz-nY-dFI" secondAttribute="top" id="ECw-Zp-2Tr"/>
<constraint firstAttribute="trailing" secondItem="Obj-Bh-L89" secondAttribute="trailing" id="M3y-23-abb"/>
<constraint firstAttribute="bottom" secondItem="Obj-Bh-L89" secondAttribute="bottom" id="lop-u2-nwa"/>
<constraint firstItem="Obj-Bh-L89" firstAttribute="leading" secondItem="gxz-nY-dFI" secondAttribute="leading" id="q6N-T6-U0n"/>
</constraints>
</view>
</subviews>
<viewLayoutGuide key="safeArea" id="8yz-fh-0GA"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<viewLayoutGuide key="safeArea" id="DnC-uL-X1U"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="gxz-nY-dFI" firstAttribute="leading" secondItem="bZT-ov-2Ec" secondAttribute="leading" id="SQu-vX-EiI"/>
<constraint firstAttribute="bottom" secondItem="gxz-nY-dFI" secondAttribute="bottom" id="UUU-4I-oNA"/>
<constraint firstAttribute="trailing" secondItem="gxz-nY-dFI" secondAttribute="trailing" id="fRa-H9-0ha"/>
<constraint firstItem="gxz-nY-dFI" firstAttribute="top" secondItem="DnC-uL-X1U" secondAttribute="top" id="hTP-dP-8pV"/>
</constraints>
</view>
<connections>
<outlet property="campaignButton" destination="th4-Ic-fA6" id="R8G-8Z-ngK"/>
<outlet property="couponButton" destination="XdG-16-mhI" id="tBd-RW-5Se"/>
<outlet property="mainView" destination="gxz-nY-dFI" id="nfd-vO-aaA"/>
<outlet property="tableView" destination="Obj-Bh-L89" id="5cL-tU-7Lw"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="YLX-2E-CQz" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
......@@ -1198,6 +1269,7 @@
<image name="dfy_logo_white" width="1611" height="395"/>
<image name="ic_background_circle" width="214" height="134"/>
<image name="ic_down_dark" width="22" height="11.5"/>
<image name="new_icon" width="37" height="17"/>
<image name="wallet_coupons" width="63" height="73"/>
<image name="wallet_dfy_earn" width="63" height="73"/>
<systemColor name="systemBackgroundColor">
......
{
"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
......