Manos Chorianopoulos

add CouponsViewController

Showing 17 changed files with 377 additions and 33 deletions
......@@ -7,7 +7,7 @@
<key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
</dict>
</dict>
......
......@@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
1EA1AF0A2835346A008998AA /* CouponsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */; };
7630AD9A6242D60846D6750C /* Pods_SwiftWarplyFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C0D5F56DD4E5371A50AD2D87 /* Pods_SwiftWarplyFramework.framework */; };
E6A77853282933340045BBA8 /* SwiftWarplyFramework.docc in Sources */ = {isa = PBXBuildFile; fileRef = E6A77852282933340045BBA8 /* SwiftWarplyFramework.docc */; };
E6A77854282933340045BBA8 /* SwiftWarplyFramework.h in Headers */ = {isa = PBXBuildFile; fileRef = E6A77851282933340045BBA8 /* SwiftWarplyFramework.h */; settings = {ATTRIBUTES = (Public, ); }; };
......@@ -137,6 +138,7 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponsTableViewCell.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; };
......@@ -320,6 +322,7 @@
isa = PBXGroup;
children = (
E6A7785E282933E40045BBA8 /* CouponsViewController.swift */,
1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */,
E6A7785D282933E40045BBA8 /* CouponViewController.swift */,
E6A77863282933E50045BBA8 /* DetailsViewController.swift */,
E6A778DE282933E60045BBA8 /* GiftsViewController.swift */,
......@@ -750,6 +753,7 @@
E6A77935282933E70045BBA8 /* UIWebView+AFNetworking.m in Sources */,
E6A77925282933E70045BBA8 /* UIProgressView+AFNetworking.m in Sources */,
E6A77944282933E70045BBA8 /* AFSecurityPolicy.m in Sources */,
1EA1AF0A2835346A008998AA /* CouponsTableViewCell.swift in Sources */,
E6A77A32282BA9C60045BBA8 /* CampaignViewController.swift in Sources */,
E6A77917282933E60045BBA8 /* UIViewController+WLAdditions.m in Sources */,
E6A77943282933E70045BBA8 /* AFNetworkReachabilityManager.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,6 +9,7 @@ import UIKit
class CouponViewController: UIViewController {
@IBOutlet weak var mainView: UIView!
@IBOutlet weak var backgroundImage: UIImageView!
@IBOutlet weak var scrollView: UIScrollView!
@IBOutlet weak var scrollContentView: UIView!
@IBOutlet weak var couponImageHeight: NSLayoutConstraint!
......@@ -28,6 +29,8 @@ class CouponViewController: UIViewController {
setBackButton()
setNavigationTitle("Εκπτωτικό κουπόνι")
backgroundImage.image = UIImage(named: "coupons_scrollview_white")
scrollView.clipsToBounds = true
scrollView.layer.cornerRadius = 30
scrollView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius
......
//
// CouponsTableViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 18/5/22.
//
import Foundation
import UIKit
import WarplySDKFrameworkIOS
class CouponsTableViewCell: UITableViewCell {
@IBOutlet weak var couponBgImage: UIImageView!
@IBOutlet weak var couponImage: UIImageView!
@IBOutlet weak var borderView: UIView!
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var dicountLabel: UILabel!
@IBOutlet weak var discriptionLabel: UILabel!
@IBOutlet weak var expirationLabel: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
couponBgImage.image = UIImage(named: "coupon_bg")
borderView.addDashedBorderVertical(color: UIColor(red: 0.44, green: 0.44, blue: 0.44, alpha: 1.00), width: 1.0, height: 110.0)
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
override func layoutSubviews() {
super.layoutSubviews()
//set the values for top,left,bottom,right margins
let margins = UIEdgeInsets(top: 0, left: 0, bottom: 30, right: 0)
contentView.frame = contentView.frame.inset(by: margins)
}
func configureCell(coupon: swiftApi.CouponItemModel) {
// COUPONSET: desc, img_preview, name, terms
// COUPON: coupon, expiration, discount, status
let couponSetData: swiftApi.CouponSetItemModel? = coupon.couponset_data
couponImage.load(link: couponSetData?.img_preview ?? "", placeholder: UIImage(), cache: URLCache())
nameLabel.text = couponSetData?.name ?? ""
dicountLabel.text = (coupon.discount ?? "") + "€"
discriptionLabel.text = couponSetData?.short_description ?? ""
expirationLabel.text = "Ισχύει έως "+(coupon.expiration ?? "")
}
}
......@@ -7,21 +7,86 @@
import Foundation
import UIKit
import WarplySDKFrameworkIOS
@objc public class CouponsViewController: UIViewController {
@IBOutlet weak var backgroundImage: UIImageView!
@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var couponButton: UIButton!
var coupons:Array<swiftApi.CouponItemModel> = []
override func viewDidLoad() {
super.viewDidLoad()
getCouponsRequest()
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
setBackButton()
setNavigationTitle("Εκπτωτικό κουπόνι")
setNavigationTitle("Ενεργά κουπόνια")
backgroundImage.image = UIImage(named: "coupons_scrollview_dark")
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
}
@IBAction func navigateToCoupon(_ sender: Any) {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "CouponViewController") as UIViewController
self.navigationController?.pushViewController(vc, animated: true)
// MARK: - API Functions
func getCouponsRequest() {
swiftApi().getCouponsAsync(getCouponsCallback)
}
func getCouponsCallback (_ couponsData: Array<swiftApi.CouponItemModel>?) -> Void {
if (couponsData != nil) {
let activeCouponData = swiftApi().filterActiveCoupons(couponsData ?? [])
self.coupons = activeCouponData
DispatchQueue.main.async {
self.tableView.reloadData()
}
} else {
self.coupons = []
}
}
}
// MARK: - TableView
extension CouponsViewController: UITableViewDelegate, UITableViewDataSource{
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.coupons.count
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 120.0 + 30.0
// return UITableViewAutomaticDimension
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CouponsTableViewCellId", for: indexPath) as! CouponsTableViewCell
cell.configureCell(coupon: coupons[indexPath.row])
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
// TODO: navigate to CouponBarcode
// let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
// let vc = storyboard.instantiateViewController(withIdentifier: "CouponBarcodeViewController") as UIViewController
// self.navigationController?.pushViewController(vc, animated: true)
}
}
......
......@@ -12,39 +12,159 @@
<!--Coupons View Controller-->
<scene sceneID="s0d-6b-0kx">
<objects>
<viewController storyboardIdentifier="CouponsViewController" id="zti-Lv-RCc" customClass="CouponsViewController" customModule="SwiftWarplyFramework" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="OHf-ga-xvH">
<viewController storyboardIdentifier="CouponsViewController" id="UpJ-ey-hJ5" customClass="CouponsViewController" customModule="SwiftWarplyFramework" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="XzS-AB-unt">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="coupons_scrollview" translatesAutoresizingMaskIntoConstraints="NO" id="t7M-3j-iFe">
<rect key="frame" x="0.0" y="88" width="414" height="808"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="FoX-v7-tak" userLabel="Main View">
<rect key="frame" x="0.0" y="44" width="414" height="852"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="coupons_scrollview_dark" translatesAutoresizingMaskIntoConstraints="NO" id="5rB-1e-ygb">
<rect key="frame" x="0.0" y="0.0" width="414" height="852"/>
</imageView>
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ebo-cU-G6Q">
<rect key="frame" x="0.0" y="88" width="414" height="808"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" allowsSelection="NO" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="-1" estimatedSectionHeaderHeight="-1" sectionFooterHeight="-1" estimatedSectionFooterHeight="-1" translatesAutoresizingMaskIntoConstraints="NO" id="KhH-tg-FBN">
<rect key="frame" x="0.0" y="5" width="414" height="847"/>
<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="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="CouponsTableViewCellId" id="Ivk-7o-eVp" customClass="CouponsTableViewCell" customModule="SwiftWarplyFramework" customModuleProvider="target">
<rect key="frame" x="0.0" y="44.5" width="414" height="115"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="Ivk-7o-eVp" id="OpF-ry-8Pc">
<rect key="frame" x="0.0" y="0.0" width="414" height="115"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Vy5-PH-dRI">
<rect key="frame" x="151" y="107" 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"/>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="JaN-ia-6ul">
<rect key="frame" x="10" y="0.0" width="394" height="115"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="coupon_bg" translatesAutoresizingMaskIntoConstraints="NO" id="2YB-QL-me8">
<rect key="frame" x="0.0" y="0.0" width="394" height="115"/>
</imageView>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="qgV-LI-5lL">
<rect key="frame" x="20" y="10" width="79" height="95"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</imageView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="kWi-pp-keF">
<rect key="frame" x="104" y="5" width="10" height="105"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" constant="10" id="UQ1-xk-Qqc"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gWw-Mr-bn2">
<rect key="frame" x="119" y="15" width="255" height="19.5"/>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="16"/>
<color key="textColor" red="0.22745098039215686" green="0.32156862745098036" blue="0.40000000000000002" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<stackView opaque="NO" contentMode="scaleToFill" spacing="5" translatesAutoresizingMaskIntoConstraints="NO" id="URC-i5-9Gw">
<rect key="frame" x="119" y="39.5" width="255" height="36"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ssk-9S-HMD">
<rect key="frame" x="0.0" y="0.0" width="127.5" height="36"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="30"/>
<color key="textColor" red="0.22745098039215686" green="0.32156862745098036" blue="0.40000000000000002" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="hWa-mr-cXD">
<rect key="frame" x="132.5" y="0.0" width="122.5" height="36"/>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="11"/>
<color key="textColor" red="0.38039215686274508" green="0.44313725490196076" blue="0.50588235294117645" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="Ssk-9S-HMD" firstAttribute="width" secondItem="URC-i5-9Gw" secondAttribute="width" multiplier="0.5" id="OLz-q3-DQc"/>
</constraints>
</stackView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Kdt-I2-GtS">
<rect key="frame" x="119" y="86.5" width="255" height="13.5"/>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="11"/>
<color key="textColor" red="0.38039215686274508" green="0.44313725490196076" blue="0.50588235294117645" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="Kdt-I2-GtS" firstAttribute="leading" secondItem="kWi-pp-keF" secondAttribute="trailing" constant="5" id="4H7-U6-dwU"/>
<constraint firstItem="kWi-pp-keF" firstAttribute="leading" secondItem="qgV-LI-5lL" secondAttribute="trailing" constant="5" id="7Oc-6i-WAJ"/>
<constraint firstAttribute="trailing" secondItem="Kdt-I2-GtS" secondAttribute="trailing" constant="20" id="87u-XE-PUf"/>
<constraint firstItem="URC-i5-9Gw" firstAttribute="leading" secondItem="kWi-pp-keF" secondAttribute="trailing" constant="5" id="CAI-TE-31b"/>
<constraint firstItem="gWw-Mr-bn2" firstAttribute="leading" secondItem="kWi-pp-keF" secondAttribute="trailing" constant="5" id="DIf-jd-4i9"/>
<constraint firstItem="2YB-QL-me8" firstAttribute="top" secondItem="JaN-ia-6ul" secondAttribute="top" id="Kg9-3h-9yX"/>
<constraint firstItem="gWw-Mr-bn2" firstAttribute="top" secondItem="JaN-ia-6ul" secondAttribute="top" constant="15" id="L2J-sA-Qyz"/>
<constraint firstAttribute="trailing" secondItem="2YB-QL-me8" secondAttribute="trailing" id="LKX-8Q-weK"/>
<constraint firstItem="kWi-pp-keF" firstAttribute="top" secondItem="JaN-ia-6ul" secondAttribute="top" constant="5" id="Nw1-Du-inS"/>
<constraint firstAttribute="bottom" secondItem="2YB-QL-me8" secondAttribute="bottom" id="QuD-tm-o3p"/>
<constraint firstItem="2YB-QL-me8" firstAttribute="leading" secondItem="JaN-ia-6ul" secondAttribute="leading" id="RGp-Mx-kq9"/>
<constraint firstAttribute="trailing" secondItem="URC-i5-9Gw" secondAttribute="trailing" constant="20" id="X88-Je-614"/>
<constraint firstAttribute="bottom" secondItem="Kdt-I2-GtS" secondAttribute="bottom" constant="15" id="YOO-8b-oBD"/>
<constraint firstItem="qgV-LI-5lL" firstAttribute="leading" secondItem="JaN-ia-6ul" secondAttribute="leading" constant="20" id="Zz2-s3-Lli"/>
<constraint firstItem="URC-i5-9Gw" firstAttribute="top" relation="greaterThanOrEqual" secondItem="gWw-Mr-bn2" secondAttribute="bottom" constant="5" id="gv1-5w-f05"/>
<constraint firstItem="URC-i5-9Gw" firstAttribute="centerY" secondItem="JaN-ia-6ul" secondAttribute="centerY" id="lCc-I4-VSe"/>
<constraint firstAttribute="bottom" secondItem="kWi-pp-keF" secondAttribute="bottom" constant="5" id="mqK-8D-WIR"/>
<constraint firstAttribute="trailing" secondItem="gWw-Mr-bn2" secondAttribute="trailing" constant="20" id="oL8-6u-dOS"/>
<constraint firstItem="qgV-LI-5lL" firstAttribute="width" secondItem="JaN-ia-6ul" secondAttribute="width" multiplier="0.2" id="pqq-lg-4bn"/>
<constraint firstItem="Kdt-I2-GtS" firstAttribute="top" relation="greaterThanOrEqual" secondItem="URC-i5-9Gw" secondAttribute="bottom" constant="5" id="rGz-OI-ook"/>
<constraint firstAttribute="bottom" secondItem="qgV-LI-5lL" secondAttribute="bottom" constant="10" id="ryN-Yr-NRM"/>
<constraint firstItem="qgV-LI-5lL" firstAttribute="top" secondItem="JaN-ia-6ul" secondAttribute="top" constant="10" id="z0W-2B-JKp"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="JaN-ia-6ul" secondAttribute="trailing" constant="10" id="1eX-rz-i5G"/>
<constraint firstItem="JaN-ia-6ul" firstAttribute="leading" secondItem="OpF-ry-8Pc" secondAttribute="leading" constant="10" id="XJA-hx-mRX"/>
<constraint firstItem="JaN-ia-6ul" firstAttribute="top" secondItem="OpF-ry-8Pc" secondAttribute="top" id="bxl-4U-Dqm"/>
<constraint firstAttribute="bottom" secondItem="JaN-ia-6ul" secondAttribute="bottom" id="zeG-7a-iyk"/>
</constraints>
</tableViewCellContentView>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<connections>
<action selector="navigateToCoupon:" destination="zti-Lv-RCc" eventType="touchUpInside" id="G78-ub-QiI"/>
<outlet property="borderView" destination="kWi-pp-keF" id="j4k-29-fIC"/>
<outlet property="couponBgImage" destination="2YB-QL-me8" id="nCY-Ir-Nkb"/>
<outlet property="couponImage" destination="qgV-LI-5lL" id="am7-DT-7Ln"/>
<outlet property="dicountLabel" destination="Ssk-9S-HMD" id="WS3-nG-Sue"/>
<outlet property="discriptionLabel" destination="hWa-mr-cXD" id="q6c-pM-iXa"/>
<outlet property="expirationLabel" destination="Kdt-I2-GtS" id="cYp-01-3RL"/>
<outlet property="nameLabel" destination="gWw-Mr-bn2" id="rT2-kW-Z2F"/>
</connections>
</button>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="UpJ-ey-hJ5" id="paH-E4-ldj"/>
<outlet property="delegate" destination="UpJ-ey-hJ5" id="lXT-i0-gPS"/>
</connections>
</tableView>
</subviews>
<viewLayoutGuide key="contentLayoutGuide" id="gl4-uV-tMn"/>
<viewLayoutGuide key="frameLayoutGuide" id="5Jr-wv-06A"/>
</scrollView>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="KhH-tg-FBN" firstAttribute="top" secondItem="FoX-v7-tak" secondAttribute="top" constant="5" id="DSl-zy-v7y"/>
<constraint firstAttribute="bottom" secondItem="KhH-tg-FBN" secondAttribute="bottom" id="Dk8-ID-x8T"/>
<constraint firstItem="5rB-1e-ygb" firstAttribute="top" secondItem="FoX-v7-tak" secondAttribute="top" id="R4t-dF-JMv"/>
<constraint firstItem="5rB-1e-ygb" firstAttribute="leading" secondItem="FoX-v7-tak" secondAttribute="leading" id="Yyu-T7-XaB"/>
<constraint firstAttribute="trailing" secondItem="5rB-1e-ygb" secondAttribute="trailing" id="h1f-x6-eGo"/>
<constraint firstAttribute="bottom" secondItem="5rB-1e-ygb" secondAttribute="bottom" id="mFa-RR-qQj"/>
<constraint firstItem="KhH-tg-FBN" firstAttribute="leading" secondItem="FoX-v7-tak" secondAttribute="leading" id="oXI-zv-0nB"/>
<constraint firstAttribute="trailing" secondItem="KhH-tg-FBN" secondAttribute="trailing" id="tAn-PH-mZ8"/>
</constraints>
</view>
</subviews>
<viewLayoutGuide key="safeArea" id="x1D-HA-Wfd"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<viewLayoutGuide key="safeArea" id="KbU-RX-se5"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="FoX-v7-tak" firstAttribute="leading" secondItem="XzS-AB-unt" secondAttribute="leading" id="FRE-tf-mAG"/>
<constraint firstAttribute="bottom" secondItem="FoX-v7-tak" secondAttribute="bottom" id="UlL-zJ-mdc"/>
<constraint firstItem="FoX-v7-tak" firstAttribute="top" secondItem="KbU-RX-se5" secondAttribute="top" id="hDd-5D-Boi"/>
<constraint firstAttribute="trailing" secondItem="FoX-v7-tak" secondAttribute="trailing" id="nro-Jt-pxP"/>
</constraints>
</view>
<navigationItem key="navigationItem" id="YHq-Mi-XvW"/>
<navigationItem key="navigationItem" id="mr8-UG-4rX"/>
<connections>
<outlet property="couponButton" destination="Vy5-PH-dRI" id="wX5-IH-ne8"/>
<outlet property="backgroundImage" destination="5rB-1e-ygb" id="Nxt-Pj-vLK"/>
<outlet property="tableView" destination="KhH-tg-FBN" id="EJH-sF-YPj"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="N1c-BM-LqY" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
......@@ -306,6 +426,7 @@
</constraints>
</view>
<connections>
<outlet property="backgroundImage" destination="Oep-XD-blB" id="YaT-qr-rry"/>
<outlet property="couponImageHeight" destination="zUx-Yd-in7" id="7vo-8L-d8o"/>
<outlet property="mainView" destination="Jqu-cp-CWU" id="Q0Z-dO-MXL"/>
<outlet property="redeemButton" destination="FCd-hv-dHg" id="3Jw-Yn-uNr"/>
......@@ -366,7 +487,8 @@
</scene>
</scenes>
<resources>
<image name="coupons_scrollview" width="214" height="463.5"/>
<image name="coupon_bg" width="196" height="64.5"/>
<image name="coupons_scrollview_dark" width="214" height="462"/>
<image name="coupons_scrollview_white" width="214" height="462"/>
<image name="ic_down_dark" width="22" height="11.5"/>
<systemColor name="systemBackgroundColor">
......
{
"images" : [
{
"filename" : "coupon_bg.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "coupon_bg-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "coupon_bg-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "coupons_scrollview_dark.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "coupons_scrollview_dark-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "coupons_scrollview_dark-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
......@@ -63,3 +63,49 @@ extension String {
return htmlToAttributedString?.string ?? ""
}
}
extension UIView {
func addDashedBorderVertical(color: UIColor, width: CGFloat, height: CGFloat) {
let color = color.cgColor
let frameSize = self.frame.size
let lineLayer = CAShapeLayer()
lineLayer.strokeColor = color
lineLayer.lineWidth = width
lineLayer.lineDashPattern = [5,5]
let path = CGMutablePath()
path.addLines(between: [CGPoint(x: frameSize.width/2, y: 0), CGPoint(x: frameSize.width/2, y: height)])
lineLayer.path = path
self.layer.addSublayer(lineLayer)
}
}
extension UIImageView {
func load(link: String, placeholder: UIImage?, cache: URLCache? = nil) {
guard let url = URL(string: link) else { return }
let cache = cache ?? URLCache.shared
let request = URLRequest(url: url)
if let data = cache.cachedResponse(for: request)?.data, let image = UIImage(data: data) {
DispatchQueue.main.async {
self.image = image
}
} else {
self.image = placeholder
URLSession.shared.dataTask(with: request, completionHandler: { (data, response, error) in
if let data = data, let response = response, ((response as? HTTPURLResponse)?.statusCode ?? 500) < 300, let image = UIImage(data: data) {
let cachedData = CachedURLResponse(response: response, data: data)
cache.storeCachedResponse(cachedData, for: request)
DispatchQueue.main.async {
self.image = image
}
}
}).resume()
}
}
}
......