Manos Chorianopoulos

add toggleBarcode btn at CouponBarcodeVC

......@@ -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>
......
......@@ -23,15 +23,25 @@ import AVFoundation
@IBOutlet weak var barcodeImage: UIImageView!
@IBOutlet weak var barcodeImageHeight: NSLayoutConstraint!
@IBOutlet weak var barcodeLabel: UILabel!
@IBOutlet weak var barcodeLabelHeight: NSLayoutConstraint!
@IBOutlet weak var showBarcodeButton: UIButton!
@IBOutlet weak var expirationLabel: UILabel!
@IBOutlet weak var redeemButton: UIButton!
@IBOutlet weak var termsButton: UIButton!
@IBOutlet weak var termsTextView: UITextView!
@IBOutlet weak var termsTextViewHeight: NSLayoutConstraint!
@IBOutlet weak var borderViewHeight: NSLayoutConstraint!
@IBOutlet weak var borderView2Height: NSLayoutConstraint!
@IBOutlet weak var border1TopSpace: NSLayoutConstraint!
@IBOutlet weak var barcodeImageTopSpace: NSLayoutConstraint!
@IBOutlet weak var barcodeLabelTopSpace: NSLayoutConstraint!
@IBOutlet weak var border2TopSpace: NSLayoutConstraint!
@IBOutlet weak var mapButton: UIButton!
let uiscreen: CGRect = UIScreen.main.bounds
var termsVisible: Bool = false;
var barcodeVisible: Bool = false;
public var coupon: swiftApi.CouponItemModel?
......@@ -83,6 +93,12 @@ import AVFoundation
redeemButton.setTitleColor(.white, for: .normal)
redeemButton.backgroundColor = UIColor(red: 0.47, green: 0.75, blue: 0.08, alpha: 1.00)
redeemButton.layer.cornerRadius = 12.0
mapButton.titleLabel?.font = UIFont.systemFont(ofSize: 15, weight: .semibold)
mapButton.setTitle("Δες τα καταστήματα", for: .normal)
mapButton.setTitleColor(UIColor(red: 0.31, green: 0.62, blue: 0.18, alpha: 1.00), for: .normal)
mapButton.backgroundColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00)
mapButton.layer.cornerRadius = 12.0
termsButton.titleLabel?.font = .systemFont(ofSize: 15.0, weight: .medium)
// termsButton.imageView?.layer.transform = CATransform3DMakeScale(1.5, 1.5, 1.5)
......@@ -102,6 +118,7 @@ import AVFoundation
termsTextView.isScrollEnabled = false
toggleTerms()
toggleBarcode()
// Logs
print("Coupon: " + (coupon?.coupon ?? ""))
......@@ -126,6 +143,48 @@ import AVFoundation
termsButton.setImage(UIImage(named: "ic_down_dark.png", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil), for: .normal)
}
}
func toggleBarcode() {
if (barcodeVisible) {
barcodeImage.isHidden = false
if (barcodeImage.image == nil) {
barcodeImageHeight.constant = CGFloat(0)
} else {
barcodeImageHeight.constant = self.uiscreen.height * 0.1
}
barcodeLabel.isHidden = false
let targetSize = CGSize(width: barcodeLabel.frame.width, height: CGFloat(MAXFLOAT))
barcodeLabelHeight.constant = barcodeLabel.sizeThatFits(targetSize).height
borderViewHeight.constant = CGFloat(1)
borderView2Height.constant = CGFloat(1)
border1TopSpace.constant = CGFloat(20) // 20
barcodeImageTopSpace.constant = CGFloat(10) // 10
barcodeLabelTopSpace.constant = CGFloat(10) // 10
border2TopSpace.constant = CGFloat(15) // 15
showBarcodeButton.setTitle("Απόκρυψη barcode", for: .normal)
showBarcodeButton.setImage(UIImage(named: "ic_up_dark.png", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil), for: .normal)
} else {
barcodeImage.isHidden = true
barcodeImageHeight.constant = CGFloat(0)
barcodeLabel.isHidden = true
barcodeLabelHeight.constant = CGFloat(0)
borderViewHeight.constant = CGFloat(0)
borderView2Height.constant = CGFloat(0)
border1TopSpace.constant = CGFloat(0) // 20
barcodeImageTopSpace.constant = CGFloat(0) // 10
barcodeLabelTopSpace.constant = CGFloat(0) // 10
border2TopSpace.constant = CGFloat(0) // 15
showBarcodeButton.setTitle("Εμφάνιση barcode", for: .normal)
showBarcodeButton.setImage(UIImage(named: "ic_down_dark.png", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil), for: .normal)
}
}
func constructBarcode() -> String? {
// EAN 13 barcode construction
......@@ -169,9 +228,18 @@ import AVFoundation
vc.coupon = self.coupon
self.navigationController?.pushViewController(vc, animated: true)
}
@IBAction func showBarcodeAction(_ sender: Any) {
barcodeVisible = !barcodeVisible
toggleBarcode()
}
@IBAction func termsButtonAction(_ sender: Any) {
termsVisible = !termsVisible
toggleTerms()
}
@IBAction func mapButtonAction(_ sender: Any) {
// TODO: open MapVC
}
}
......