Showing
4 changed files
with
145 additions
and
7 deletions
No preview for this file type
This diff is collapsed. Click to expand it.
| ... | @@ -9,6 +9,7 @@ import UIKit | ... | @@ -9,6 +9,7 @@ import UIKit |
| 9 | 9 | ||
| 10 | @objc public class TelcoViewController: UIViewController, UIPopoverControllerDelegate { | 10 | @objc public class TelcoViewController: UIViewController, UIPopoverControllerDelegate { |
| 11 | @IBOutlet weak var mainView: UIView! | 11 | @IBOutlet weak var mainView: UIView! |
| 12 | + @IBOutlet weak var backgroundImage: UIImageView! | ||
| 12 | @IBOutlet weak var scrollView: UIScrollView! | 13 | @IBOutlet weak var scrollView: UIScrollView! |
| 13 | @IBOutlet weak var scrollContentView: UIView! | 14 | @IBOutlet weak var scrollContentView: UIView! |
| 14 | @IBOutlet weak var heroImage: UIImageView! | 15 | @IBOutlet weak var heroImage: UIImageView! |
| ... | @@ -16,6 +17,15 @@ import UIKit | ... | @@ -16,6 +17,15 @@ import UIKit |
| 16 | @IBOutlet weak var nameLabel: UILabel! | 17 | @IBOutlet weak var nameLabel: UILabel! |
| 17 | @IBOutlet weak var descriptionLabel: UILabel! | 18 | @IBOutlet weak var descriptionLabel: UILabel! |
| 18 | @IBOutlet weak var activateButton: UIButton! | 19 | @IBOutlet weak var activateButton: UIButton! |
| 20 | + @IBOutlet weak var valueView: UIView! | ||
| 21 | + @IBOutlet weak var valueLabel: UILabel! | ||
| 22 | + @IBOutlet weak var giftTypeLabel: UILabel! | ||
| 23 | + @IBOutlet weak var giftDurationView: UIView! | ||
| 24 | + @IBOutlet weak var giftDurationLabel: UILabel! | ||
| 25 | + @IBOutlet weak var borderLineView: UIView! | ||
| 26 | + @IBOutlet weak var moreButton: UIButton! | ||
| 27 | + @IBOutlet weak var moreTextView: UITextView! | ||
| 28 | + @IBOutlet weak var moreTextViewHeight: NSLayoutConstraint! | ||
| 19 | 29 | ||
| 20 | let uiscreen: CGRect = UIScreen.main.bounds | 30 | let uiscreen: CGRect = UIScreen.main.bounds |
| 21 | 31 | ||
| ... | @@ -24,6 +34,8 @@ import UIKit | ... | @@ -24,6 +34,8 @@ import UIKit |
| 24 | var selectedNumber: String = "" | 34 | var selectedNumber: String = "" |
| 25 | public var numbersList: Array<String> = [] | 35 | public var numbersList: Array<String> = [] |
| 26 | 36 | ||
| 37 | + var moreVisible: Bool = false; | ||
| 38 | + | ||
| 27 | public override func viewDidLoad() { | 39 | public override func viewDidLoad() { |
| 28 | 40 | ||
| 29 | super.viewDidLoad() | 41 | super.viewDidLoad() |
| ... | @@ -33,27 +45,76 @@ import UIKit | ... | @@ -33,27 +45,76 @@ import UIKit |
| 33 | // Do any additional setup after loading the view. | 45 | // Do any additional setup after loading the view. |
| 34 | getProfileRequest() | 46 | getProfileRequest() |
| 35 | 47 | ||
| 36 | - setBackButton() | 48 | + setBackButton("ic_close") |
| 37 | - setNavigationTitle("Ενεργοποίηση") | 49 | + setNavigationTitle(ccms?._titleOffer ?? "") |
| 50 | + | ||
| 51 | + backgroundImage.image = UIImage(named: "coupons_scrollview_white", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil) | ||
| 38 | 52 | ||
| 39 | scrollView.clipsToBounds = true | 53 | scrollView.clipsToBounds = true |
| 40 | scrollView.layer.cornerRadius = 30 | 54 | scrollView.layer.cornerRadius = 30 |
| 41 | scrollView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius | 55 | scrollView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius |
| 42 | 56 | ||
| 43 | - heroImage.load(link: ccms?._imageUrl ?? "", placeholder: UIImage(), cache: URLCache()) | 57 | + heroImage.load(link: ccms?._imageOfferUrl ?? "", placeholder: UIImage(), cache: URLCache()) |
| 44 | heroImage.contentMode = .scaleAspectFill | 58 | heroImage.contentMode = .scaleAspectFill |
| 45 | heroImageHeight.constant = self.uiscreen.height * 0.25 | 59 | heroImageHeight.constant = self.uiscreen.height * 0.25 |
| 46 | - nameLabel.text = ccms?._title ?? "" | 60 | + nameLabel.text = ccms?._description ?? "" |
| 47 | - descriptionLabel.text = ccms?._subtitle ?? "" | 61 | + // descriptionLabel.text = ccms?._subtitle ?? "" |
| 62 | + | ||
| 63 | + valueView.gradientBorder(width: 1, colors: [UIColor(rgb: 0x07A2D1), UIColor(rgb: 0x73CA34)], startPoint: .unitCoordinate(.bottomLeft), endPoint: .unitCoordinate(.topRight), andRoundCornersWithRadius: 35) | ||
| 64 | + valueLabel.text = ccms?._giftValue ?? "" | ||
| 65 | + giftTypeLabel.text = ccms?._giftType ?? "" | ||
| 66 | + | ||
| 67 | + giftDurationLabel.text = ccms?._duration ?? "" | ||
| 68 | + giftDurationView.frame = CGRect(x: 0.0, y: 0.0, width: giftDurationLabel.intrinsicContentSize.width + 20, height: giftDurationView.frame.height) | ||
| 69 | + giftDurationView.gradientBorder(width: 2, colors: [UIColor(rgb: 0x65DD6B), UIColor(rgb: 0x0D81B8)], startPoint: .unitCoordinate(.left), endPoint: .unitCoordinate(.right), andRoundCornersWithRadius: 35) | ||
| 70 | + | ||
| 71 | + borderLineView.applyGradient(colours: [UIColor(rgb: 0x0AA3CD), UIColor(rgb: 0x6ECA43)], gradient: GradientOrientation.horizontal, cornerRadius: 0.0) | ||
| 48 | 72 | ||
| 49 | activateButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 16) | 73 | activateButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 16) |
| 50 | activateButton.setTitle("Ενεργοποίηση", for: .normal) | 74 | activateButton.setTitle("Ενεργοποίηση", for: .normal) |
| 51 | activateButton.setTitleColor(.white, for: .normal) | 75 | activateButton.setTitleColor(.white, for: .normal) |
| 52 | activateButton.backgroundColor = UIColor(red: 0.47, green: 0.75, blue: 0.08, alpha: 1.00) | 76 | activateButton.backgroundColor = UIColor(red: 0.47, green: 0.75, blue: 0.08, alpha: 1.00) |
| 53 | activateButton.layer.cornerRadius = 12.0 | 77 | activateButton.layer.cornerRadius = 12.0 |
| 78 | + | ||
| 79 | + moreButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Regular", size: 16) | ||
| 80 | +// termsButton.imageView?.layer.transform = CATransform3DMakeScale(1.5, 1.5, 1.5) | ||
| 81 | + moreButton.setTitle("Δες Περισσότερα", for: .normal) | ||
| 82 | + moreButton.setTitleColor(UIColor(red: 0.25, green: 0.33, blue: 0.39, alpha: 1.00), for: .normal) | ||
| 83 | + moreButton.setImage(UIImage(named: "ic_down_dark.png"), for: .normal) | ||
| 84 | + // TODO: UNCOMMENT | ||
| 85 | +// moreButton.setImage(UIImage(named: "ic_down_dark.png", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil), for: .normal) | ||
| 86 | + moreButton.semanticContentAttribute = .forceRightToLeft | ||
| 87 | + moreButton.tintColor = UIColor(red: 0.21, green: 0.32, blue: 0.41, alpha: 1.00) | ||
| 88 | + moreButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 0); | ||
| 89 | + moreButton.titleEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 5); | ||
| 90 | + | ||
| 91 | +// let htmlText = ccms?._description ?? "" | ||
| 92 | +// moreTextView.attributedText = htmlText.htmlToAttributedString | ||
| 93 | + moreTextView.text = ccms?._termsAndConditions ?? "" | ||
| 94 | + moreTextView.font = UIFont(name: "PFSquareSansPro-Regular", size: 13) | ||
| 95 | + moreTextView.textColor = UIColor(rgb: 0x415564) | ||
| 96 | +// moreTextView.textAlignment = .center | ||
| 97 | + moreTextView.isScrollEnabled = false | ||
| 98 | + | ||
| 99 | + toggleMore() | ||
| 54 | } | 100 | } |
| 55 | 101 | ||
| 56 | // MARK: - Functions | 102 | // MARK: - Functions |
| 103 | + func toggleMore() { | ||
| 104 | + if (moreVisible) { | ||
| 105 | + moreTextView.isHidden = false | ||
| 106 | + let targetSize = CGSize(width: moreTextView.frame.width, height: CGFloat(MAXFLOAT)) | ||
| 107 | + moreTextViewHeight.constant = moreTextView.sizeThatFits(targetSize).height | ||
| 108 | + | ||
| 109 | + moreButton.setImage(UIImage(named: "ic_up_dark.png", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil), for: .normal) | ||
| 110 | + } else { | ||
| 111 | + moreTextView.isHidden = true | ||
| 112 | + moreTextViewHeight.constant = CGFloat(0) | ||
| 113 | + | ||
| 114 | + moreButton.setImage(UIImage(named: "ic_down_dark.png", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil), for: .normal) | ||
| 115 | + } | ||
| 116 | + } | ||
| 117 | + | ||
| 57 | func showConfirmDialog() -> Void { | 118 | func showConfirmDialog() -> Void { |
| 58 | 119 | ||
| 59 | let alert = UIAlertController(title: "Ενεργοποίηση υπηρεσίας", message: "Θέλετε να γίνει ενεργοποίηση στο Κινητό μου;", preferredStyle: .alert) | 120 | let alert = UIAlertController(title: "Ενεργοποίηση υπηρεσίας", message: "Θέλετε να γίνει ενεργοποίηση στο Κινητό μου;", preferredStyle: .alert) |
| ... | @@ -162,6 +223,11 @@ import UIKit | ... | @@ -162,6 +223,11 @@ import UIKit |
| 162 | @IBAction func activateButtomAction(_ sender: Any) { | 223 | @IBAction func activateButtomAction(_ sender: Any) { |
| 163 | self.numbersPopupTapped(sender) | 224 | self.numbersPopupTapped(sender) |
| 164 | } | 225 | } |
| 226 | + | ||
| 227 | + @IBAction func moreButtonAction(_ sender: Any) { | ||
| 228 | + moreVisible = !moreVisible | ||
| 229 | + toggleMore() | ||
| 230 | + } | ||
| 165 | } | 231 | } |
| 166 | 232 | ||
| 167 | // MARK: NumbersPopup | 233 | // MARK: NumbersPopup | ... | ... |
| ... | @@ -8,23 +8,33 @@ | ... | @@ -8,23 +8,33 @@ |
| 8 | import UIKit | 8 | import UIKit |
| 9 | 9 | ||
| 10 | extension UIViewController { | 10 | extension UIViewController { |
| 11 | - func setBackButton() { | 11 | + func setBackButton(_ icon:String = "ic_back") { |
| 12 | let uiscreen: CGRect = UIScreen.main.bounds | 12 | let uiscreen: CGRect = UIScreen.main.bounds |
| 13 | 13 | ||
| 14 | let backButton = UIButton(type: UIButton.ButtonType.custom) as UIButton | 14 | let backButton = UIButton(type: UIButton.ButtonType.custom) as UIButton |
| 15 | + if (icon == "ic_close") { | ||
| 16 | + backButton.frame = CGRect(x: 0, y: 0, width: uiscreen.height * 0.025, height: uiscreen.height * 0.025) | ||
| 17 | + } else { | ||
| 15 | backButton.frame = CGRect(x: 0, y: 0, width: uiscreen.height * 0.025, height: uiscreen.height * 0.02) | 18 | backButton.frame = CGRect(x: 0, y: 0, width: uiscreen.height * 0.025, height: uiscreen.height * 0.02) |
| 19 | + } | ||
| 16 | backButton.imageView!.contentMode = .scaleAspectFit | 20 | backButton.imageView!.contentMode = .scaleAspectFit |
| 17 | //backButton.setBackgroundImage(UIImage(named:Assets.Navigation.backButton), for: UIControlState()) | 21 | //backButton.setBackgroundImage(UIImage(named:Assets.Navigation.backButton), for: UIControlState()) |
| 18 | - backButton.setImage(UIImage(named: "ic_back", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil), for: .normal) | 22 | + backButton.setImage(UIImage(named: icon, in: Bundle(for: MyEmptyClass.self), compatibleWith: nil), for: .normal) |
| 19 | // backButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: -20, bottom: 0, right: 0) | 23 | // backButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: -20, bottom: 0, right: 0) |
| 20 | backButton.addTarget(self, action: #selector(moveToBack(_:)), for: .touchUpInside) | 24 | backButton.addTarget(self, action: #selector(moveToBack(_:)), for: .touchUpInside) |
| 21 | 25 | ||
| 22 | 26 | ||
| 23 | backButton.translatesAutoresizingMaskIntoConstraints = false | 27 | backButton.translatesAutoresizingMaskIntoConstraints = false |
| 24 | // Add width, height constraints | 28 | // Add width, height constraints |
| 29 | + if (icon == "ic_close") { | ||
| 30 | + let widthContraints = NSLayoutConstraint(item: backButton, attribute: NSLayoutConstraint.Attribute.width, relatedBy: NSLayoutConstraint.Relation.equal, toItem: nil, attribute: NSLayoutConstraint.Attribute.notAnAttribute, multiplier: 1, constant: uiscreen.height * 0.025) | ||
| 31 | + let heightContraints = NSLayoutConstraint(item: backButton, attribute: NSLayoutConstraint.Attribute.height, relatedBy: NSLayoutConstraint.Relation.equal, toItem: nil, attribute: NSLayoutConstraint.Attribute.notAnAttribute, multiplier: 1, constant: uiscreen.height * 0.025) | ||
| 32 | + NSLayoutConstraint.activate([heightContraints,widthContraints]) | ||
| 33 | + } else { | ||
| 25 | let widthContraints = NSLayoutConstraint(item: backButton, attribute: NSLayoutConstraint.Attribute.width, relatedBy: NSLayoutConstraint.Relation.equal, toItem: nil, attribute: NSLayoutConstraint.Attribute.notAnAttribute, multiplier: 1, constant: uiscreen.height * 0.025) | 34 | let widthContraints = NSLayoutConstraint(item: backButton, attribute: NSLayoutConstraint.Attribute.width, relatedBy: NSLayoutConstraint.Relation.equal, toItem: nil, attribute: NSLayoutConstraint.Attribute.notAnAttribute, multiplier: 1, constant: uiscreen.height * 0.025) |
| 26 | let heightContraints = NSLayoutConstraint(item: backButton, attribute: NSLayoutConstraint.Attribute.height, relatedBy: NSLayoutConstraint.Relation.equal, toItem: nil, attribute: NSLayoutConstraint.Attribute.notAnAttribute, multiplier: 1, constant: uiscreen.height * 0.02) | 35 | let heightContraints = NSLayoutConstraint(item: backButton, attribute: NSLayoutConstraint.Attribute.height, relatedBy: NSLayoutConstraint.Relation.equal, toItem: nil, attribute: NSLayoutConstraint.Attribute.notAnAttribute, multiplier: 1, constant: uiscreen.height * 0.02) |
| 27 | NSLayoutConstraint.activate([heightContraints,widthContraints]) | 36 | NSLayoutConstraint.activate([heightContraints,widthContraints]) |
| 37 | + } | ||
| 28 | 38 | ||
| 29 | let leftBarButtonItem: UIBarButtonItem = UIBarButtonItem(customView: backButton) | 39 | let leftBarButtonItem: UIBarButtonItem = UIBarButtonItem(customView: backButton) |
| 30 | self.navigationItem.setLeftBarButton(leftBarButtonItem, animated: false) | 40 | self.navigationItem.setLeftBarButton(leftBarButtonItem, animated: false) |
| ... | @@ -217,3 +227,65 @@ extension UIFont { | ... | @@ -217,3 +227,65 @@ extension UIFont { |
| 217 | return self.systemFont(ofSize: pointSize, weight: .medium) | 227 | return self.systemFont(ofSize: pointSize, weight: .medium) |
| 218 | } | 228 | } |
| 219 | } | 229 | } |
| 230 | + | ||
| 231 | +public extension UIView { | ||
| 232 | + | ||
| 233 | + private static let kLayerNameGradientBorder = "GradientBorderLayer" | ||
| 234 | + | ||
| 235 | + func gradientBorder(width: CGFloat, | ||
| 236 | + colors: [UIColor], | ||
| 237 | + startPoint: CGPoint = CGPoint(x: 0.5, y: 0.0), | ||
| 238 | + endPoint: CGPoint = CGPoint(x: 0.5, y: 1.0), | ||
| 239 | + andRoundCornersWithRadius cornerRadius: CGFloat = 0) { | ||
| 240 | + | ||
| 241 | + let existingBorder = gradientBorderLayer() | ||
| 242 | + let border = existingBorder ?? CAGradientLayer() | ||
| 243 | + border.frame = CGRect(x: bounds.origin.x, y: bounds.origin.y, | ||
| 244 | + width: bounds.size.width + width, height: bounds.size.height + width) | ||
| 245 | + border.colors = colors.map { return $0.cgColor } | ||
| 246 | + border.startPoint = startPoint | ||
| 247 | + border.endPoint = endPoint | ||
| 248 | + | ||
| 249 | + let mask = CAShapeLayer() | ||
| 250 | + let maskRect = CGRect(x: bounds.origin.x + width/2, y: bounds.origin.y + width/2, | ||
| 251 | + width: bounds.size.width - width, height: bounds.size.height - width) | ||
| 252 | + mask.path = UIBezierPath(roundedRect: maskRect, cornerRadius: cornerRadius).cgPath | ||
| 253 | + mask.fillColor = UIColor.clear.cgColor | ||
| 254 | + mask.strokeColor = UIColor.white.cgColor | ||
| 255 | + mask.lineWidth = width | ||
| 256 | + | ||
| 257 | + border.mask = mask | ||
| 258 | + | ||
| 259 | + let exists = (existingBorder != nil) | ||
| 260 | + if !exists { | ||
| 261 | + layer.addSublayer(border) | ||
| 262 | + } | ||
| 263 | + } | ||
| 264 | + private func gradientBorderLayer() -> CAGradientLayer? { | ||
| 265 | + let borderLayers = layer.sublayers?.filter { return $0.name == UIView.kLayerNameGradientBorder } | ||
| 266 | + if borderLayers?.count ?? 0 > 1 { | ||
| 267 | + fatalError() | ||
| 268 | + } | ||
| 269 | + return borderLayers?.first as? CAGradientLayer | ||
| 270 | + } | ||
| 271 | +} | ||
| 272 | + | ||
| 273 | +public extension CGPoint { | ||
| 274 | + | ||
| 275 | + enum CoordinateSide { | ||
| 276 | + case topLeft, top, topRight, right, bottomRight, bottom, bottomLeft, left | ||
| 277 | + } | ||
| 278 | + | ||
| 279 | + static func unitCoordinate(_ side: CoordinateSide) -> CGPoint { | ||
| 280 | + switch side { | ||
| 281 | + case .topLeft: return CGPoint(x: 0.0, y: 0.0) | ||
| 282 | + case .top: return CGPoint(x: 0.5, y: 0.0) | ||
| 283 | + case .topRight: return CGPoint(x: 1.0, y: 0.0) | ||
| 284 | + case .right: return CGPoint(x: 0.0, y: 0.5) | ||
| 285 | + case .bottomRight: return CGPoint(x: 1.0, y: 1.0) | ||
| 286 | + case .bottom: return CGPoint(x: 0.5, y: 1.0) | ||
| 287 | + case .bottomLeft: return CGPoint(x: 0.0, y: 1.0) | ||
| 288 | + case .left: return CGPoint(x: 1.0, y: 0.5) | ||
| 289 | + } | ||
| 290 | + } | ||
| 291 | +} | ... | ... |
-
Please register or login to post a comment