Manos Chorianopoulos

add CouponBarcodeViewController

......@@ -7,7 +7,7 @@
<key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>0</integer>
</dict>
</dict>
</dict>
......
......@@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
1E74838D28378AF40042A589 /* CouponBarcodeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E74838C28378AF40042A589 /* CouponBarcodeViewController.swift */; };
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 */; };
......@@ -138,6 +139,7 @@
/* End PBXBuildFile section */
/* 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>"; };
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>"; };
......@@ -324,6 +326,7 @@
E6A7785E282933E40045BBA8 /* CouponsViewController.swift */,
1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */,
E6A7785D282933E40045BBA8 /* CouponViewController.swift */,
1E74838C28378AF40042A589 /* CouponBarcodeViewController.swift */,
E6A77863282933E50045BBA8 /* DetailsViewController.swift */,
E6A778DE282933E60045BBA8 /* GiftsViewController.swift */,
E6A778DB282933E60045BBA8 /* MFYViewController.swift */,
......@@ -729,6 +732,7 @@
E6A7791E282933E60045BBA8 /* WLSMSActionHanlder.m in Sources */,
E6A778F5282933E60045BBA8 /* WLCustomNativeAdTableViewCell.m in Sources */,
E6A77901282933E60045BBA8 /* WLBaseItem.m in Sources */,
1E74838D28378AF40042A589 /* CouponBarcodeViewController.swift in Sources */,
E6A778F0282933E60045BBA8 /* WLNativeAdsCollectionMode.m in Sources */,
E6A7791C282933E60045BBA8 /* WLSMSActionHandlerDeprecated.m in Sources */,
E6A77934282933E70045BBA8 /* UIActivityIndicatorView+AFNetworking.m in Sources */,
......
......@@ -7,7 +7,7 @@
<key>SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
</dict>
</dict>
......
//
// CouponBarcodeViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 20/5/22.
//
import UIKit
import WarplySDKFrameworkIOS
@objc class CouponBarcodeViewController: UIViewController {
@IBOutlet weak var backgroundImage: UIImageView!
@IBOutlet weak var scrollView: UIScrollView!
@IBOutlet weak var scrollContentView: UIView!
@IBOutlet weak var couponImage: UIImageView!
@IBOutlet weak var couponImageHeight: NSLayoutConstraint!
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var discriptionLabel: UILabel!
@IBOutlet weak var couponView: UIView!
@IBOutlet weak var couponNumberLabel: UILabel!
@IBOutlet weak var barcodeLabel: UILabel!
@IBOutlet weak var expirationLabel: UILabel!
@IBOutlet weak var redeemButton: UIButton!
@IBOutlet weak var termsButton: UIButton!
@IBOutlet weak var termsTextView: UITextView!
@IBOutlet weak var termsTextViewHeight: NSLayoutConstraint!
let uiscreen: CGRect = UIScreen.main.bounds
var termsVisible: Bool = false;
var coupon: swiftApi.CouponItemModel?
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
setBackButton()
setNavigationTitle("Εκπτωτικό κουπόνι")
backgroundImage.image = UIImage(named: "coupons_scrollview_white")
scrollView.clipsToBounds = true
scrollView.layer.cornerRadius = 30
scrollView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius
// 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())
couponImage.contentMode = .scaleAspectFill
couponImageHeight.constant = self.uiscreen.height * 0.25
nameLabel.text = couponSetData?.name ?? ""
discriptionLabel.text = couponSetData?.short_description ?? ""
couponView.layer.cornerRadius = 10
couponNumberLabel.text = coupon?.coupon ?? ""
let barcodeString = constructBarcode() ?? ""
barcodeLabel.text = barcodeString
expirationLabel.text = "Το κουπόνι ισχύει έως " + (coupon?.expiration ?? "")
redeemButton.titleLabel?.font = UIFont.systemFont(ofSize: 15, weight: .medium)
termsButton.titleLabel?.font = .systemFont(ofSize: 15.0, weight: .semibold)
// termsButton.imageView?.layer.transform = CATransform3DMakeScale(1.5, 1.5, 1.5)
let htmlText = couponSetData?.terms ?? ""
termsTextView.attributedText = htmlText.htmlToAttributedString
termsTextView.font = UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.regular)
termsTextView.textColor = UIColor(red: 0.25, green: 0.33, blue: 0.39, alpha: 1.00)
termsTextView.textAlignment = .center
termsTextView.isScrollEnabled = false
toggleTerms()
}
// MARK: - Functions
func toggleTerms() {
if (termsVisible) {
termsTextView.isHidden = false
let targetSize = CGSize(width: termsTextView.frame.width, height: CGFloat(MAXFLOAT))
termsTextViewHeight.constant = termsTextView.sizeThatFits(targetSize).height
termsButton.setImage(UIImage(named: "ic_up_dark.png"), for: .normal)
} else {
termsTextView.isHidden = true
termsTextViewHeight.constant = CGFloat(0)
termsButton.setImage(UIImage(named: "ic_down_dark.png"), for: .normal)
}
}
func constructBarcode() -> String? {
// EAN 13 barcode construction
let couponData = coupon?.couponset_data
let couponString = coupon?.coupon ?? ""
if (!couponString.isEmpty) {
var checkDigit = 0;
var result = 0;
var fixedCouponCode = couponString;
if (fixedCouponCode.count < 12) {
let loops = 12 - fixedCouponCode.count;
var zerosStr = "";
for i in 0 ..< loops {
zerosStr += "0"
}
fixedCouponCode = zerosStr + fixedCouponCode;
}
var multiplier = 3;
for idx in (0 ... (fixedCouponCode.count - 1)).reversed() {
let curChar = fixedCouponCode[idx];
result += (Int(curChar) ?? 0) * multiplier;
multiplier = multiplier == 3 ? 1 : 3;
}
checkDigit = 10 - (result % 10);
let barcodeStr = fixedCouponCode + String(checkDigit);
return barcodeStr;
}
return ""
}
// MARK: - Actions
@IBAction func redeemButtomAction(_ sender: Any) {
// TODO: Add redeem action
let alert = UIAlertController(title: "Το κουπόνι σου ενεργοποιήθηκε", message: "Μπορείς να το βρεις στην αρχική οθόνη της εφαρμογής και στην ενότητα ενεργά δώρα!", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
print("default")
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
}))
self.present(alert, animated: true, completion: nil)
}
@IBAction func termsButtonAction(_ sender: Any) {
termsVisible = !termsVisible
toggleTerms()
}
}
......@@ -7,7 +7,7 @@
import UIKit
class CouponViewController: UIViewController {
@objc class CouponViewController: UIViewController {
@IBOutlet weak var mainView: UIView!
@IBOutlet weak var backgroundImage: UIImageView!
@IBOutlet weak var scrollView: UIScrollView!
......
......@@ -9,7 +9,7 @@ import Foundation
import UIKit
import WarplySDKFrameworkIOS
class CouponsTableViewCell: UITableViewCell {
@objc class CouponsTableViewCell: UITableViewCell {
@IBOutlet weak var couponBgImage: UIImageView!
@IBOutlet weak var couponImage: UIImageView!
@IBOutlet weak var borderView: UIView!
......
......@@ -315,6 +315,237 @@
</objects>
<point key="canvasLocation" x="1612" y="129"/>
</scene>
<!--Coupon Barcode View Controller-->
<scene sceneID="7Dn-sf-iEB">
<objects>
<viewController storyboardIdentifier="CouponBarcodeViewController" id="CDt-eI-msA" customClass="CouponBarcodeViewController" customModule="SwiftWarplyFramework" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="p8P-DP-0kH">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="P3Q-nP-aSj" 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_white" translatesAutoresizingMaskIntoConstraints="NO" id="B6L-Zs-Vnz">
<rect key="frame" x="0.0" y="0.0" width="414" height="852"/>
</imageView>
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" translatesAutoresizingMaskIntoConstraints="NO" id="D1m-2B-ehg">
<rect key="frame" x="0.0" y="5" width="414" height="847"/>
<subviews>
<view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="1ec-eH-fkX">
<rect key="frame" x="0.0" y="0.0" width="414" height="852"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="iiM-5P-m5s">
<rect key="frame" x="0.0" y="0.0" width="414" height="200"/>
<constraints>
<constraint firstAttribute="height" constant="200" id="kL0-u7-VI9"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Πάρε δωρεάν μηνιαία πακέτα με πάνες στα supermarket Σκλαβενίτης!" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Xz4-EE-EzJ">
<rect key="frame" x="20" y="230" width="374" height="38.5"/>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="16"/>
<color key="textColor" red="0.25490196079999999" green="0.33333333329999998" blue="0.3921568627" alpha="0.84705882349999995" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Χρησιμοποίησε τον παρακάτω κωδικό και πάρε δωρεάν πακέτο πάνες Pampers αποκλειστικά στα Supermarket Σκλαβενίτης" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mri-Wl-spg">
<rect key="frame" x="20" y="293.5" width="374" height="57.5"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" red="0.25490196079999999" green="0.33333333329999998" blue="0.3921568627" alpha="0.84705882349999995" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Κωδικός Κουπονιού" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Sg1-QU-FY1">
<rect key="frame" x="20" y="386" width="374" height="19.5"/>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="16"/>
<color key="textColor" red="0.25490196079999999" green="0.33333333329999998" blue="0.3921568627" alpha="0.84705882349999995" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Zdf-1r-FdJ" userLabel="Coupon View">
<rect key="frame" x="25" y="415.5" width="364" height="55"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="BJS-kk-CBZ">
<rect key="frame" x="10" y="11.5" width="344" height="32.5"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="27"/>
<color key="textColor" red="0.25490196078431371" green="0.33333333333333331" blue="0.39215686274509803" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" red="0.95686274509803915" green="0.95686274509803915" blue="0.95686274509803915" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="BJS-kk-CBZ" secondAttribute="trailing" constant="10" id="Adz-tK-JPK"/>
<constraint firstItem="BJS-kk-CBZ" firstAttribute="centerY" secondItem="Zdf-1r-FdJ" secondAttribute="centerY" id="WUs-XT-erR"/>
<constraint firstAttribute="height" constant="55" id="XVr-JP-U40"/>
<constraint firstItem="BJS-kk-CBZ" firstAttribute="leading" secondItem="Zdf-1r-FdJ" secondAttribute="leading" constant="10" id="dxa-Dc-OXI"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="jrM-7n-fSw" userLabel="Border View">
<rect key="frame" x="20" y="490.5" width="374" height="1"/>
<color key="backgroundColor" red="0.90196078431372551" green="0.90196078431372551" blue="0.90196078431372551" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="eF3-7T-hMu"/>
</constraints>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="8cR-Rc-YMJ">
<rect key="frame" x="83" y="646" width="248" height="50"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="ccg-NP-FIH"/>
</constraints>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="Κάντο δώρο!">
<backgroundConfiguration key="background" cornerRadius="12">
<color key="backgroundColor" red="0.47450980390000003" green="0.74901960779999999" blue="0.078431372550000003" alpha="0.84705882349999995" colorSpace="calibratedRGB"/>
</backgroundConfiguration>
<fontDescription key="titleFontDescription" type="system" weight="medium" pointSize="15"/>
<color key="baseForegroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</buttonConfiguration>
<connections>
<action selector="redeemButtomAction:" destination="CDt-eI-msA" eventType="touchUpInside" id="0pY-lD-17H"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="8UD-WL-JB7">
<rect key="frame" x="103.5" y="706" width="207" height="50"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="xdq-YS-AL4"/>
</constraints>
<inset key="imageEdgeInsets" minX="5" minY="0.0" maxX="0.0" maxY="0.0"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" image="ic_down_dark" imagePlacement="trailing" title="Όροι χρήσης" imagePadding="5">
<preferredSymbolConfiguration key="preferredSymbolConfigurationForImage"/>
<fontDescription key="titleFontDescription" type="system" weight="semibold" pointSize="15"/>
<color key="baseForegroundColor" red="0.25490196079999999" green="0.33333333329999998" blue="0.3921568627" alpha="0.84705882349999995" colorSpace="calibratedRGB"/>
</buttonConfiguration>
<connections>
<action selector="termsButtonAction:" destination="CDt-eI-msA" eventType="touchUpInside" id="zrs-az-yjI"/>
</connections>
</button>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" textAlignment="center" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="xjX-HZ-MpD">
<rect key="frame" x="20" y="766" width="374" height="0.0"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstAttribute="height" id="3GU-tg-S3t"/>
</constraints>
<color key="textColor" red="0.25490196079999999" green="0.33333333329999998" blue="0.3921568627" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
</textView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="123456789101112" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="EKv-Mx-6Yv">
<rect key="frame" x="20" y="511.5" width="374" height="26.5"/>
<fontDescription key="fontDescription" type="system" pointSize="22"/>
<color key="textColor" red="0.25490196079999999" green="0.33333333329999998" blue="0.3921568627" alpha="0.84705882349999995" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="6rV-2m-QMZ" userLabel="Border 2 View">
<rect key="frame" x="20" y="558" width="374" height="1"/>
<color key="backgroundColor" red="0.90196078430000004" green="0.90196078430000004" blue="0.90196078430000004" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="DVl-3B-zqo"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Το κουπόνι ισχύει έως 05/12/2022" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="UhC-Lj-tfN">
<rect key="frame" x="20" y="594" width="374" height="17"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.25490196079999999" green="0.33333333329999998" blue="0.3921568627" alpha="0.84705882349999995" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="jrM-7n-fSw" firstAttribute="leading" secondItem="1ec-eH-fkX" secondAttribute="leading" constant="20" id="0Dc-gr-Zfa"/>
<constraint firstAttribute="trailing" secondItem="Xz4-EE-EzJ" secondAttribute="trailing" constant="20" id="5Sx-lW-x5H"/>
<constraint firstItem="8cR-Rc-YMJ" firstAttribute="centerX" secondItem="1ec-eH-fkX" secondAttribute="centerX" id="8hP-dm-rWP"/>
<constraint firstItem="8cR-Rc-YMJ" firstAttribute="width" secondItem="1ec-eH-fkX" secondAttribute="width" multiplier="0.6" id="8kM-Og-K54"/>
<constraint firstItem="8UD-WL-JB7" firstAttribute="width" secondItem="1ec-eH-fkX" secondAttribute="width" multiplier="0.5" id="9Gy-bi-NXO"/>
<constraint firstItem="mri-Wl-spg" firstAttribute="top" secondItem="Xz4-EE-EzJ" secondAttribute="bottom" constant="25" id="9W8-fX-IzR"/>
<constraint firstItem="xjX-HZ-MpD" firstAttribute="leading" secondItem="1ec-eH-fkX" secondAttribute="leading" constant="20" id="AIW-Kf-tkQ"/>
<constraint firstItem="jrM-7n-fSw" firstAttribute="top" secondItem="Zdf-1r-FdJ" secondAttribute="bottom" constant="20" id="G5W-a3-pag"/>
<constraint firstItem="iiM-5P-m5s" firstAttribute="top" secondItem="1ec-eH-fkX" secondAttribute="top" id="H9I-TB-xig"/>
<constraint firstItem="8cR-Rc-YMJ" firstAttribute="top" secondItem="UhC-Lj-tfN" secondAttribute="bottom" constant="35" id="I87-km-KEb"/>
<constraint firstItem="Zdf-1r-FdJ" firstAttribute="top" secondItem="Sg1-QU-FY1" secondAttribute="bottom" constant="10" id="KZi-Jl-Yyz"/>
<constraint firstItem="UhC-Lj-tfN" firstAttribute="leading" secondItem="1ec-eH-fkX" secondAttribute="leading" constant="20" id="MSg-iF-tt9"/>
<constraint firstAttribute="trailing" secondItem="6rV-2m-QMZ" secondAttribute="trailing" constant="20" id="NGe-PV-pQl"/>
<constraint firstAttribute="trailing" secondItem="mri-Wl-spg" secondAttribute="trailing" constant="20" id="NmE-Pu-v1S"/>
<constraint firstAttribute="trailing" secondItem="EKv-Mx-6Yv" secondAttribute="trailing" constant="20" id="OeB-T7-87x"/>
<constraint firstItem="8UD-WL-JB7" firstAttribute="top" secondItem="8cR-Rc-YMJ" secondAttribute="bottom" constant="10" id="Rbe-XQ-CIj"/>
<constraint firstAttribute="trailing" secondItem="jrM-7n-fSw" secondAttribute="trailing" constant="20" id="ReY-xR-F8V"/>
<constraint firstItem="Xz4-EE-EzJ" firstAttribute="top" secondItem="iiM-5P-m5s" secondAttribute="bottom" constant="30" id="Ryr-v8-THU"/>
<constraint firstItem="xjX-HZ-MpD" firstAttribute="top" secondItem="8UD-WL-JB7" secondAttribute="bottom" constant="10" id="XFI-ij-KkC"/>
<constraint firstItem="mri-Wl-spg" firstAttribute="leading" secondItem="1ec-eH-fkX" secondAttribute="leading" constant="20" id="YLo-Lg-Lda"/>
<constraint firstItem="Zdf-1r-FdJ" firstAttribute="leading" secondItem="1ec-eH-fkX" secondAttribute="leading" constant="25" id="ZQd-cZ-JwO"/>
<constraint firstItem="6rV-2m-QMZ" firstAttribute="leading" secondItem="1ec-eH-fkX" secondAttribute="leading" constant="20" id="bcQ-yl-h1d"/>
<constraint firstAttribute="trailing" secondItem="Zdf-1r-FdJ" secondAttribute="trailing" constant="25" id="c0p-Op-6VI"/>
<constraint firstItem="Sg1-QU-FY1" firstAttribute="top" secondItem="mri-Wl-spg" secondAttribute="bottom" constant="35" id="dOs-ap-XJ4"/>
<constraint firstItem="iiM-5P-m5s" firstAttribute="leading" secondItem="1ec-eH-fkX" secondAttribute="leading" id="e6i-V3-Csq"/>
<constraint firstItem="8UD-WL-JB7" firstAttribute="centerX" secondItem="1ec-eH-fkX" secondAttribute="centerX" id="eFM-ex-Dye"/>
<constraint firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="8UD-WL-JB7" secondAttribute="bottom" constant="30" id="emI-WB-sXK"/>
<constraint firstItem="6rV-2m-QMZ" firstAttribute="top" secondItem="EKv-Mx-6Yv" secondAttribute="bottom" constant="20" id="hL4-rX-9aa"/>
<constraint firstItem="Sg1-QU-FY1" firstAttribute="leading" secondItem="1ec-eH-fkX" secondAttribute="leading" constant="20" id="hUh-Q7-uqi"/>
<constraint firstItem="EKv-Mx-6Yv" firstAttribute="top" secondItem="jrM-7n-fSw" secondAttribute="bottom" constant="20" id="hZO-Qg-tda"/>
<constraint firstItem="EKv-Mx-6Yv" firstAttribute="leading" secondItem="1ec-eH-fkX" secondAttribute="leading" constant="20" id="hf5-qR-yc9"/>
<constraint firstAttribute="trailing" secondItem="Sg1-QU-FY1" secondAttribute="trailing" constant="20" id="j1h-uw-6rC"/>
<constraint firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="xjX-HZ-MpD" secondAttribute="bottom" constant="30" id="kLr-ZV-vCo"/>
<constraint firstAttribute="trailing" secondItem="UhC-Lj-tfN" secondAttribute="trailing" constant="20" id="lM1-ep-Zec"/>
<constraint firstItem="Xz4-EE-EzJ" firstAttribute="leading" secondItem="1ec-eH-fkX" secondAttribute="leading" constant="20" id="lMf-pF-Bp6"/>
<constraint firstItem="UhC-Lj-tfN" firstAttribute="top" secondItem="6rV-2m-QMZ" secondAttribute="bottom" constant="35" id="ora-fw-TKe"/>
<constraint firstAttribute="trailing" secondItem="iiM-5P-m5s" secondAttribute="trailing" id="qWA-17-dEY"/>
<constraint firstAttribute="trailing" secondItem="xjX-HZ-MpD" secondAttribute="trailing" constant="20" id="rIc-bw-vfp"/>
</constraints>
</view>
</subviews>
<constraints>
<constraint firstItem="1ec-eH-fkX" firstAttribute="bottom" secondItem="4fu-Tq-CEO" secondAttribute="bottom" id="7sQ-jj-vME"/>
<constraint firstItem="1ec-eH-fkX" firstAttribute="trailing" secondItem="4fu-Tq-CEO" secondAttribute="trailing" id="Ec4-LO-JCy"/>
<constraint firstItem="1ec-eH-fkX" firstAttribute="top" secondItem="4fu-Tq-CEO" secondAttribute="top" id="VHa-ah-QOg"/>
<constraint firstItem="1ec-eH-fkX" firstAttribute="leading" secondItem="4fu-Tq-CEO" secondAttribute="leading" id="YB3-J0-DrC"/>
<constraint firstItem="1ec-eH-fkX" firstAttribute="width" secondItem="282-tV-FBh" secondAttribute="width" id="kai-Hd-WzK"/>
</constraints>
<viewLayoutGuide key="contentLayoutGuide" id="4fu-Tq-CEO"/>
<viewLayoutGuide key="frameLayoutGuide" id="282-tV-FBh"/>
</scrollView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="D1m-2B-ehg" firstAttribute="leading" secondItem="P3Q-nP-aSj" secondAttribute="leading" id="AMp-IG-CcQ"/>
<constraint firstItem="B6L-Zs-Vnz" firstAttribute="top" secondItem="P3Q-nP-aSj" secondAttribute="top" id="BfW-Mh-FDd"/>
<constraint firstItem="1ec-eH-fkX" firstAttribute="height" relation="greaterThanOrEqual" secondItem="P3Q-nP-aSj" secondAttribute="height" id="F9b-Gx-lxj"/>
<constraint firstAttribute="bottom" secondItem="B6L-Zs-Vnz" secondAttribute="bottom" id="OZW-L0-2gZ"/>
<constraint firstAttribute="trailing" secondItem="D1m-2B-ehg" secondAttribute="trailing" id="OZg-9O-qKw"/>
<constraint firstItem="D1m-2B-ehg" firstAttribute="top" secondItem="P3Q-nP-aSj" secondAttribute="top" constant="5" id="b1K-LA-UXY"/>
<constraint firstItem="B6L-Zs-Vnz" firstAttribute="leading" secondItem="P3Q-nP-aSj" secondAttribute="leading" id="oyw-NE-7bF"/>
<constraint firstAttribute="trailing" secondItem="B6L-Zs-Vnz" secondAttribute="trailing" id="twW-h7-cNb"/>
<constraint firstAttribute="bottom" secondItem="D1m-2B-ehg" secondAttribute="bottom" id="vw6-dc-3pg"/>
</constraints>
</view>
</subviews>
<viewLayoutGuide key="safeArea" id="mZk-p4-W2P"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="P3Q-nP-aSj" secondAttribute="bottom" id="Crs-cf-GBJ"/>
<constraint firstItem="P3Q-nP-aSj" firstAttribute="top" secondItem="mZk-p4-W2P" secondAttribute="top" id="mBZ-Rm-pNr"/>
<constraint firstAttribute="trailing" secondItem="P3Q-nP-aSj" secondAttribute="trailing" id="vm4-E2-JYa"/>
<constraint firstItem="P3Q-nP-aSj" firstAttribute="leading" secondItem="p8P-DP-0kH" secondAttribute="leading" id="vy0-c0-0FN"/>
</constraints>
</view>
<connections>
<outlet property="backgroundImage" destination="B6L-Zs-Vnz" id="0fs-sM-Khn"/>
<outlet property="barcodeLabel" destination="EKv-Mx-6Yv" id="myd-id-Q29"/>
<outlet property="couponImage" destination="iiM-5P-m5s" id="oKZ-Up-sI3"/>
<outlet property="couponImageHeight" destination="kL0-u7-VI9" id="QJ9-gs-XUh"/>
<outlet property="couponNumberLabel" destination="BJS-kk-CBZ" id="Sdz-3a-Jvq"/>
<outlet property="couponView" destination="Zdf-1r-FdJ" id="OA8-73-e0p"/>
<outlet property="discriptionLabel" destination="mri-Wl-spg" id="iuf-XL-NWH"/>
<outlet property="expirationLabel" destination="UhC-Lj-tfN" id="9Hj-I1-nJa"/>
<outlet property="nameLabel" destination="Xz4-EE-EzJ" id="zTY-n5-36h"/>
<outlet property="redeemButton" destination="8cR-Rc-YMJ" id="atB-0m-8ff"/>
<outlet property="scrollContentView" destination="1ec-eH-fkX" id="IZE-ie-TUA"/>
<outlet property="scrollView" destination="D1m-2B-ehg" id="dwz-JJ-dht"/>
<outlet property="termsButton" destination="8UD-WL-JB7" id="azl-dZ-6ey"/>
<outlet property="termsTextView" destination="xjX-HZ-MpD" id="8ZQ-e0-1Ib"/>
<outlet property="termsTextViewHeight" destination="3GU-tg-S3t" id="H3e-IQ-FGo"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="tvH-ht-75E" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2341" y="-555"/>
</scene>
<!--Coupon View Controller-->
<scene sceneID="yGm-Im-aAN">
<objects>
......
......@@ -64,6 +64,33 @@ extension String {
}
}
extension String {
var length: Int {
return count
}
subscript (i: Int) -> String {
return self[i ..< i + 1]
}
func substring(fromIndex: Int) -> String {
return self[min(fromIndex, length) ..< length]
}
func substring(toIndex: Int) -> String {
return self[0 ..< max(0, toIndex)]
}
subscript (r: Range<Int>) -> String {
let range = Range(uncheckedBounds: (lower: max(0, min(length, r.lowerBound)),
upper: min(length, max(0, r.upperBound))))
let start = index(startIndex, offsetBy: range.lowerBound)
let end = index(start, offsetBy: range.upperBound - range.lowerBound)
return String(self[start ..< end])
}
}
extension UIView {
func addDashedBorderVertical(color: UIColor, width: CGFloat, height: CGFloat) {
......