Manos Chorianopoulos

add toggleBarcode btn at CouponBarcodeVC

...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
7 <key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key> 7 <key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key>
8 <dict> 8 <dict>
9 <key>orderHint</key> 9 <key>orderHint</key>
10 - <integer>0</integer> 10 + <integer>1</integer>
11 </dict> 11 </dict>
12 </dict> 12 </dict>
13 </dict> 13 </dict>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
7 <key>SwiftWarplyFramework.xcscheme_^#shared#^_</key> 7 <key>SwiftWarplyFramework.xcscheme_^#shared#^_</key>
8 <dict> 8 <dict>
9 <key>orderHint</key> 9 <key>orderHint</key>
10 - <integer>1</integer> 10 + <integer>0</integer>
11 </dict> 11 </dict>
12 </dict> 12 </dict>
13 </dict> 13 </dict>
......
...@@ -23,15 +23,25 @@ import AVFoundation ...@@ -23,15 +23,25 @@ import AVFoundation
23 @IBOutlet weak var barcodeImage: UIImageView! 23 @IBOutlet weak var barcodeImage: UIImageView!
24 @IBOutlet weak var barcodeImageHeight: NSLayoutConstraint! 24 @IBOutlet weak var barcodeImageHeight: NSLayoutConstraint!
25 @IBOutlet weak var barcodeLabel: UILabel! 25 @IBOutlet weak var barcodeLabel: UILabel!
26 + @IBOutlet weak var barcodeLabelHeight: NSLayoutConstraint!
27 + @IBOutlet weak var showBarcodeButton: UIButton!
26 @IBOutlet weak var expirationLabel: UILabel! 28 @IBOutlet weak var expirationLabel: UILabel!
27 @IBOutlet weak var redeemButton: UIButton! 29 @IBOutlet weak var redeemButton: UIButton!
28 @IBOutlet weak var termsButton: UIButton! 30 @IBOutlet weak var termsButton: UIButton!
29 @IBOutlet weak var termsTextView: UITextView! 31 @IBOutlet weak var termsTextView: UITextView!
30 @IBOutlet weak var termsTextViewHeight: NSLayoutConstraint! 32 @IBOutlet weak var termsTextViewHeight: NSLayoutConstraint!
33 + @IBOutlet weak var borderViewHeight: NSLayoutConstraint!
34 + @IBOutlet weak var borderView2Height: NSLayoutConstraint!
35 + @IBOutlet weak var border1TopSpace: NSLayoutConstraint!
36 + @IBOutlet weak var barcodeImageTopSpace: NSLayoutConstraint!
37 + @IBOutlet weak var barcodeLabelTopSpace: NSLayoutConstraint!
38 + @IBOutlet weak var border2TopSpace: NSLayoutConstraint!
39 + @IBOutlet weak var mapButton: UIButton!
31 40
32 let uiscreen: CGRect = UIScreen.main.bounds 41 let uiscreen: CGRect = UIScreen.main.bounds
33 42
34 var termsVisible: Bool = false; 43 var termsVisible: Bool = false;
44 + var barcodeVisible: Bool = false;
35 45
36 public var coupon: swiftApi.CouponItemModel? 46 public var coupon: swiftApi.CouponItemModel?
37 47
...@@ -83,6 +93,12 @@ import AVFoundation ...@@ -83,6 +93,12 @@ import AVFoundation
83 redeemButton.setTitleColor(.white, for: .normal) 93 redeemButton.setTitleColor(.white, for: .normal)
84 redeemButton.backgroundColor = UIColor(red: 0.47, green: 0.75, blue: 0.08, alpha: 1.00) 94 redeemButton.backgroundColor = UIColor(red: 0.47, green: 0.75, blue: 0.08, alpha: 1.00)
85 redeemButton.layer.cornerRadius = 12.0 95 redeemButton.layer.cornerRadius = 12.0
96 +
97 + mapButton.titleLabel?.font = UIFont.systemFont(ofSize: 15, weight: .semibold)
98 + mapButton.setTitle("Δες τα καταστήματα", for: .normal)
99 + mapButton.setTitleColor(UIColor(red: 0.31, green: 0.62, blue: 0.18, alpha: 1.00), for: .normal)
100 + mapButton.backgroundColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00)
101 + mapButton.layer.cornerRadius = 12.0
86 102
87 termsButton.titleLabel?.font = .systemFont(ofSize: 15.0, weight: .medium) 103 termsButton.titleLabel?.font = .systemFont(ofSize: 15.0, weight: .medium)
88 // termsButton.imageView?.layer.transform = CATransform3DMakeScale(1.5, 1.5, 1.5) 104 // termsButton.imageView?.layer.transform = CATransform3DMakeScale(1.5, 1.5, 1.5)
...@@ -102,6 +118,7 @@ import AVFoundation ...@@ -102,6 +118,7 @@ import AVFoundation
102 termsTextView.isScrollEnabled = false 118 termsTextView.isScrollEnabled = false
103 119
104 toggleTerms() 120 toggleTerms()
121 + toggleBarcode()
105 122
106 // Logs 123 // Logs
107 print("Coupon: " + (coupon?.coupon ?? "")) 124 print("Coupon: " + (coupon?.coupon ?? ""))
...@@ -126,6 +143,48 @@ import AVFoundation ...@@ -126,6 +143,48 @@ import AVFoundation
126 termsButton.setImage(UIImage(named: "ic_down_dark.png", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil), for: .normal) 143 termsButton.setImage(UIImage(named: "ic_down_dark.png", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil), for: .normal)
127 } 144 }
128 } 145 }
146 +
147 + func toggleBarcode() {
148 + if (barcodeVisible) {
149 + barcodeImage.isHidden = false
150 + if (barcodeImage.image == nil) {
151 + barcodeImageHeight.constant = CGFloat(0)
152 + } else {
153 + barcodeImageHeight.constant = self.uiscreen.height * 0.1
154 + }
155 + barcodeLabel.isHidden = false
156 + let targetSize = CGSize(width: barcodeLabel.frame.width, height: CGFloat(MAXFLOAT))
157 + barcodeLabelHeight.constant = barcodeLabel.sizeThatFits(targetSize).height
158 +
159 + borderViewHeight.constant = CGFloat(1)
160 + borderView2Height.constant = CGFloat(1)
161 +
162 + border1TopSpace.constant = CGFloat(20) // 20
163 + barcodeImageTopSpace.constant = CGFloat(10) // 10
164 + barcodeLabelTopSpace.constant = CGFloat(10) // 10
165 + border2TopSpace.constant = CGFloat(15) // 15
166 +
167 + showBarcodeButton.setTitle("Απόκρυψη barcode", for: .normal)
168 + showBarcodeButton.setImage(UIImage(named: "ic_up_dark.png", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil), for: .normal)
169 +
170 + } else {
171 + barcodeImage.isHidden = true
172 + barcodeImageHeight.constant = CGFloat(0)
173 + barcodeLabel.isHidden = true
174 + barcodeLabelHeight.constant = CGFloat(0)
175 +
176 + borderViewHeight.constant = CGFloat(0)
177 + borderView2Height.constant = CGFloat(0)
178 +
179 + border1TopSpace.constant = CGFloat(0) // 20
180 + barcodeImageTopSpace.constant = CGFloat(0) // 10
181 + barcodeLabelTopSpace.constant = CGFloat(0) // 10
182 + border2TopSpace.constant = CGFloat(0) // 15
183 +
184 + showBarcodeButton.setTitle("Εμφάνιση barcode", for: .normal)
185 + showBarcodeButton.setImage(UIImage(named: "ic_down_dark.png", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil), for: .normal)
186 + }
187 + }
129 188
130 func constructBarcode() -> String? { 189 func constructBarcode() -> String? {
131 // EAN 13 barcode construction 190 // EAN 13 barcode construction
...@@ -169,9 +228,18 @@ import AVFoundation ...@@ -169,9 +228,18 @@ import AVFoundation
169 vc.coupon = self.coupon 228 vc.coupon = self.coupon
170 self.navigationController?.pushViewController(vc, animated: true) 229 self.navigationController?.pushViewController(vc, animated: true)
171 } 230 }
231 +
232 + @IBAction func showBarcodeAction(_ sender: Any) {
233 + barcodeVisible = !barcodeVisible
234 + toggleBarcode()
235 + }
172 236
173 @IBAction func termsButtonAction(_ sender: Any) { 237 @IBAction func termsButtonAction(_ sender: Any) {
174 termsVisible = !termsVisible 238 termsVisible = !termsVisible
175 toggleTerms() 239 toggleTerms()
176 } 240 }
241 +
242 + @IBAction func mapButtonAction(_ sender: Any) {
243 + // TODO: open MapVC
244 + }
177 } 245 }
......