Showing
5 changed files
with
172 additions
and
7 deletions
... | @@ -18,6 +18,7 @@ | ... | @@ -18,6 +18,7 @@ |
18 | 1E87A9EF28C2021200C79F90 /* ContextualViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E87A9EE28C2021200C79F90 /* ContextualViewController.swift */; }; | 18 | 1E87A9EF28C2021200C79F90 /* ContextualViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E87A9EE28C2021200C79F90 /* ContextualViewController.swift */; }; |
19 | 1EA1AF0A2835346A008998AA /* CouponsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */; }; | 19 | 1EA1AF0A2835346A008998AA /* CouponsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */; }; |
20 | 1EA2BB792865BFE8003F2AB0 /* InboxTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA2BB782865BFE8003F2AB0 /* InboxTableViewCell.swift */; }; | 20 | 1EA2BB792865BFE8003F2AB0 /* InboxTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA2BB782865BFE8003F2AB0 /* InboxTableViewCell.swift */; }; |
21 | + 1EA771AC290977CA0030924C /* CopyableLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA771AB290977CA0030924C /* CopyableLabel.swift */; }; | ||
21 | 1EB236AB28816B680063777A /* ShareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EB236AA28816B680063777A /* ShareViewController.swift */; }; | 22 | 1EB236AB28816B680063777A /* ShareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EB236AA28816B680063777A /* ShareViewController.swift */; }; |
22 | 1EB236AD28816C560063777A /* NumberPopupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EB236AC28816C560063777A /* NumberPopupViewController.swift */; }; | 23 | 1EB236AD28816C560063777A /* NumberPopupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EB236AC28816C560063777A /* NumberPopupViewController.swift */; }; |
23 | 1EB236AF28816CAC0063777A /* NumbersTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EB236AE28816CAB0063777A /* NumbersTableViewCell.swift */; }; | 24 | 1EB236AF28816CAC0063777A /* NumbersTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EB236AE28816CAB0063777A /* NumbersTableViewCell.swift */; }; |
... | @@ -180,6 +181,7 @@ | ... | @@ -180,6 +181,7 @@ |
180 | 1E87A9EE28C2021200C79F90 /* ContextualViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContextualViewController.swift; sourceTree = "<group>"; }; | 181 | 1E87A9EE28C2021200C79F90 /* ContextualViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContextualViewController.swift; sourceTree = "<group>"; }; |
181 | 1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponsTableViewCell.swift; sourceTree = "<group>"; }; | 182 | 1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponsTableViewCell.swift; sourceTree = "<group>"; }; |
182 | 1EA2BB782865BFE8003F2AB0 /* InboxTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InboxTableViewCell.swift; sourceTree = "<group>"; }; | 183 | 1EA2BB782865BFE8003F2AB0 /* InboxTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InboxTableViewCell.swift; sourceTree = "<group>"; }; |
184 | + 1EA771AB290977CA0030924C /* CopyableLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CopyableLabel.swift; sourceTree = "<group>"; }; | ||
183 | 1EB236AA28816B680063777A /* ShareViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareViewController.swift; sourceTree = "<group>"; }; | 185 | 1EB236AA28816B680063777A /* ShareViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareViewController.swift; sourceTree = "<group>"; }; |
184 | 1EB236AC28816C560063777A /* NumberPopupViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumberPopupViewController.swift; sourceTree = "<group>"; }; | 186 | 1EB236AC28816C560063777A /* NumberPopupViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumberPopupViewController.swift; sourceTree = "<group>"; }; |
185 | 1EB236AE28816CAB0063777A /* NumbersTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumbersTableViewCell.swift; sourceTree = "<group>"; }; | 187 | 1EB236AE28816CAB0063777A /* NumbersTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumbersTableViewCell.swift; sourceTree = "<group>"; }; |
... | @@ -464,6 +466,7 @@ | ... | @@ -464,6 +466,7 @@ |
464 | E6A77A35282BB4CB0045BBA8 /* MakeItAPresentViewController.swift */, | 466 | E6A77A35282BB4CB0045BBA8 /* MakeItAPresentViewController.swift */, |
465 | E6A7785A282933E40045BBA8 /* Helpers */, | 467 | E6A7785A282933E40045BBA8 /* Helpers */, |
466 | E6A77861282933E50045BBA8 /* Main.storyboard */, | 468 | E6A77861282933E50045BBA8 /* Main.storyboard */, |
469 | + 1EA771AB290977CA0030924C /* CopyableLabel.swift */, | ||
467 | 1E4410B028F5855000859F92 /* CampaignCategory.swift */, | 470 | 1E4410B028F5855000859F92 /* CampaignCategory.swift */, |
468 | 1EDCDFAB28DB29E8002ED8F0 /* AnalysisMoreViewCell.swift */, | 471 | 1EDCDFAB28DB29E8002ED8F0 /* AnalysisMoreViewCell.swift */, |
469 | 1E87A9EE28C2021200C79F90 /* ContextualViewController.swift */, | 472 | 1E87A9EE28C2021200C79F90 /* ContextualViewController.swift */, |
... | @@ -940,6 +943,7 @@ | ... | @@ -940,6 +943,7 @@ |
940 | E6A77A36282BB4CB0045BBA8 /* MakeItAPresentViewController.swift in Sources */, | 943 | E6A77A36282BB4CB0045BBA8 /* MakeItAPresentViewController.swift in Sources */, |
941 | E6A77947282933E70045BBA8 /* FMDatabaseQueue.m in Sources */, | 944 | E6A77947282933E70045BBA8 /* FMDatabaseQueue.m in Sources */, |
942 | E6A77922282933E60045BBA8 /* NSData+SSToolkitAdditions.m in Sources */, | 945 | E6A77922282933E60045BBA8 /* NSData+SSToolkitAdditions.m in Sources */, |
946 | + 1EA771AC290977CA0030924C /* CopyableLabel.swift in Sources */, | ||
943 | 1EB236AB28816B680063777A /* ShareViewController.swift in Sources */, | 947 | 1EB236AB28816B680063777A /* ShareViewController.swift in Sources */, |
944 | E6A778E7282933E60045BBA8 /* DetailsViewController.swift in Sources */, | 948 | E6A778E7282933E60045BBA8 /* DetailsViewController.swift in Sources */, |
945 | 1EB5F4CA285370C90016F36E /* LoyaltyAnalysisViewController.swift in Sources */, | 949 | 1EB5F4CA285370C90016F36E /* LoyaltyAnalysisViewController.swift in Sources */, | ... | ... |
No preview for this file type
1 | +// | ||
2 | +// CopyableLabel.swift | ||
3 | +// SwiftWarplyFramework | ||
4 | +// | ||
5 | +// Created by Manos Chorianopoulos on 26/10/22. | ||
6 | +// | ||
7 | + | ||
8 | +import Foundation | ||
9 | +import UIKit | ||
10 | + | ||
11 | +class CopyableLabel: UILabel { | ||
12 | + | ||
13 | + override init(frame: CGRect) { | ||
14 | + super.init(frame: frame) | ||
15 | + sharedInit() | ||
16 | + } | ||
17 | + | ||
18 | + required init(coder aDecoder: NSCoder) { | ||
19 | + super.init(coder: aDecoder)! | ||
20 | + sharedInit() | ||
21 | + } | ||
22 | + | ||
23 | + func sharedInit() { | ||
24 | + isUserInteractionEnabled = true | ||
25 | + addGestureRecognizer(UILongPressGestureRecognizer(target: self, action: #selector(showMenu(sender:)))) | ||
26 | + } | ||
27 | + | ||
28 | + @objc | ||
29 | + func showMenu(sender: AnyObject?) { | ||
30 | + becomeFirstResponder() | ||
31 | + let menu = UIMenuController.shared | ||
32 | + if !menu.isMenuVisible { | ||
33 | + menu.setTargetRect(bounds, in: self) | ||
34 | + menu.setMenuVisible(true, animated: true) | ||
35 | + } | ||
36 | + } | ||
37 | + | ||
38 | + override var canBecomeFirstResponder: Bool { | ||
39 | + return true | ||
40 | + } | ||
41 | + | ||
42 | + override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool { | ||
43 | + if action == #selector(UIResponderStandardEditActions.copy(_:)) { | ||
44 | + return true | ||
45 | + } | ||
46 | + return false | ||
47 | + } | ||
48 | + | ||
49 | + override func copy(_ sender: Any?) { | ||
50 | + let board = UIPasteboard.general | ||
51 | + if var textToCopy = text { | ||
52 | + if (textToCopy.contains(", ")) { | ||
53 | + textToCopy = textToCopy.replacingOccurrences(of: ", ", with: "") | ||
54 | + } | ||
55 | + print(textToCopy) | ||
56 | + board.string = textToCopy | ||
57 | + } | ||
58 | + | ||
59 | +// board.string = text | ||
60 | + let menu = UIMenuController.shared | ||
61 | + menu.setMenuVisible(false, animated: true) | ||
62 | + } | ||
63 | + | ||
64 | +} |
... | @@ -944,7 +944,7 @@ | ... | @@ -944,7 +944,7 @@ |
944 | <rect key="frame" x="10" y="475" width="394" height="100"/> | 944 | <rect key="frame" x="10" y="475" width="394" height="100"/> |
945 | <subviews> | 945 | <subviews> |
946 | <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="2" translatesAutoresizingMaskIntoConstraints="NO" id="MCY-xv-vpg"> | 946 | <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="2" translatesAutoresizingMaskIntoConstraints="NO" id="MCY-xv-vpg"> |
947 | - <rect key="frame" x="20" y="23" width="254" height="54"/> | 947 | + <rect key="frame" x="20" y="32.5" width="254" height="35"/> |
948 | <subviews> | 948 | <subviews> |
949 | <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Ενεργός κωδικός:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ucC-u4-AQL"> | 949 | <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Ενεργός κωδικός:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ucC-u4-AQL"> |
950 | <rect key="frame" x="0.0" y="0.0" width="254" height="19"/> | 950 | <rect key="frame" x="0.0" y="0.0" width="254" height="19"/> |
... | @@ -952,19 +952,52 @@ | ... | @@ -952,19 +952,52 @@ |
952 | <color key="textColor" red="0.23529411759999999" green="0.32549019610000002" blue="0.39607843139999999" alpha="1" colorSpace="calibratedRGB"/> | 952 | <color key="textColor" red="0.23529411759999999" green="0.32549019610000002" blue="0.39607843139999999" alpha="1" colorSpace="calibratedRGB"/> |
953 | <nil key="highlightedColor"/> | 953 | <nil key="highlightedColor"/> |
954 | </label> | 954 | </label> |
955 | + <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vUM-ac-164"> | ||
956 | + <rect key="frame" x="0.0" y="21" width="254" height="0.0"/> | ||
957 | + <subviews> | ||
958 | + <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Cjr-c8-pL3"> | ||
959 | + <rect key="frame" x="0.0" y="0.0" width="254" height="0.0"/> | ||
960 | + <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> | ||
961 | + <constraints> | ||
962 | + <constraint firstAttribute="height" id="eQ1-yY-Dk0"/> | ||
963 | + </constraints> | ||
964 | + </view> | ||
965 | + </subviews> | ||
966 | + <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> | ||
967 | + <constraints> | ||
968 | + <constraint firstItem="Cjr-c8-pL3" firstAttribute="top" secondItem="gKJ-wy-UjY" secondAttribute="top" id="00U-6c-1f2"/> | ||
969 | + <constraint firstItem="Cjr-c8-pL3" firstAttribute="bottom" secondItem="gKJ-wy-UjY" secondAttribute="bottom" id="PDW-hq-mQs"/> | ||
970 | + <constraint firstItem="Cjr-c8-pL3" firstAttribute="trailing" secondItem="gKJ-wy-UjY" secondAttribute="trailing" id="S8N-x6-zh1"/> | ||
971 | + <constraint firstItem="Cjr-c8-pL3" firstAttribute="leading" secondItem="gKJ-wy-UjY" secondAttribute="leading" id="SbU-3v-rwK"/> | ||
972 | + <constraint firstItem="Cjr-c8-pL3" firstAttribute="width" secondItem="4rG-Ia-uel" secondAttribute="width" id="tMz-sE-6TW"/> | ||
973 | + <constraint firstAttribute="height" id="zkI-mG-qPM"/> | ||
974 | + </constraints> | ||
975 | + <viewLayoutGuide key="contentLayoutGuide" id="gKJ-wy-UjY"/> | ||
976 | + <viewLayoutGuide key="frameLayoutGuide" id="4rG-Ia-uel"/> | ||
977 | + </scrollView> | ||
955 | <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="961544809" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qBe-Jw-QUx"> | 978 | <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="961544809" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qBe-Jw-QUx"> |
956 | <rect key="frame" x="0.0" y="21" width="254" height="19"/> | 979 | <rect key="frame" x="0.0" y="21" width="254" height="19"/> |
980 | + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> | ||
957 | <fontDescription key="fontDescription" name="PFSquareSansPro-Bold" family="PF Square Sans Pro" pointSize="19"/> | 981 | <fontDescription key="fontDescription" name="PFSquareSansPro-Bold" family="PF Square Sans Pro" pointSize="19"/> |
958 | <color key="textColor" red="0.23529411759999999" green="0.32549019610000002" blue="0.39607843139999999" alpha="1" colorSpace="calibratedRGB"/> | 982 | <color key="textColor" red="0.23529411759999999" green="0.32549019610000002" blue="0.39607843139999999" alpha="1" colorSpace="calibratedRGB"/> |
959 | <nil key="highlightedColor"/> | 983 | <nil key="highlightedColor"/> |
960 | </label> | 984 | </label> |
961 | <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Λήγει σε 4 ημέρες" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qL0-3b-eqA"> | 985 | <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Λήγει σε 4 ημέρες" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qL0-3b-eqA"> |
962 | - <rect key="frame" x="0.0" y="42" width="254" height="12"/> | 986 | + <rect key="frame" x="0.0" y="23" width="254" height="12"/> |
963 | <fontDescription key="fontDescription" name="PFSquareSansPro-Regular" family="PF Square Sans Pro" pointSize="12"/> | 987 | <fontDescription key="fontDescription" name="PFSquareSansPro-Regular" family="PF Square Sans Pro" pointSize="12"/> |
964 | <color key="textColor" red="0.2274509804" green="0.32156862749999998" blue="0.40000000000000002" alpha="1" colorSpace="calibratedRGB"/> | 988 | <color key="textColor" red="0.2274509804" green="0.32156862749999998" blue="0.40000000000000002" alpha="1" colorSpace="calibratedRGB"/> |
965 | <nil key="highlightedColor"/> | 989 | <nil key="highlightedColor"/> |
966 | </label> | 990 | </label> |
967 | </subviews> | 991 | </subviews> |
992 | + <constraints> | ||
993 | + <constraint firstItem="vUM-ac-164" firstAttribute="leading" secondItem="MCY-xv-vpg" secondAttribute="leading" id="eV5-RL-miL"/> | ||
994 | + <constraint firstAttribute="trailing" secondItem="vUM-ac-164" secondAttribute="trailing" id="u5q-oF-oPt"/> | ||
995 | + </constraints> | ||
996 | + <variation key="default"> | ||
997 | + <mask key="subviews"> | ||
998 | + <exclude reference="qBe-Jw-QUx"/> | ||
999 | + </mask> | ||
1000 | + </variation> | ||
968 | </stackView> | 1001 | </stackView> |
969 | <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="active_code_logo" translatesAutoresizingMaskIntoConstraints="NO" id="xwu-AC-ij3"> | 1002 | <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="active_code_logo" translatesAutoresizingMaskIntoConstraints="NO" id="xwu-AC-ij3"> |
970 | <rect key="frame" x="294" y="10" width="80" height="80"/> | 1003 | <rect key="frame" x="294" y="10" width="80" height="80"/> |
... | @@ -1191,9 +1224,13 @@ | ... | @@ -1191,9 +1224,13 @@ |
1191 | </constraints> | 1224 | </constraints> |
1192 | </view> | 1225 | </view> |
1193 | <connections> | 1226 | <connections> |
1227 | + <outlet property="activeCodeContentView" destination="Cjr-c8-pL3" id="KXI-Mq-PWS"/> | ||
1228 | + <outlet property="activeCodeContentViewHeight" destination="eQ1-yY-Dk0" id="J69-Hr-XD3"/> | ||
1194 | <outlet property="activeCodeExpirationLabel" destination="qL0-3b-eqA" id="XjP-lI-UtJ"/> | 1229 | <outlet property="activeCodeExpirationLabel" destination="qL0-3b-eqA" id="XjP-lI-UtJ"/> |
1195 | <outlet property="activeCodeImage" destination="xwu-AC-ij3" id="iU8-rU-Q07"/> | 1230 | <outlet property="activeCodeImage" destination="xwu-AC-ij3" id="iU8-rU-Q07"/> |
1196 | <outlet property="activeCodeLabel" destination="qBe-Jw-QUx" id="mlj-zT-T0Z"/> | 1231 | <outlet property="activeCodeLabel" destination="qBe-Jw-QUx" id="mlj-zT-T0Z"/> |
1232 | + <outlet property="activeCodeScrollView" destination="vUM-ac-164" id="kIA-4v-lGx"/> | ||
1233 | + <outlet property="activeCodeScrollViewHeight" destination="zkI-mG-qPM" id="hXL-Rp-DQz"/> | ||
1197 | <outlet property="activeCodeView" destination="zFT-By-XHL" id="M0w-Ln-iC9"/> | 1234 | <outlet property="activeCodeView" destination="zFT-By-XHL" id="M0w-Ln-iC9"/> |
1198 | <outlet property="activeCodeViewHeight" destination="7r0-fu-7H9" id="nDr-bk-ViP"/> | 1235 | <outlet property="activeCodeViewHeight" destination="7r0-fu-7H9" id="nDr-bk-ViP"/> |
1199 | <outlet property="activeCodesCountLabel" destination="ucC-u4-AQL" id="BCn-Ul-WqA"/> | 1236 | <outlet property="activeCodesCountLabel" destination="ucC-u4-AQL" id="BCn-Ul-WqA"/> | ... | ... |
... | @@ -40,6 +40,10 @@ import SwiftEventBus | ... | @@ -40,6 +40,10 @@ import SwiftEventBus |
40 | @IBOutlet weak var emptyView: UIView! | 40 | @IBOutlet weak var emptyView: UIView! |
41 | @IBOutlet weak var emptyImage: UIImageView! | 41 | @IBOutlet weak var emptyImage: UIImageView! |
42 | @IBOutlet weak var emptyLabel: UILabel! | 42 | @IBOutlet weak var emptyLabel: UILabel! |
43 | + @IBOutlet weak var activeCodeScrollView: UIScrollView! | ||
44 | + @IBOutlet weak var activeCodeScrollViewHeight: NSLayoutConstraint! | ||
45 | + @IBOutlet weak var activeCodeContentView: UIView! | ||
46 | + @IBOutlet weak var activeCodeContentViewHeight: NSLayoutConstraint! | ||
43 | 47 | ||
44 | public var coupons:Array<swiftApi.CouponItemModel> = swiftApi().getCouponList() | 48 | public var coupons:Array<swiftApi.CouponItemModel> = swiftApi().getCouponList() |
45 | public var dfyCoupons:Array<swiftApi.ActiveDFYCouponModel> = swiftApi().getActiveDFYCoupons() | 49 | public var dfyCoupons:Array<swiftApi.ActiveDFYCouponModel> = swiftApi().getActiveDFYCoupons() |
... | @@ -237,7 +241,21 @@ import SwiftEventBus | ... | @@ -237,7 +241,21 @@ import SwiftEventBus |
237 | } | 241 | } |
238 | 242 | ||
239 | activeCodesCountLabel.text = "Ενεργός κωδικός:" | 243 | activeCodesCountLabel.text = "Ενεργός κωδικός:" |
240 | - activeCodeLabel.text = dfyCoupons[0]._code | 244 | + // activeCodeLabel.text = dfyCoupons[0]._code |
245 | + let newLabel = CopyableLabel() | ||
246 | + newLabel.text = String(dfyCoupons[0]._code) | ||
247 | + newLabel.font = UIFont(name: "PFSquareSansPro-Bold", size: 19) | ||
248 | + newLabel.textColor = UIColor(rgb: 0x3C5365) | ||
249 | + newLabel.frame.size.width = newLabel.intrinsicContentSize.width | ||
250 | + newLabel.frame.size.height = newLabel.intrinsicContentSize.height // tagHeight | ||
251 | + activeCodeContentView.addSubview(newLabel) | ||
252 | + // set the btn frame origin | ||
253 | + newLabel.frame.origin.x = 0 | ||
254 | + newLabel.frame.origin.y = 0 | ||
255 | + let scrollHeight = newLabel.intrinsicContentSize.height | ||
256 | + activeCodeContentViewHeight.constant = scrollHeight | ||
257 | + activeCodeScrollViewHeight.constant = scrollHeight | ||
258 | + | ||
241 | activeCodeExpirationLabel.isHidden = false | 259 | activeCodeExpirationLabel.isHidden = false |
242 | if (daysFromNow == "1") { | 260 | if (daysFromNow == "1") { |
243 | activeCodeExpirationLabel.text = "Λήγει σε " + daysFromNow + " ημέρα" | 261 | activeCodeExpirationLabel.text = "Λήγει σε " + daysFromNow + " ημέρα" |
... | @@ -246,19 +264,61 @@ import SwiftEventBus | ... | @@ -246,19 +264,61 @@ import SwiftEventBus |
246 | } | 264 | } |
247 | 265 | ||
248 | } else { | 266 | } else { |
249 | - var couponCodesString = "" | 267 | + var tagHeight:CGFloat = 30 |
268 | + let tagPadding: CGFloat = 0 | ||
269 | + let tagSpacingX: CGFloat = 0 | ||
270 | + let tagSpacingY: CGFloat = 2 | ||
271 | + | ||
272 | + let containerWidth = activeCodeContentView.frame.size.width | ||
273 | + | ||
274 | + var currentOriginX: CGFloat = 0 | ||
275 | + var currentOriginY: CGFloat = 0 | ||
276 | + | ||
277 | + // var couponCodesString = "" | ||
250 | for (index, item) in dfyCoupons.enumerated() { | 278 | for (index, item) in dfyCoupons.enumerated() { |
279 | + let newLabel = CopyableLabel() | ||
280 | + newLabel.font = UIFont(name: "PFSquareSansPro-Bold", size: 19) | ||
281 | + newLabel.textColor = UIColor(rgb: 0x3C5365) | ||
282 | + | ||
251 | if (index == (dfyCoupons.endIndex - 1)) { | 283 | if (index == (dfyCoupons.endIndex - 1)) { |
252 | - couponCodesString += String(item._code) | 284 | + // couponCodesString += String(item._code) |
285 | + newLabel.text = String(item._code) | ||
253 | } else { | 286 | } else { |
254 | - couponCodesString += String(item._code) + ", " | 287 | + // couponCodesString += String(item._code) + ", " |
288 | + newLabel.text = String(item._code) + ", " | ||
289 | + } | ||
290 | + | ||
291 | + newLabel.frame.size.width = newLabel.intrinsicContentSize.width + tagPadding | ||
292 | + newLabel.frame.size.height = newLabel.intrinsicContentSize.height // tagHeight | ||
293 | + tagHeight = newLabel.intrinsicContentSize.height | ||
294 | + activeCodeContentView.addSubview(newLabel) | ||
295 | + | ||
296 | + // if current X + label width will be greater than container view width | ||
297 | + // "move to next row" | ||
298 | + if currentOriginX + newLabel.frame.width > containerWidth { | ||
299 | + currentOriginX = 0 | ||
300 | + currentOriginY += tagHeight + tagSpacingY | ||
255 | } | 301 | } |
256 | 302 | ||
303 | + // set the btn frame origin | ||
304 | + newLabel.frame.origin.x = currentOriginX | ||
305 | + newLabel.frame.origin.y = currentOriginY | ||
306 | + | ||
307 | + // increment current X by btn width + spacing | ||
308 | + currentOriginX += newLabel.frame.width + tagSpacingX | ||
257 | } | 309 | } |
258 | 310 | ||
259 | activeCodesCountLabel.text = String(dfyCoupons.count) + " Ενεργοί κωδικοί:" | 311 | activeCodesCountLabel.text = String(dfyCoupons.count) + " Ενεργοί κωδικοί:" |
260 | - activeCodeLabel.text = couponCodesString | 312 | + // activeCodeLabel.text = couponCodesString |
261 | activeCodeExpirationLabel.isHidden = true | 313 | activeCodeExpirationLabel.isHidden = true |
314 | + | ||
315 | + // update container view height | ||
316 | + activeCodeContentViewHeight.constant = currentOriginY + tagHeight | ||
317 | + if ((currentOriginY + tagHeight) <= (2 * tagHeight + tagSpacingY)) { | ||
318 | + activeCodeScrollViewHeight.constant = currentOriginY + tagHeight | ||
319 | + } else { | ||
320 | + activeCodeScrollViewHeight.constant = 2 * tagHeight + tagSpacingY | ||
321 | + } | ||
262 | } | 322 | } |
263 | } else { | 323 | } else { |
264 | activeCodeLabel.text = "-" | 324 | activeCodeLabel.text = "-" | ... | ... |
-
Please register or login to post a comment