Manos Chorianopoulos

CouponsetViewController redesign part2

......@@ -8,7 +8,7 @@
import UIKit
extension UIViewController {
func addFloatingBackButton(icon: String = "ic_back_3") {
func addFloatingBackButton(icon: String = "ic_back_4") {
let button = UIButton(type: .custom)
button.translatesAutoresizingMaskIntoConstraints = false
button.backgroundColor = .white
......@@ -17,6 +17,9 @@ extension UIViewController {
button.layer.shadowOpacity = 0.1
button.layer.shadowOffset = CGSize(width: 0, height: 2)
button.layer.shadowRadius = 4
button.imageView?.contentMode = .scaleAspectFit
button.contentEdgeInsets = UIEdgeInsets(top: 12, left: 12, bottom: 12, right: 12)
if let img = UIImage(named: icon, in: Bundle.frameworkResourceBundle, compatibleWith: nil) {
button.setImage(img, for: .normal)
......
......@@ -34,6 +34,7 @@ import UIKit
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var subtitleLabel: UILabel!
@IBOutlet weak var expirationView: UIView!
@IBOutlet weak var expirationImage: UIImageView!
@IBOutlet weak var expirationLabel: UILabel!
@IBOutlet weak var detailsLabel: UILabel!
......@@ -99,6 +100,7 @@ import UIKit
infoImage.image = UIImage(named: "info", in: Bundle.frameworkResourceBundle, compatibleWith: nil)
shareImage.image = UIImage(named: "share", in: Bundle.frameworkResourceBundle, compatibleWith: nil)
termsButtonArrowImage.image = UIImage(named: "arrow_down", in: Bundle.frameworkResourceBundle, compatibleWith: nil)
expirationImage.image = UIImage(named: "clock", in: Bundle.frameworkResourceBundle, compatibleWith: nil)
infoLabel.font = UIFont(name: "PingLCG-Regular", size: 13)
infoLabel.textColor = UIColor(rgb: 0x020E1C)
......@@ -172,6 +174,23 @@ import UIKit
if let response = response,
let result = response["result"] as? [String: Any],
let couponCode = result["coupon"] as? String {
self.redeemButton.setTitle("Saved to My Coupons", for: .normal)
self.redeemButton.setTitle("Saved to My Coupons", for: .disabled) // keeps title when disabled
self.redeemButton.backgroundColor = UIColor(rgb: 0xDBF6E6)
self.redeemButton.setTitleColor(UIColor(rgb: 0x0D9E5B), for: .normal)
self.redeemButton.setTitleColor(UIColor(rgb: 0x0D9E5B), for: .disabled) // keeps color when disabled
if let tickImage = UIImage(named: "tick", in: Bundle.frameworkResourceBundle, compatibleWith: nil) {
let tintedImage = tickImage.withRenderingMode(.alwaysTemplate)
self.redeemButton.setImage(tintedImage, for: .normal)
self.redeemButton.setImage(tintedImage, for: .disabled)
}
self.redeemButton.tintColor = UIColor(rgb: 0x17B26A)
self.redeemButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: -13, bottom: 0, right: 0)
// self.redeemButton.isEnabled = false
self.redeemButton.removeTarget(self, action: #selector(redeemButtonTapped), for: .touchUpInside)
let expiration = result["expiration"] as? String ?? ""
self.showSuccessAlert(couponCode: couponCode, expiration: expiration)
} else {
......
......@@ -12,6 +12,7 @@
<connections>
<outlet property="couponImage" destination="50f-Uw-WmD" id="yxn-pQ-nCT"/>
<outlet property="detailsLabel" destination="tOt-gP-Et5" id="H2V-Uq-Dsj"/>
<outlet property="expirationImage" destination="IO5-82-CjR" id="6OY-KM-0Kn"/>
<outlet property="expirationLabel" destination="PZ8-Go-A85" id="hXE-lo-i0w"/>
<outlet property="expirationView" destination="Haz-Ae-VkM" id="OMt-Fr-BW4"/>
<outlet property="favoriteImage" destination="kQb-LM-Zaa" id="75J-Ez-RZx"/>
......@@ -115,10 +116,18 @@
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Haz-Ae-VkM" userLabel="Expiration View">
<rect key="frame" x="24.000000000000004" y="347" width="55.333333333333343" height="34.333333333333314"/>
<rect key="frame" x="24" y="347" width="76.333333333333329" height="34.333333333333314"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="IO5-82-CjR" userLabel="Expiration Image">
<rect key="frame" x="10" y="10.333333333333314" width="14" height="14"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="14" id="2Kv-8v-5Rd"/>
<constraint firstAttribute="width" constant="14" id="kDx-vc-7Ie"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="PZ8-Go-A85" userLabel="Expiration Label">
<rect key="frame" x="7" y="6.9999999999999982" width="41.333333333333336" height="20.333333333333329"/>
<rect key="frame" x="28.000000000000004" y="6.9999999999999982" width="41.333333333333343" height="20.333333333333329"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
......@@ -126,10 +135,12 @@
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="PZ8-Go-A85" firstAttribute="leading" secondItem="Haz-Ae-VkM" secondAttribute="leading" constant="7" id="GHg-uf-y2A"/>
<constraint firstItem="PZ8-Go-A85" firstAttribute="leading" secondItem="IO5-82-CjR" secondAttribute="trailing" constant="4" id="GHg-uf-y2A"/>
<constraint firstAttribute="bottom" secondItem="PZ8-Go-A85" secondAttribute="bottom" constant="7" id="lzh-zn-eSc"/>
<constraint firstAttribute="trailing" secondItem="PZ8-Go-A85" secondAttribute="trailing" constant="7" id="mOL-XE-ayp"/>
<constraint firstItem="IO5-82-CjR" firstAttribute="leading" secondItem="Haz-Ae-VkM" secondAttribute="leading" constant="10" id="st4-Ng-17V"/>
<constraint firstItem="PZ8-Go-A85" firstAttribute="top" secondItem="Haz-Ae-VkM" secondAttribute="top" constant="7" id="u2c-QD-K7q"/>
<constraint firstItem="IO5-82-CjR" firstAttribute="centerY" secondItem="Haz-Ae-VkM" secondAttribute="centerY" id="xvt-yn-tD3"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="tOt-gP-Et5" userLabel="Details Label">
......