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 {
......