Manos Chorianopoulos

add CouponBarcodeViewController

...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
7 <key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key> 7 <key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key>
8 <dict> 8 <dict>
9 <key>orderHint</key> 9 <key>orderHint</key>
10 - <integer>1</integer> 10 + <integer>0</integer>
11 </dict> 11 </dict>
12 </dict> 12 </dict>
13 </dict> 13 </dict>
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
7 objects = { 7 objects = {
8 8
9 /* Begin PBXBuildFile section */ 9 /* Begin PBXBuildFile section */
10 + 1E74838D28378AF40042A589 /* CouponBarcodeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E74838C28378AF40042A589 /* CouponBarcodeViewController.swift */; };
10 1EA1AF0A2835346A008998AA /* CouponsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */; }; 11 1EA1AF0A2835346A008998AA /* CouponsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */; };
11 7630AD9A6242D60846D6750C /* Pods_SwiftWarplyFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C0D5F56DD4E5371A50AD2D87 /* Pods_SwiftWarplyFramework.framework */; }; 12 7630AD9A6242D60846D6750C /* Pods_SwiftWarplyFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C0D5F56DD4E5371A50AD2D87 /* Pods_SwiftWarplyFramework.framework */; };
12 E6A77853282933340045BBA8 /* SwiftWarplyFramework.docc in Sources */ = {isa = PBXBuildFile; fileRef = E6A77852282933340045BBA8 /* SwiftWarplyFramework.docc */; }; 13 E6A77853282933340045BBA8 /* SwiftWarplyFramework.docc in Sources */ = {isa = PBXBuildFile; fileRef = E6A77852282933340045BBA8 /* SwiftWarplyFramework.docc */; };
...@@ -138,6 +139,7 @@ ...@@ -138,6 +139,7 @@
138 /* End PBXBuildFile section */ 139 /* End PBXBuildFile section */
139 140
140 /* Begin PBXFileReference section */ 141 /* Begin PBXFileReference section */
142 + 1E74838C28378AF40042A589 /* CouponBarcodeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponBarcodeViewController.swift; sourceTree = "<group>"; };
141 1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponsTableViewCell.swift; sourceTree = "<group>"; }; 143 1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponsTableViewCell.swift; sourceTree = "<group>"; };
142 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>"; }; 144 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>"; };
143 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>"; }; 145 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 @@ ...@@ -324,6 +326,7 @@
324 E6A7785E282933E40045BBA8 /* CouponsViewController.swift */, 326 E6A7785E282933E40045BBA8 /* CouponsViewController.swift */,
325 1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */, 327 1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */,
326 E6A7785D282933E40045BBA8 /* CouponViewController.swift */, 328 E6A7785D282933E40045BBA8 /* CouponViewController.swift */,
329 + 1E74838C28378AF40042A589 /* CouponBarcodeViewController.swift */,
327 E6A77863282933E50045BBA8 /* DetailsViewController.swift */, 330 E6A77863282933E50045BBA8 /* DetailsViewController.swift */,
328 E6A778DE282933E60045BBA8 /* GiftsViewController.swift */, 331 E6A778DE282933E60045BBA8 /* GiftsViewController.swift */,
329 E6A778DB282933E60045BBA8 /* MFYViewController.swift */, 332 E6A778DB282933E60045BBA8 /* MFYViewController.swift */,
...@@ -729,6 +732,7 @@ ...@@ -729,6 +732,7 @@
729 E6A7791E282933E60045BBA8 /* WLSMSActionHanlder.m in Sources */, 732 E6A7791E282933E60045BBA8 /* WLSMSActionHanlder.m in Sources */,
730 E6A778F5282933E60045BBA8 /* WLCustomNativeAdTableViewCell.m in Sources */, 733 E6A778F5282933E60045BBA8 /* WLCustomNativeAdTableViewCell.m in Sources */,
731 E6A77901282933E60045BBA8 /* WLBaseItem.m in Sources */, 734 E6A77901282933E60045BBA8 /* WLBaseItem.m in Sources */,
735 + 1E74838D28378AF40042A589 /* CouponBarcodeViewController.swift in Sources */,
732 E6A778F0282933E60045BBA8 /* WLNativeAdsCollectionMode.m in Sources */, 736 E6A778F0282933E60045BBA8 /* WLNativeAdsCollectionMode.m in Sources */,
733 E6A7791C282933E60045BBA8 /* WLSMSActionHandlerDeprecated.m in Sources */, 737 E6A7791C282933E60045BBA8 /* WLSMSActionHandlerDeprecated.m in Sources */,
734 E6A77934282933E70045BBA8 /* UIActivityIndicatorView+AFNetworking.m in Sources */, 738 E6A77934282933E70045BBA8 /* UIActivityIndicatorView+AFNetworking.m in Sources */,
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
7 <key>SwiftWarplyFramework.xcscheme_^#shared#^_</key> 7 <key>SwiftWarplyFramework.xcscheme_^#shared#^_</key>
8 <dict> 8 <dict>
9 <key>orderHint</key> 9 <key>orderHint</key>
10 - <integer>0</integer> 10 + <integer>1</integer>
11 </dict> 11 </dict>
12 </dict> 12 </dict>
13 </dict> 13 </dict>
......
1 +//
2 +// CouponBarcodeViewController.swift
3 +// SwiftWarplyFramework
4 +//
5 +// Created by Manos Chorianopoulos on 20/5/22.
6 +//
7 +
8 +import UIKit
9 +import WarplySDKFrameworkIOS
10 +
11 +@objc class CouponBarcodeViewController: UIViewController {
12 + @IBOutlet weak var backgroundImage: UIImageView!
13 + @IBOutlet weak var scrollView: UIScrollView!
14 + @IBOutlet weak var scrollContentView: UIView!
15 + @IBOutlet weak var couponImage: UIImageView!
16 + @IBOutlet weak var couponImageHeight: NSLayoutConstraint!
17 + @IBOutlet weak var nameLabel: UILabel!
18 + @IBOutlet weak var discriptionLabel: UILabel!
19 + @IBOutlet weak var couponView: UIView!
20 + @IBOutlet weak var couponNumberLabel: UILabel!
21 + @IBOutlet weak var barcodeLabel: UILabel!
22 + @IBOutlet weak var expirationLabel: UILabel!
23 + @IBOutlet weak var redeemButton: UIButton!
24 + @IBOutlet weak var termsButton: UIButton!
25 + @IBOutlet weak var termsTextView: UITextView!
26 + @IBOutlet weak var termsTextViewHeight: NSLayoutConstraint!
27 +
28 + let uiscreen: CGRect = UIScreen.main.bounds
29 +
30 + var termsVisible: Bool = false;
31 +
32 + var coupon: swiftApi.CouponItemModel?
33 +
34 + override func viewDidLoad() {
35 + super.viewDidLoad()
36 +
37 + // Do any additional setup after loading the view.
38 + setBackButton()
39 + setNavigationTitle("Εκπτωτικό κουπόνι")
40 +
41 + backgroundImage.image = UIImage(named: "coupons_scrollview_white")
42 +
43 + scrollView.clipsToBounds = true
44 + scrollView.layer.cornerRadius = 30
45 + scrollView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius
46 +
47 + // COUPONSET: desc, img_preview, name, terms
48 + // COUPON: coupon, expiration, discount, status
49 +
50 + let couponSetData: swiftApi.CouponSetItemModel? = coupon?.couponset_data
51 +
52 + couponImage.load(link: couponSetData?.img_preview ?? "", placeholder: UIImage(), cache: URLCache())
53 + couponImage.contentMode = .scaleAspectFill
54 + couponImageHeight.constant = self.uiscreen.height * 0.25
55 +
56 + nameLabel.text = couponSetData?.name ?? ""
57 + discriptionLabel.text = couponSetData?.short_description ?? ""
58 +
59 + couponView.layer.cornerRadius = 10
60 + couponNumberLabel.text = coupon?.coupon ?? ""
61 +
62 + let barcodeString = constructBarcode() ?? ""
63 + barcodeLabel.text = barcodeString
64 +
65 + expirationLabel.text = "Το κουπόνι ισχύει έως " + (coupon?.expiration ?? "")
66 +
67 + redeemButton.titleLabel?.font = UIFont.systemFont(ofSize: 15, weight: .medium)
68 +
69 + termsButton.titleLabel?.font = .systemFont(ofSize: 15.0, weight: .semibold)
70 +// termsButton.imageView?.layer.transform = CATransform3DMakeScale(1.5, 1.5, 1.5)
71 +
72 + let htmlText = couponSetData?.terms ?? ""
73 + termsTextView.attributedText = htmlText.htmlToAttributedString
74 + termsTextView.font = UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.regular)
75 + termsTextView.textColor = UIColor(red: 0.25, green: 0.33, blue: 0.39, alpha: 1.00)
76 + termsTextView.textAlignment = .center
77 + termsTextView.isScrollEnabled = false
78 +
79 + toggleTerms()
80 +
81 + }
82 +
83 + // MARK: - Functions
84 + func toggleTerms() {
85 + if (termsVisible) {
86 + termsTextView.isHidden = false
87 + let targetSize = CGSize(width: termsTextView.frame.width, height: CGFloat(MAXFLOAT))
88 + termsTextViewHeight.constant = termsTextView.sizeThatFits(targetSize).height
89 +
90 + termsButton.setImage(UIImage(named: "ic_up_dark.png"), for: .normal)
91 + } else {
92 + termsTextView.isHidden = true
93 + termsTextViewHeight.constant = CGFloat(0)
94 +
95 + termsButton.setImage(UIImage(named: "ic_down_dark.png"), for: .normal)
96 + }
97 + }
98 +
99 + func constructBarcode() -> String? {
100 + // EAN 13 barcode construction
101 + let couponData = coupon?.couponset_data
102 + let couponString = coupon?.coupon ?? ""
103 +
104 + if (!couponString.isEmpty) {
105 + var checkDigit = 0;
106 + var result = 0;
107 +
108 + var fixedCouponCode = couponString;
109 + if (fixedCouponCode.count < 12) {
110 + let loops = 12 - fixedCouponCode.count;
111 + var zerosStr = "";
112 + for i in 0 ..< loops {
113 + zerosStr += "0"
114 + }
115 + fixedCouponCode = zerosStr + fixedCouponCode;
116 + }
117 +
118 + var multiplier = 3;
119 + for idx in (0 ... (fixedCouponCode.count - 1)).reversed() {
120 + let curChar = fixedCouponCode[idx];
121 + result += (Int(curChar) ?? 0) * multiplier;
122 + multiplier = multiplier == 3 ? 1 : 3;
123 + }
124 + checkDigit = 10 - (result % 10);
125 +
126 + let barcodeStr = fixedCouponCode + String(checkDigit);
127 + return barcodeStr;
128 + }
129 +
130 + return ""
131 + }
132 +
133 + // MARK: - Actions
134 +
135 + @IBAction func redeemButtomAction(_ sender: Any) {
136 + // TODO: Add redeem action
137 +
138 + let alert = UIAlertController(title: "Το κουπόνι σου ενεργοποιήθηκε", message: "Μπορείς να το βρεις στην αρχική οθόνη της εφαρμογής και στην ενότητα ενεργά δώρα!", preferredStyle: .alert)
139 + alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
140 + switch action.style{
141 + case .default:
142 + print("default")
143 +
144 + case .cancel:
145 + print("cancel")
146 +
147 + case .destructive:
148 + print("destructive")
149 +
150 + }
151 + }))
152 + self.present(alert, animated: true, completion: nil)
153 + }
154 +
155 + @IBAction func termsButtonAction(_ sender: Any) {
156 + termsVisible = !termsVisible
157 + toggleTerms()
158 + }
159 +}
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
7 7
8 import UIKit 8 import UIKit
9 9
10 -class CouponViewController: UIViewController { 10 +@objc class CouponViewController: UIViewController {
11 @IBOutlet weak var mainView: UIView! 11 @IBOutlet weak var mainView: UIView!
12 @IBOutlet weak var backgroundImage: UIImageView! 12 @IBOutlet weak var backgroundImage: UIImageView!
13 @IBOutlet weak var scrollView: UIScrollView! 13 @IBOutlet weak var scrollView: UIScrollView!
......
...@@ -9,7 +9,7 @@ import Foundation ...@@ -9,7 +9,7 @@ import Foundation
9 import UIKit 9 import UIKit
10 import WarplySDKFrameworkIOS 10 import WarplySDKFrameworkIOS
11 11
12 -class CouponsTableViewCell: UITableViewCell { 12 +@objc class CouponsTableViewCell: UITableViewCell {
13 @IBOutlet weak var couponBgImage: UIImageView! 13 @IBOutlet weak var couponBgImage: UIImageView!
14 @IBOutlet weak var couponImage: UIImageView! 14 @IBOutlet weak var couponImage: UIImageView!
15 @IBOutlet weak var borderView: UIView! 15 @IBOutlet weak var borderView: UIView!
......
...@@ -315,6 +315,237 @@ ...@@ -315,6 +315,237 @@
315 </objects> 315 </objects>
316 <point key="canvasLocation" x="1612" y="129"/> 316 <point key="canvasLocation" x="1612" y="129"/>
317 </scene> 317 </scene>
318 + <!--Coupon Barcode View Controller-->
319 + <scene sceneID="7Dn-sf-iEB">
320 + <objects>
321 + <viewController storyboardIdentifier="CouponBarcodeViewController" id="CDt-eI-msA" customClass="CouponBarcodeViewController" customModule="SwiftWarplyFramework" customModuleProvider="target" sceneMemberID="viewController">
322 + <view key="view" contentMode="scaleToFill" id="p8P-DP-0kH">
323 + <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
324 + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
325 + <subviews>
326 + <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="P3Q-nP-aSj" userLabel="Main View">
327 + <rect key="frame" x="0.0" y="44" width="414" height="852"/>
328 + <subviews>
329 + <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="coupons_scrollview_white" translatesAutoresizingMaskIntoConstraints="NO" id="B6L-Zs-Vnz">
330 + <rect key="frame" x="0.0" y="0.0" width="414" height="852"/>
331 + </imageView>
332 + <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" translatesAutoresizingMaskIntoConstraints="NO" id="D1m-2B-ehg">
333 + <rect key="frame" x="0.0" y="5" width="414" height="847"/>
334 + <subviews>
335 + <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="1ec-eH-fkX">
336 + <rect key="frame" x="0.0" y="0.0" width="414" height="852"/>
337 + <subviews>
338 + <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="iiM-5P-m5s">
339 + <rect key="frame" x="0.0" y="0.0" width="414" height="200"/>
340 + <constraints>
341 + <constraint firstAttribute="height" constant="200" id="kL0-u7-VI9"/>
342 + </constraints>
343 + </imageView>
344 + <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">
345 + <rect key="frame" x="20" y="230" width="374" height="38.5"/>
346 + <fontDescription key="fontDescription" type="system" weight="semibold" pointSize="16"/>
347 + <color key="textColor" red="0.25490196079999999" green="0.33333333329999998" blue="0.3921568627" alpha="0.84705882349999995" colorSpace="calibratedRGB"/>
348 + <nil key="highlightedColor"/>
349 + </label>
350 + <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">
351 + <rect key="frame" x="20" y="293.5" width="374" height="57.5"/>
352 + <fontDescription key="fontDescription" type="system" pointSize="16"/>
353 + <color key="textColor" red="0.25490196079999999" green="0.33333333329999998" blue="0.3921568627" alpha="0.84705882349999995" colorSpace="calibratedRGB"/>
354 + <nil key="highlightedColor"/>
355 + </label>
356 + <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">
357 + <rect key="frame" x="20" y="386" width="374" height="19.5"/>
358 + <fontDescription key="fontDescription" type="system" weight="semibold" pointSize="16"/>
359 + <color key="textColor" red="0.25490196079999999" green="0.33333333329999998" blue="0.3921568627" alpha="0.84705882349999995" colorSpace="calibratedRGB"/>
360 + <nil key="highlightedColor"/>
361 + </label>
362 + <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Zdf-1r-FdJ" userLabel="Coupon View">
363 + <rect key="frame" x="25" y="415.5" width="364" height="55"/>
364 + <subviews>
365 + <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">
366 + <rect key="frame" x="10" y="11.5" width="344" height="32.5"/>
367 + <fontDescription key="fontDescription" type="boldSystem" pointSize="27"/>
368 + <color key="textColor" red="0.25490196078431371" green="0.33333333333333331" blue="0.39215686274509803" alpha="1" colorSpace="calibratedRGB"/>
369 + <nil key="highlightedColor"/>
370 + </label>
371 + </subviews>
372 + <color key="backgroundColor" red="0.95686274509803915" green="0.95686274509803915" blue="0.95686274509803915" alpha="1" colorSpace="calibratedRGB"/>
373 + <constraints>
374 + <constraint firstAttribute="trailing" secondItem="BJS-kk-CBZ" secondAttribute="trailing" constant="10" id="Adz-tK-JPK"/>
375 + <constraint firstItem="BJS-kk-CBZ" firstAttribute="centerY" secondItem="Zdf-1r-FdJ" secondAttribute="centerY" id="WUs-XT-erR"/>
376 + <constraint firstAttribute="height" constant="55" id="XVr-JP-U40"/>
377 + <constraint firstItem="BJS-kk-CBZ" firstAttribute="leading" secondItem="Zdf-1r-FdJ" secondAttribute="leading" constant="10" id="dxa-Dc-OXI"/>
378 + </constraints>
379 + </view>
380 + <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="jrM-7n-fSw" userLabel="Border View">
381 + <rect key="frame" x="20" y="490.5" width="374" height="1"/>
382 + <color key="backgroundColor" red="0.90196078431372551" green="0.90196078431372551" blue="0.90196078431372551" alpha="1" colorSpace="calibratedRGB"/>
383 + <constraints>
384 + <constraint firstAttribute="height" constant="1" id="eF3-7T-hMu"/>
385 + </constraints>
386 + </view>
387 + <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="8cR-Rc-YMJ">
388 + <rect key="frame" x="83" y="646" width="248" height="50"/>
389 + <constraints>
390 + <constraint firstAttribute="height" constant="50" id="ccg-NP-FIH"/>
391 + </constraints>
392 + <state key="normal" title="Button"/>
393 + <buttonConfiguration key="configuration" style="plain" title="Κάντο δώρο!">
394 + <backgroundConfiguration key="background" cornerRadius="12">
395 + <color key="backgroundColor" red="0.47450980390000003" green="0.74901960779999999" blue="0.078431372550000003" alpha="0.84705882349999995" colorSpace="calibratedRGB"/>
396 + </backgroundConfiguration>
397 + <fontDescription key="titleFontDescription" type="system" weight="medium" pointSize="15"/>
398 + <color key="baseForegroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
399 + </buttonConfiguration>
400 + <connections>
401 + <action selector="redeemButtomAction:" destination="CDt-eI-msA" eventType="touchUpInside" id="0pY-lD-17H"/>
402 + </connections>
403 + </button>
404 + <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="8UD-WL-JB7">
405 + <rect key="frame" x="103.5" y="706" width="207" height="50"/>
406 + <constraints>
407 + <constraint firstAttribute="height" constant="50" id="xdq-YS-AL4"/>
408 + </constraints>
409 + <inset key="imageEdgeInsets" minX="5" minY="0.0" maxX="0.0" maxY="0.0"/>
410 + <state key="normal" title="Button"/>
411 + <buttonConfiguration key="configuration" style="plain" image="ic_down_dark" imagePlacement="trailing" title="Όροι χρήσης" imagePadding="5">
412 + <preferredSymbolConfiguration key="preferredSymbolConfigurationForImage"/>
413 + <fontDescription key="titleFontDescription" type="system" weight="semibold" pointSize="15"/>
414 + <color key="baseForegroundColor" red="0.25490196079999999" green="0.33333333329999998" blue="0.3921568627" alpha="0.84705882349999995" colorSpace="calibratedRGB"/>
415 + </buttonConfiguration>
416 + <connections>
417 + <action selector="termsButtonAction:" destination="CDt-eI-msA" eventType="touchUpInside" id="zrs-az-yjI"/>
418 + </connections>
419 + </button>
420 + <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" textAlignment="center" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="xjX-HZ-MpD">
421 + <rect key="frame" x="20" y="766" width="374" height="0.0"/>
422 + <color key="backgroundColor" systemColor="systemBackgroundColor"/>
423 + <constraints>
424 + <constraint firstAttribute="height" id="3GU-tg-S3t"/>
425 + </constraints>
426 + <color key="textColor" red="0.25490196079999999" green="0.33333333329999998" blue="0.3921568627" alpha="1" colorSpace="calibratedRGB"/>
427 + <fontDescription key="fontDescription" type="system" pointSize="14"/>
428 + <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
429 + </textView>
430 + <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">
431 + <rect key="frame" x="20" y="511.5" width="374" height="26.5"/>
432 + <fontDescription key="fontDescription" type="system" pointSize="22"/>
433 + <color key="textColor" red="0.25490196079999999" green="0.33333333329999998" blue="0.3921568627" alpha="0.84705882349999995" colorSpace="calibratedRGB"/>
434 + <nil key="highlightedColor"/>
435 + </label>
436 + <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="6rV-2m-QMZ" userLabel="Border 2 View">
437 + <rect key="frame" x="20" y="558" width="374" height="1"/>
438 + <color key="backgroundColor" red="0.90196078430000004" green="0.90196078430000004" blue="0.90196078430000004" alpha="1" colorSpace="calibratedRGB"/>
439 + <constraints>
440 + <constraint firstAttribute="height" constant="1" id="DVl-3B-zqo"/>
441 + </constraints>
442 + </view>
443 + <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">
444 + <rect key="frame" x="20" y="594" width="374" height="17"/>
445 + <fontDescription key="fontDescription" type="system" pointSize="14"/>
446 + <color key="textColor" red="0.25490196079999999" green="0.33333333329999998" blue="0.3921568627" alpha="0.84705882349999995" colorSpace="calibratedRGB"/>
447 + <nil key="highlightedColor"/>
448 + </label>
449 + </subviews>
450 + <color key="backgroundColor" systemColor="systemBackgroundColor"/>
451 + <constraints>
452 + <constraint firstItem="jrM-7n-fSw" firstAttribute="leading" secondItem="1ec-eH-fkX" secondAttribute="leading" constant="20" id="0Dc-gr-Zfa"/>
453 + <constraint firstAttribute="trailing" secondItem="Xz4-EE-EzJ" secondAttribute="trailing" constant="20" id="5Sx-lW-x5H"/>
454 + <constraint firstItem="8cR-Rc-YMJ" firstAttribute="centerX" secondItem="1ec-eH-fkX" secondAttribute="centerX" id="8hP-dm-rWP"/>
455 + <constraint firstItem="8cR-Rc-YMJ" firstAttribute="width" secondItem="1ec-eH-fkX" secondAttribute="width" multiplier="0.6" id="8kM-Og-K54"/>
456 + <constraint firstItem="8UD-WL-JB7" firstAttribute="width" secondItem="1ec-eH-fkX" secondAttribute="width" multiplier="0.5" id="9Gy-bi-NXO"/>
457 + <constraint firstItem="mri-Wl-spg" firstAttribute="top" secondItem="Xz4-EE-EzJ" secondAttribute="bottom" constant="25" id="9W8-fX-IzR"/>
458 + <constraint firstItem="xjX-HZ-MpD" firstAttribute="leading" secondItem="1ec-eH-fkX" secondAttribute="leading" constant="20" id="AIW-Kf-tkQ"/>
459 + <constraint firstItem="jrM-7n-fSw" firstAttribute="top" secondItem="Zdf-1r-FdJ" secondAttribute="bottom" constant="20" id="G5W-a3-pag"/>
460 + <constraint firstItem="iiM-5P-m5s" firstAttribute="top" secondItem="1ec-eH-fkX" secondAttribute="top" id="H9I-TB-xig"/>
461 + <constraint firstItem="8cR-Rc-YMJ" firstAttribute="top" secondItem="UhC-Lj-tfN" secondAttribute="bottom" constant="35" id="I87-km-KEb"/>
462 + <constraint firstItem="Zdf-1r-FdJ" firstAttribute="top" secondItem="Sg1-QU-FY1" secondAttribute="bottom" constant="10" id="KZi-Jl-Yyz"/>
463 + <constraint firstItem="UhC-Lj-tfN" firstAttribute="leading" secondItem="1ec-eH-fkX" secondAttribute="leading" constant="20" id="MSg-iF-tt9"/>
464 + <constraint firstAttribute="trailing" secondItem="6rV-2m-QMZ" secondAttribute="trailing" constant="20" id="NGe-PV-pQl"/>
465 + <constraint firstAttribute="trailing" secondItem="mri-Wl-spg" secondAttribute="trailing" constant="20" id="NmE-Pu-v1S"/>
466 + <constraint firstAttribute="trailing" secondItem="EKv-Mx-6Yv" secondAttribute="trailing" constant="20" id="OeB-T7-87x"/>
467 + <constraint firstItem="8UD-WL-JB7" firstAttribute="top" secondItem="8cR-Rc-YMJ" secondAttribute="bottom" constant="10" id="Rbe-XQ-CIj"/>
468 + <constraint firstAttribute="trailing" secondItem="jrM-7n-fSw" secondAttribute="trailing" constant="20" id="ReY-xR-F8V"/>
469 + <constraint firstItem="Xz4-EE-EzJ" firstAttribute="top" secondItem="iiM-5P-m5s" secondAttribute="bottom" constant="30" id="Ryr-v8-THU"/>
470 + <constraint firstItem="xjX-HZ-MpD" firstAttribute="top" secondItem="8UD-WL-JB7" secondAttribute="bottom" constant="10" id="XFI-ij-KkC"/>
471 + <constraint firstItem="mri-Wl-spg" firstAttribute="leading" secondItem="1ec-eH-fkX" secondAttribute="leading" constant="20" id="YLo-Lg-Lda"/>
472 + <constraint firstItem="Zdf-1r-FdJ" firstAttribute="leading" secondItem="1ec-eH-fkX" secondAttribute="leading" constant="25" id="ZQd-cZ-JwO"/>
473 + <constraint firstItem="6rV-2m-QMZ" firstAttribute="leading" secondItem="1ec-eH-fkX" secondAttribute="leading" constant="20" id="bcQ-yl-h1d"/>
474 + <constraint firstAttribute="trailing" secondItem="Zdf-1r-FdJ" secondAttribute="trailing" constant="25" id="c0p-Op-6VI"/>
475 + <constraint firstItem="Sg1-QU-FY1" firstAttribute="top" secondItem="mri-Wl-spg" secondAttribute="bottom" constant="35" id="dOs-ap-XJ4"/>
476 + <constraint firstItem="iiM-5P-m5s" firstAttribute="leading" secondItem="1ec-eH-fkX" secondAttribute="leading" id="e6i-V3-Csq"/>
477 + <constraint firstItem="8UD-WL-JB7" firstAttribute="centerX" secondItem="1ec-eH-fkX" secondAttribute="centerX" id="eFM-ex-Dye"/>
478 + <constraint firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="8UD-WL-JB7" secondAttribute="bottom" constant="30" id="emI-WB-sXK"/>
479 + <constraint firstItem="6rV-2m-QMZ" firstAttribute="top" secondItem="EKv-Mx-6Yv" secondAttribute="bottom" constant="20" id="hL4-rX-9aa"/>
480 + <constraint firstItem="Sg1-QU-FY1" firstAttribute="leading" secondItem="1ec-eH-fkX" secondAttribute="leading" constant="20" id="hUh-Q7-uqi"/>
481 + <constraint firstItem="EKv-Mx-6Yv" firstAttribute="top" secondItem="jrM-7n-fSw" secondAttribute="bottom" constant="20" id="hZO-Qg-tda"/>
482 + <constraint firstItem="EKv-Mx-6Yv" firstAttribute="leading" secondItem="1ec-eH-fkX" secondAttribute="leading" constant="20" id="hf5-qR-yc9"/>
483 + <constraint firstAttribute="trailing" secondItem="Sg1-QU-FY1" secondAttribute="trailing" constant="20" id="j1h-uw-6rC"/>
484 + <constraint firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="xjX-HZ-MpD" secondAttribute="bottom" constant="30" id="kLr-ZV-vCo"/>
485 + <constraint firstAttribute="trailing" secondItem="UhC-Lj-tfN" secondAttribute="trailing" constant="20" id="lM1-ep-Zec"/>
486 + <constraint firstItem="Xz4-EE-EzJ" firstAttribute="leading" secondItem="1ec-eH-fkX" secondAttribute="leading" constant="20" id="lMf-pF-Bp6"/>
487 + <constraint firstItem="UhC-Lj-tfN" firstAttribute="top" secondItem="6rV-2m-QMZ" secondAttribute="bottom" constant="35" id="ora-fw-TKe"/>
488 + <constraint firstAttribute="trailing" secondItem="iiM-5P-m5s" secondAttribute="trailing" id="qWA-17-dEY"/>
489 + <constraint firstAttribute="trailing" secondItem="xjX-HZ-MpD" secondAttribute="trailing" constant="20" id="rIc-bw-vfp"/>
490 + </constraints>
491 + </view>
492 + </subviews>
493 + <constraints>
494 + <constraint firstItem="1ec-eH-fkX" firstAttribute="bottom" secondItem="4fu-Tq-CEO" secondAttribute="bottom" id="7sQ-jj-vME"/>
495 + <constraint firstItem="1ec-eH-fkX" firstAttribute="trailing" secondItem="4fu-Tq-CEO" secondAttribute="trailing" id="Ec4-LO-JCy"/>
496 + <constraint firstItem="1ec-eH-fkX" firstAttribute="top" secondItem="4fu-Tq-CEO" secondAttribute="top" id="VHa-ah-QOg"/>
497 + <constraint firstItem="1ec-eH-fkX" firstAttribute="leading" secondItem="4fu-Tq-CEO" secondAttribute="leading" id="YB3-J0-DrC"/>
498 + <constraint firstItem="1ec-eH-fkX" firstAttribute="width" secondItem="282-tV-FBh" secondAttribute="width" id="kai-Hd-WzK"/>
499 + </constraints>
500 + <viewLayoutGuide key="contentLayoutGuide" id="4fu-Tq-CEO"/>
501 + <viewLayoutGuide key="frameLayoutGuide" id="282-tV-FBh"/>
502 + </scrollView>
503 + </subviews>
504 + <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
505 + <constraints>
506 + <constraint firstItem="D1m-2B-ehg" firstAttribute="leading" secondItem="P3Q-nP-aSj" secondAttribute="leading" id="AMp-IG-CcQ"/>
507 + <constraint firstItem="B6L-Zs-Vnz" firstAttribute="top" secondItem="P3Q-nP-aSj" secondAttribute="top" id="BfW-Mh-FDd"/>
508 + <constraint firstItem="1ec-eH-fkX" firstAttribute="height" relation="greaterThanOrEqual" secondItem="P3Q-nP-aSj" secondAttribute="height" id="F9b-Gx-lxj"/>
509 + <constraint firstAttribute="bottom" secondItem="B6L-Zs-Vnz" secondAttribute="bottom" id="OZW-L0-2gZ"/>
510 + <constraint firstAttribute="trailing" secondItem="D1m-2B-ehg" secondAttribute="trailing" id="OZg-9O-qKw"/>
511 + <constraint firstItem="D1m-2B-ehg" firstAttribute="top" secondItem="P3Q-nP-aSj" secondAttribute="top" constant="5" id="b1K-LA-UXY"/>
512 + <constraint firstItem="B6L-Zs-Vnz" firstAttribute="leading" secondItem="P3Q-nP-aSj" secondAttribute="leading" id="oyw-NE-7bF"/>
513 + <constraint firstAttribute="trailing" secondItem="B6L-Zs-Vnz" secondAttribute="trailing" id="twW-h7-cNb"/>
514 + <constraint firstAttribute="bottom" secondItem="D1m-2B-ehg" secondAttribute="bottom" id="vw6-dc-3pg"/>
515 + </constraints>
516 + </view>
517 + </subviews>
518 + <viewLayoutGuide key="safeArea" id="mZk-p4-W2P"/>
519 + <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
520 + <constraints>
521 + <constraint firstAttribute="bottom" secondItem="P3Q-nP-aSj" secondAttribute="bottom" id="Crs-cf-GBJ"/>
522 + <constraint firstItem="P3Q-nP-aSj" firstAttribute="top" secondItem="mZk-p4-W2P" secondAttribute="top" id="mBZ-Rm-pNr"/>
523 + <constraint firstAttribute="trailing" secondItem="P3Q-nP-aSj" secondAttribute="trailing" id="vm4-E2-JYa"/>
524 + <constraint firstItem="P3Q-nP-aSj" firstAttribute="leading" secondItem="p8P-DP-0kH" secondAttribute="leading" id="vy0-c0-0FN"/>
525 + </constraints>
526 + </view>
527 + <connections>
528 + <outlet property="backgroundImage" destination="B6L-Zs-Vnz" id="0fs-sM-Khn"/>
529 + <outlet property="barcodeLabel" destination="EKv-Mx-6Yv" id="myd-id-Q29"/>
530 + <outlet property="couponImage" destination="iiM-5P-m5s" id="oKZ-Up-sI3"/>
531 + <outlet property="couponImageHeight" destination="kL0-u7-VI9" id="QJ9-gs-XUh"/>
532 + <outlet property="couponNumberLabel" destination="BJS-kk-CBZ" id="Sdz-3a-Jvq"/>
533 + <outlet property="couponView" destination="Zdf-1r-FdJ" id="OA8-73-e0p"/>
534 + <outlet property="discriptionLabel" destination="mri-Wl-spg" id="iuf-XL-NWH"/>
535 + <outlet property="expirationLabel" destination="UhC-Lj-tfN" id="9Hj-I1-nJa"/>
536 + <outlet property="nameLabel" destination="Xz4-EE-EzJ" id="zTY-n5-36h"/>
537 + <outlet property="redeemButton" destination="8cR-Rc-YMJ" id="atB-0m-8ff"/>
538 + <outlet property="scrollContentView" destination="1ec-eH-fkX" id="IZE-ie-TUA"/>
539 + <outlet property="scrollView" destination="D1m-2B-ehg" id="dwz-JJ-dht"/>
540 + <outlet property="termsButton" destination="8UD-WL-JB7" id="azl-dZ-6ey"/>
541 + <outlet property="termsTextView" destination="xjX-HZ-MpD" id="8ZQ-e0-1Ib"/>
542 + <outlet property="termsTextViewHeight" destination="3GU-tg-S3t" id="H3e-IQ-FGo"/>
543 + </connections>
544 + </viewController>
545 + <placeholder placeholderIdentifier="IBFirstResponder" id="tvH-ht-75E" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
546 + </objects>
547 + <point key="canvasLocation" x="2341" y="-555"/>
548 + </scene>
318 <!--Coupon View Controller--> 549 <!--Coupon View Controller-->
319 <scene sceneID="yGm-Im-aAN"> 550 <scene sceneID="yGm-Im-aAN">
320 <objects> 551 <objects>
......
...@@ -64,6 +64,33 @@ extension String { ...@@ -64,6 +64,33 @@ extension String {
64 } 64 }
65 } 65 }
66 66
67 +extension String {
68 +
69 + var length: Int {
70 + return count
71 + }
72 +
73 + subscript (i: Int) -> String {
74 + return self[i ..< i + 1]
75 + }
76 +
77 + func substring(fromIndex: Int) -> String {
78 + return self[min(fromIndex, length) ..< length]
79 + }
80 +
81 + func substring(toIndex: Int) -> String {
82 + return self[0 ..< max(0, toIndex)]
83 + }
84 +
85 + subscript (r: Range<Int>) -> String {
86 + let range = Range(uncheckedBounds: (lower: max(0, min(length, r.lowerBound)),
87 + upper: min(length, max(0, r.upperBound))))
88 + let start = index(startIndex, offsetBy: range.lowerBound)
89 + let end = index(start, offsetBy: range.upperBound - range.lowerBound)
90 + return String(self[start ..< end])
91 + }
92 +}
93 +
67 extension UIView { 94 extension UIView {
68 95
69 func addDashedBorderVertical(color: UIColor, width: CGFloat, height: CGFloat) { 96 func addDashedBorderVertical(color: UIColor, width: CGFloat, height: CGFloat) {
......