Manos Chorianopoulos

add clickable links to CouponViewController

......@@ -7,7 +7,7 @@
<key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
</dict>
</dict>
......
......@@ -7,7 +7,7 @@
<key>SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>0</integer>
</dict>
</dict>
</dict>
......
......@@ -8,7 +8,7 @@
import UIKit
import SwiftEventBus
@objc public class CouponViewController: UIViewController {
@objc public class CouponViewController: UIViewController, UITextViewDelegate {
@IBOutlet weak var mainView: UIView!
@IBOutlet weak var backgroundImage: UIImageView!
@IBOutlet weak var scrollView: UIScrollView!
......@@ -16,10 +16,11 @@ import SwiftEventBus
@IBOutlet weak var couponImage: UIImageView!
@IBOutlet weak var couponImageHeight: NSLayoutConstraint!
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var descriptionLabel: UILabel!
@IBOutlet weak var descriptionTextView: UnselectableTappableTextView!
@IBOutlet weak var descriptionTextViewHeight: NSLayoutConstraint!
@IBOutlet weak var redeemButton: UIButton!
@IBOutlet weak var termsButton: UIButton!
@IBOutlet weak var termsTextView: UITextView!
@IBOutlet weak var termsTextView: UnselectableTappableTextView!
@IBOutlet weak var termsTextViewHeight: NSLayoutConstraint!
@IBOutlet weak var topBorderLine: UIImageView!
......@@ -39,6 +40,8 @@ import SwiftEventBus
super.viewDidLoad()
self.hidesBottomBarWhenPushed = true
descriptionTextView.delegate = self
termsTextView.delegate = self
// Do any additional setup after loading the view.
setBackButton()
......@@ -78,7 +81,19 @@ import SwiftEventBus
nameLabel.text = couponset?.name ?? ""
let htmlDescrText = couponset?.description ?? ""
descriptionLabel.text = htmlDescrText.htmlToString
descriptionTextView.attributedText = htmlDescrText.htmlToAttributedString
descriptionTextView.font = UIFont(name: "PFSquareSansPro-Regular", size: 17)
descriptionTextView.textColor = UIColor(red: 0.25, green: 0.33, blue: 0.39, alpha: 1.00)
descriptionTextView.textAlignment = .center
descriptionTextView.isScrollEnabled = false
descriptionTextView.isUserInteractionEnabled = true
descriptionTextView.isEditable = false
descriptionTextView.isSelectable = true
descriptionTextView.dataDetectorTypes = [.link]
let targetSize = CGSize(width: descriptionTextView.frame.width, height: CGFloat(MAXFLOAT))
descriptionTextViewHeight.constant = descriptionTextView.sizeThatFits(targetSize).height
redeemButton.setTitle("Απόκτησέ το", for: .normal)
redeemButton.setTitleColor(.white, for: .normal)
......@@ -114,6 +129,10 @@ import SwiftEventBus
termsTextView.textColor = UIColor(red: 0.25, green: 0.33, blue: 0.39, alpha: 1.00)
termsTextView.textAlignment = .center
termsTextView.isScrollEnabled = false
termsTextView.isUserInteractionEnabled = true
termsTextView.isEditable = false
termsTextView.isSelectable = true
termsTextView.dataDetectorTypes = [.link]
toggleTerms()
......@@ -126,6 +145,13 @@ import SwiftEventBus
}
public func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
UIApplication.shared.open(URL)
// Disable `.preview` by 3D Touch and other interactions
return false
}
// MARK: - Functions
func nonTelcoDialog(_ alertTitle: String, _ alertSubTitle: String) -> Void {
......
......@@ -1384,7 +1384,7 @@
<!--Coupon Barcode View Controller-->
<scene sceneID="7Dn-sf-iEB">
<objects>
<viewController storyboardIdentifier="CouponBarcodeViewController" hidesBottomBarWhenPushed="YES" id="CDt-eI-msA" customClass="CouponBarcodeViewController" customModule="ResourcesBundle" customModuleProvider="target" sceneMemberID="viewController">
<viewController storyboardIdentifier="CouponBarcodeViewController" hidesBottomBarWhenPushed="YES" 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"/>
......@@ -1438,7 +1438,7 @@
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Zdf-1r-FdJ" userLabel="Coupon View">
<rect key="frame" x="152.5" y="397" width="109" 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" customClass="CopyableLabel" customModule="ResourcesBundle" customModuleProvider="target">
<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" customClass="CopyableLabel" customModule="SwiftWarplyFramework" customModuleProvider="target">
<rect key="frame" x="20" y="13.5" width="69" height="28"/>
<fontDescription key="fontDescription" name="PFSquareSansPro-Bold" family="PF Square Sans Pro" pointSize="28"/>
<color key="textColor" red="0.25490196078431371" green="0.33333333333333331" blue="0.39215686274509803" alpha="1" colorSpace="calibratedRGB"/>
......@@ -2073,7 +2073,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Jqu-cp-CWU">
<rect key="frame" x="0.0" y="44" width="414" height="852"/>
<rect key="frame" x="0.0" y="48" width="414" height="848"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="coupons_scrollview_white" translatesAutoresizingMaskIntoConstraints="NO" id="Oep-XD-blB">
<rect key="frame" x="0.0" y="0.0" width="414" height="852"/>
......@@ -2096,14 +2096,18 @@
<color key="textColor" red="0.25490196078431371" green="0.33333333333333331" blue="0.39215686274509803" alpha="1" colorSpace="custom" customColorSpace="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="dSA-lM-N5v">
<rect key="frame" x="20" y="269" width="374" height="51"/>
<fontDescription key="fontDescription" name="PFSquareSansPro-Regular" family="PF Square Sans Pro" pointSize="17"/>
<color key="textColor" red="0.25490196079999999" green="0.33333333329999998" blue="0.3921568627" alpha="1" colorSpace="custom" customColorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" textAlignment="center" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2YG-ey-cyw" customClass="UnselectableTappableTextView" customModule="SwiftWarplyFramework">
<rect key="frame" x="20" y="269" width="374" height="0.0"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstAttribute="height" id="GaK-QZ-z7W"/>
</constraints>
<color key="textColor" red="0.25490196079999999" green="0.33333333329999998" blue="0.3921568627" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" name="PFSquareSansPro-Regular" family="PF Square Sans Pro" pointSize="15"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
</textView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="FCd-hv-dHg">
<rect key="frame" x="165" y="420" width="84" height="44"/>
<rect key="frame" x="165" y="369" width="84" height="44"/>
<constraints>
<constraint firstAttribute="height" constant="44" id="n2w-Tx-hhO"/>
</constraints>
......@@ -2117,7 +2121,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="KvN-fk-rlm">
<rect key="frame" x="103.5" y="484" width="207" height="50"/>
<rect key="frame" x="103.5" y="433" width="207" height="50"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="O7T-ug-rTB"/>
</constraints>
......@@ -2131,8 +2135,8 @@
<action selector="termsButtonAction:" destination="S8k-2D-tGT" eventType="touchUpInside" id="Cdz-mV-gqb"/>
</connections>
</button>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" textAlignment="center" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="siA-c8-Ub8">
<rect key="frame" x="20" y="544" width="374" height="0.0"/>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" textAlignment="center" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="siA-c8-Ub8" customClass="UnselectableTappableTextView" customModule="SwiftWarplyFramework">
<rect key="frame" x="20" y="493" width="374" height="0.0"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstAttribute="height" id="BWJ-i6-UeO"/>
......@@ -2144,13 +2148,13 @@
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="FCd-hv-dHg" firstAttribute="top" secondItem="2YG-ey-cyw" secondAttribute="bottom" constant="100" id="0ya-Ww-UPb"/>
<constraint firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="KvN-fk-rlm" secondAttribute="bottom" constant="30" id="2Md-hq-rQl"/>
<constraint firstItem="KvN-fk-rlm" firstAttribute="width" secondItem="uTN-Qr-wBi" secondAttribute="width" multiplier="0.5" id="2R9-MN-w6g"/>
<constraint firstItem="dSA-lM-N5v" firstAttribute="leading" secondItem="uTN-Qr-wBi" secondAttribute="leading" constant="20" id="6B9-Tx-YcO"/>
<constraint firstAttribute="trailing" secondItem="2YG-ey-cyw" secondAttribute="trailing" constant="20" id="6S5-EO-Gwn"/>
<constraint firstAttribute="trailing" secondItem="isU-Qv-94G" secondAttribute="trailing" constant="20" id="7cL-ob-hXY"/>
<constraint firstAttribute="trailing" secondItem="siA-c8-Ub8" secondAttribute="trailing" constant="20" id="C8g-1f-Ef3"/>
<constraint firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="siA-c8-Ub8" secondAttribute="bottom" constant="30" id="FOo-d7-zvC"/>
<constraint firstAttribute="trailing" secondItem="dSA-lM-N5v" secondAttribute="trailing" constant="20" id="LZq-UM-EE3"/>
<constraint firstItem="siA-c8-Ub8" firstAttribute="top" secondItem="KvN-fk-rlm" secondAttribute="bottom" constant="10" id="MHv-4j-YYr"/>
<constraint firstItem="FCd-hv-dHg" firstAttribute="centerX" secondItem="uTN-Qr-wBi" secondAttribute="centerX" id="OFE-Xc-Ui3"/>
<constraint firstItem="isU-Qv-94G" firstAttribute="leading" secondItem="uTN-Qr-wBi" secondAttribute="leading" constant="20" id="PR6-tJ-tw0"/>
......@@ -2158,11 +2162,11 @@
<constraint firstAttribute="trailing" secondItem="3SX-fR-ph2" secondAttribute="trailing" id="WJj-1Q-Erx"/>
<constraint firstItem="siA-c8-Ub8" firstAttribute="leading" secondItem="uTN-Qr-wBi" secondAttribute="leading" constant="20" id="cpX-xa-q0z"/>
<constraint firstItem="KvN-fk-rlm" firstAttribute="top" secondItem="FCd-hv-dHg" secondAttribute="bottom" constant="20" id="fAV-Vc-ICH"/>
<constraint firstItem="dSA-lM-N5v" firstAttribute="top" secondItem="isU-Qv-94G" secondAttribute="bottom" constant="15" id="k8m-Rf-p7u"/>
<constraint firstItem="2YG-ey-cyw" firstAttribute="leading" secondItem="uTN-Qr-wBi" secondAttribute="leading" constant="20" id="h4k-WL-Eo1"/>
<constraint firstItem="2YG-ey-cyw" firstAttribute="top" secondItem="isU-Qv-94G" secondAttribute="bottom" constant="15" id="mbx-ls-aMK"/>
<constraint firstItem="3SX-fR-ph2" firstAttribute="leading" secondItem="uTN-Qr-wBi" secondAttribute="leading" id="nBV-nm-wOq"/>
<constraint firstItem="3SX-fR-ph2" firstAttribute="top" secondItem="uTN-Qr-wBi" secondAttribute="top" id="oaX-KH-TEh"/>
<constraint firstItem="isU-Qv-94G" firstAttribute="top" secondItem="3SX-fR-ph2" secondAttribute="bottom" constant="20" id="vQf-lC-GgG"/>
<constraint firstItem="FCd-hv-dHg" firstAttribute="top" secondItem="dSA-lM-N5v" secondAttribute="bottom" constant="100" id="x3c-xH-QFZ"/>
</constraints>
</view>
</subviews>
......@@ -2215,7 +2219,8 @@
<outlet property="backgroundImage" destination="Oep-XD-blB" id="YaT-qr-rry"/>
<outlet property="couponImage" destination="3SX-fR-ph2" id="Ov2-Bw-eWL"/>
<outlet property="couponImageHeight" destination="zUx-Yd-in7" id="7vo-8L-d8o"/>
<outlet property="descriptionLabel" destination="dSA-lM-N5v" id="v6k-3l-uaA"/>
<outlet property="descriptionTextView" destination="2YG-ey-cyw" id="YAv-KA-iaX"/>
<outlet property="descriptionTextViewHeight" destination="GaK-QZ-z7W" id="ilM-IK-1sd"/>
<outlet property="mainView" destination="Jqu-cp-CWU" id="Q0Z-dO-MXL"/>
<outlet property="nameLabel" destination="isU-Qv-94G" id="Vc8-gh-Cth"/>
<outlet property="redeemButton" destination="FCd-hv-dHg" id="3Jw-Yn-uNr"/>
......