Manos Chorianopoulos

Wallet changes

......@@ -839,7 +839,7 @@
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="wallet_dfy_earn" translatesAutoresizingMaskIntoConstraints="NO" id="J7v-XB-iCp">
<rect key="frame" x="0.0" y="0.0" width="90" height="90"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="18,00€" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="E1I-Ms-Wub">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0,00€" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="E1I-Ms-Wub">
<rect key="frame" x="5" y="54" width="80" height="14"/>
<fontDescription key="fontDescription" name="PFSquareSansPro-ExtraBlack" family="PF Square Sans Pro" pointSize="14"/>
<color key="textColor" red="0.25490196079999999" green="0.33333333329999998" blue="0.3921568627" alpha="1" colorSpace="calibratedRGB"/>
......@@ -865,7 +865,7 @@
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="wallet_dfy_earn" translatesAutoresizingMaskIntoConstraints="NO" id="cYY-uD-dwf">
<rect key="frame" x="0.0" y="0.0" width="75" height="75"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="18,00€" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uDb-BJ-aht">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0,00€" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uDb-BJ-aht">
<rect key="frame" x="5" y="46" width="65" height="11"/>
<fontDescription key="fontDescription" name="PFSquareSansPro-ExtraBlack" family="PF Square Sans Pro" pointSize="11"/>
<color key="textColor" red="0.25490196079999999" green="0.33333333329999998" blue="0.3921568627" alpha="1" colorSpace="calibratedRGB"/>
......@@ -906,7 +906,7 @@
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="wallet_dfy_earn" translatesAutoresizingMaskIntoConstraints="NO" id="blj-YT-unI">
<rect key="frame" x="0.0" y="0.0" width="75" height="75"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="18,00€" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="rPe-HK-KW1">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0,00€" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="rPe-HK-KW1">
<rect key="frame" x="5" y="46" width="65" height="11"/>
<fontDescription key="fontDescription" name="PFSquareSansPro-ExtraBlack" family="PF Square Sans Pro" pointSize="11"/>
<color key="textColor" red="0.25490196079999999" green="0.33333333329999998" blue="0.3921568627" alpha="1" colorSpace="calibratedRGB"/>
......@@ -947,7 +947,7 @@
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="wallet_dfy_earn" translatesAutoresizingMaskIntoConstraints="NO" id="EZL-9s-XvQ">
<rect key="frame" x="0.0" y="0.0" width="75" height="75"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="18,00€" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="rid-Wp-gA9">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0,00€" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="rid-Wp-gA9">
<rect key="frame" x="5" y="46" width="65" height="11"/>
<fontDescription key="fontDescription" name="PFSquareSansPro-ExtraBlack" family="PF Square Sans Pro" pointSize="11"/>
<color key="textColor" red="0.25490196079999999" green="0.33333333329999998" blue="0.3921568627" alpha="1" colorSpace="calibratedRGB"/>
......@@ -1531,23 +1531,23 @@
</connections>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" reuseIdentifier="UnifiedCouponsTableViewCellId" id="DUH-nG-QWi" customClass="UnifiedCouponsTableViewCell" customModule="SwiftWarplyFramework">
<rect key="frame" x="0.0" y="923.5" width="414" height="44"/>
<rect key="frame" x="0.0" y="923.5" width="414" height="64.5"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="DUH-nG-QWi" id="rx6-wA-MYI">
<rect key="frame" x="0.0" y="0.0" width="414" height="44"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="64.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="WW2-mP-ZJD">
<rect key="frame" x="10" y="0.0" width="394" height="44"/>
<rect key="frame" x="10" y="0.0" width="394" height="64.5"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="coupon_bg" translatesAutoresizingMaskIntoConstraints="NO" id="Gde-3J-Ew9">
<rect key="frame" x="0.0" y="0.0" width="394" height="44"/>
<rect key="frame" x="0.0" y="0.0" width="394" height="64.5"/>
</imageView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="87q-5c-uea">
<rect key="frame" x="20" y="10" width="79" height="24"/>
<rect key="frame" x="20" y="10" width="79" height="44.5"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="XsA-Nw-7Pr">
<rect key="frame" x="18" y="18" width="43" height="0.0"/>
<rect key="frame" x="18" y="18" width="43" height="8.5"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</imageView>
</subviews>
......@@ -1560,41 +1560,26 @@
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="u97-5H-Y40">
<rect key="frame" x="104" y="5" width="10" height="34"/>
<rect key="frame" x="104" y="5" width="10" height="54.5"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" constant="10" id="Tcx-FG-KC0"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7Ng-4X-yjm">
<rect key="frame" x="119" y="15" width="255" height="0.0"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7Ng-4X-yjm">
<rect key="frame" x="119" y="15" width="163.5" height="17"/>
<fontDescription key="fontDescription" name="PFSquareSansPro-Medium" family="PF Square Sans Pro" pointSize="17"/>
<color key="textColor" red="0.2274509804" green="0.32156862749999998" blue="0.40000000000000002" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<stackView opaque="NO" contentMode="scaleToFill" spacing="5" translatesAutoresizingMaskIntoConstraints="NO" id="fjU-NZ-UM8">
<rect key="frame" x="119" y="20" width="255" height="4"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="lhE-IF-PdV">
<rect key="frame" x="0.0" y="0.0" width="127.5" height="4"/>
<fontDescription key="fontDescription" name="PFSquareSansPro-Bold" family="PF Square Sans Pro" pointSize="31"/>
<color key="textColor" red="0.2274509804" green="0.32156862749999998" blue="0.40000000000000002" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="KJD-Db-B4t">
<rect key="frame" x="132.5" y="0.0" width="122.5" height="4"/>
<fontDescription key="fontDescription" name="PFSquareSansPro-Medium" family="PF Square Sans Pro" pointSize="12"/>
<color key="textColor" red="0.3803921569" green="0.4431372549" blue="0.50588235290000005" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="lhE-IF-PdV" firstAttribute="width" secondItem="fjU-NZ-UM8" secondAttribute="width" multiplier="0.5" id="jV0-Rz-MOC"/>
</constraints>
</stackView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="KJD-Db-B4t">
<rect key="frame" x="292.5" y="26.5" width="81.5" height="12"/>
<fontDescription key="fontDescription" name="PFSquareSansPro-Medium" family="PF Square Sans Pro" pointSize="12"/>
<color key="textColor" red="0.3803921569" green="0.4431372549" blue="0.50588235290000005" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="C5t-xz-oAO">
<rect key="frame" x="119" y="29" width="255" height="0.0"/>
<rect key="frame" x="119" y="37.5" width="255" height="12"/>
<fontDescription key="fontDescription" name="PFSquareSansPro-Medium" family="PF Square Sans Pro" pointSize="12"/>
<color key="textColor" red="0.3803921569" green="0.4431372549" blue="0.50588235290000005" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
......@@ -1603,27 +1588,25 @@
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="u97-5H-Y40" secondAttribute="bottom" constant="5" id="1Lc-bv-1Al"/>
<constraint firstAttribute="trailing" secondItem="7Ng-4X-yjm" secondAttribute="trailing" constant="20" id="1nu-j0-QIj"/>
<constraint firstItem="Gde-3J-Ew9" firstAttribute="leading" secondItem="WW2-mP-ZJD" secondAttribute="leading" id="40f-ex-Phx"/>
<constraint firstItem="7Ng-4X-yjm" firstAttribute="leading" secondItem="u97-5H-Y40" secondAttribute="trailing" constant="5" id="5TF-wG-jX1"/>
<constraint firstItem="87q-5c-uea" firstAttribute="top" secondItem="WW2-mP-ZJD" secondAttribute="top" constant="10" id="6AJ-EI-bPD"/>
<constraint firstAttribute="trailing" secondItem="Gde-3J-Ew9" secondAttribute="trailing" id="Aal-fh-wUH"/>
<constraint firstItem="fjU-NZ-UM8" firstAttribute="centerY" secondItem="WW2-mP-ZJD" secondAttribute="centerY" id="BOY-1A-D30"/>
<constraint firstItem="KJD-Db-B4t" firstAttribute="leading" secondItem="7Ng-4X-yjm" secondAttribute="trailing" constant="10" id="CE4-RE-oQa"/>
<constraint firstItem="7Ng-4X-yjm" firstAttribute="top" secondItem="WW2-mP-ZJD" secondAttribute="top" constant="15" id="EFT-xp-xck"/>
<constraint firstAttribute="trailing" secondItem="KJD-Db-B4t" secondAttribute="trailing" constant="20" id="FxZ-Fg-Cto"/>
<constraint firstItem="87q-5c-uea" firstAttribute="width" secondItem="WW2-mP-ZJD" secondAttribute="width" multiplier="0.2" id="Jct-QS-76d"/>
<constraint firstItem="fjU-NZ-UM8" firstAttribute="leading" secondItem="u97-5H-Y40" secondAttribute="trailing" constant="5" id="Kr7-AR-EG1"/>
<constraint firstItem="u97-5H-Y40" firstAttribute="top" secondItem="WW2-mP-ZJD" secondAttribute="top" constant="5" id="MwF-kc-vsh"/>
<constraint firstItem="fjU-NZ-UM8" firstAttribute="top" relation="greaterThanOrEqual" secondItem="7Ng-4X-yjm" secondAttribute="bottom" constant="5" id="Q7K-FB-afo"/>
<constraint firstItem="KJD-Db-B4t" firstAttribute="centerY" secondItem="WW2-mP-ZJD" secondAttribute="centerY" id="NmT-xf-UuO"/>
<constraint firstItem="C5t-xz-oAO" firstAttribute="leading" secondItem="u97-5H-Y40" secondAttribute="trailing" constant="5" id="Qud-Nb-9mK"/>
<constraint firstItem="7Ng-4X-yjm" firstAttribute="width" secondItem="KJD-Db-B4t" secondAttribute="width" multiplier="2" id="Tcm-US-ex1"/>
<constraint firstItem="Gde-3J-Ew9" firstAttribute="top" secondItem="WW2-mP-ZJD" secondAttribute="top" id="kMk-q4-Ig9"/>
<constraint firstAttribute="bottom" secondItem="Gde-3J-Ew9" secondAttribute="bottom" id="kVb-zO-dgp"/>
<constraint firstItem="87q-5c-uea" firstAttribute="leading" secondItem="WW2-mP-ZJD" secondAttribute="leading" constant="20" id="kW3-Fe-zjx"/>
<constraint firstAttribute="trailing" secondItem="fjU-NZ-UM8" secondAttribute="trailing" constant="20" id="paQ-99-YFA"/>
<constraint firstAttribute="bottom" secondItem="87q-5c-uea" secondAttribute="bottom" constant="10" id="qXI-m9-UWA"/>
<constraint firstItem="u97-5H-Y40" firstAttribute="leading" secondItem="87q-5c-uea" secondAttribute="trailing" constant="5" id="rU6-Db-qdS"/>
<constraint firstAttribute="trailing" secondItem="C5t-xz-oAO" secondAttribute="trailing" constant="20" id="sjh-Xe-FAi"/>
<constraint firstAttribute="bottom" secondItem="C5t-xz-oAO" secondAttribute="bottom" constant="15" id="ujL-p5-XBS"/>
<constraint firstItem="C5t-xz-oAO" firstAttribute="top" relation="greaterThanOrEqual" secondItem="fjU-NZ-UM8" secondAttribute="bottom" constant="5" id="yPM-CY-avN"/>
</constraints>
</view>
</subviews>
......@@ -1640,7 +1623,6 @@
<outlet property="borderView" destination="u97-5H-Y40" id="unw-S4-1cW"/>
<outlet property="couponBgImage" destination="Gde-3J-Ew9" id="zAU-dC-iJ3"/>
<outlet property="couponImage" destination="XsA-Nw-7Pr" id="sPO-ba-7pB"/>
<outlet property="dicountLabel" destination="lhE-IF-PdV" id="w8c-Rx-0yP"/>
<outlet property="discriptionLabel" destination="KJD-Db-B4t" id="Iac-05-eFb"/>
<outlet property="expirationLabel" destination="C5t-xz-oAO" id="PvS-Fj-fua"/>
<outlet property="nameLabel" destination="7Ng-4X-yjm" id="FfZ-6W-xyF"/>
......
......@@ -13,28 +13,9 @@ class UnifiedCouponsTableViewCell: UITableViewCell {
@IBOutlet weak var couponImage: UIImageView!
@IBOutlet weak var borderView: UIView!
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var dicountLabel: UILabel!
@IBOutlet weak var discriptionLabel: UILabel!
@IBOutlet weak var expirationLabel: UILabel!
var postImageURL: String? {
didSet {
if let url = postImageURL {
self.couponImage.image = UIImage() // UIImage(named: "loading")
UIImage.loadImageUsingCacheWithUrlString(url) { image in
// set the image only when we are still displaying the content for the image we finished downloading
if url == self.postImageURL {
self.couponImage.image = image
}
}
}
else {
self.couponImage.image = nil
}
}
}
public override func awakeFromNib() {
super.awakeFromNib()
......@@ -61,37 +42,25 @@ class UnifiedCouponsTableViewCell: UITableViewCell {
}
func configureCell(coupon: swiftApi.CouponItemModel) {
// COUPONSET: desc, img_preview, name, terms, merchant_uuid, discount_type, final_price
// COUPON: coupon, expiration, discount, status
// MERCHANT: _img_preview,_admin_name
let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList()
func configureCell(coupon: swiftApi.UnifiedCouponModel) {
var activeCouponsCount:Int = 0
for coupon in coupon._coupons {
if (coupon.status == 1) {
activeCouponsCount += 1
}
}
let couponSetData: swiftApi.CouponSetItemModel? = coupon.couponset_data
nameLabel.text = "COSMOTE SuperMarket Deals"
nameLabel.text = ""
discriptionLabel.text =
activeCouponsCount == 1 ? "έχεις " + String(activeCouponsCount) + " ενεργό κουπόνι"
: "έχεις " + String(activeCouponsCount) + " ενεργά κουπόνια"
for merchant in merchantList {
if (merchant._uuid == couponSetData?.merchant_uuid) {
// couponImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache())
// self.postImageURL = merchant._img_preview
nameLabel.text = merchant._admin_name
break;
}
if let earliestExpiration = coupon._coupons.min(by: { ($0.expiration ?? "") < ($1.expiration ?? "") }) {
expirationLabel.text = "Ισχύει έως " + (earliestExpiration.expiration ?? "")
} else {
expirationLabel.text = ""
}
// couponImage.load(link: couponSetData?.img_preview ?? "", placeholder: UIImage(), cache: URLCache())
// nameLabel.text = couponSetData?.name ?? ""
let discount = couponSetData?.discount_type == "value" ? ((coupon.discount ?? "") + "€")
: couponSetData?.discount_type == "percentage" ? ((coupon.discount ?? "") + "%")
: couponSetData?.discount_type == "plus_one" ? "1+1"
: ((coupon.discount ?? "") + "€")
dicountLabel.text = discount
// let htmlText = couponSetData?.inner_text ?? ""
// discriptionLabel.text = htmlText.htmlToString
discriptionLabel.text = couponSetData?.inner_text ?? ""
expirationLabel.text = "Ισχύει έως "+(coupon.expiration ?? "")
}
}
......
......@@ -63,10 +63,14 @@ import SwiftEventBus
public var loyaltyBadge:swiftApi.LoyaltyBadgeModel = swiftApi().getLoyaltyBadge()
public var profile:swiftApi.ProfileModel? = swiftApi().getConsumer()
// TODO: Add correct unifiedCoupons
public var unifiedCoupons:Array<swiftApi.CouponItemModel> = swiftApi().getCouponList()
public var unifiedCoupons:Array<swiftApi.UnifiedCouponModel> = []
var timerWallet: DispatchSourceTimer?
var seconds: Int = 0
var totalCouponValue = swiftApi().getDealsCouponsSum()
let totalCouponDiscount = Float(round(100 * swiftApi().getLoyaltyBadge()._value) / 100)
var unifiedCouponsDiscount:Float = 0.0
public override func viewDidLoad() {
super.viewDidLoad()
......@@ -97,6 +101,8 @@ import SwiftEventBus
// dfyCoupons = swiftApi().getActiveDFYCoupons()
// TODO: DELETE <===
getUnifiedCouponsRequest()
setBackButton()
setNavigationTitle("My Rewards")
......@@ -169,7 +175,7 @@ import SwiftEventBus
dfyEarnBannerView.layer.shadowOpacity = 1.0
dfyEarnBannerView.layer.shadowRadius = 3.0
var totalCouponValue = swiftApi().getDealsCouponsSum()
// var totalCouponValue = swiftApi().getDealsCouponsSum()
if (totalCouponValue == 0.0) {
dfyEarnBannerView.isHidden = true
......@@ -240,7 +246,7 @@ import SwiftEventBus
couponEarnView.layer.shadowOpacity = 1.0
couponEarnView.layer.shadowRadius = 3.0
let totalCouponDiscount = Float(round(100 * loyaltyBadge._value) / 100)
// let totalCouponDiscount = Float(round(100 * loyaltyBadge._value) / 100)
var totalCouponDiscountString = "0"
totalCouponDiscountString = String(format: "%.2f", totalCouponDiscount).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
......@@ -273,25 +279,43 @@ import SwiftEventBus
print("Loyalty Badge Count: " + String(loyaltyBadge._couponCount))
// Rewards View - Market Badge
//
// var unifiedCouponsDiscount:Float = 0.0
// for uniCoupon in unifiedCoupons {
// for coupon in uniCoupon._coupons {
// if (coupon.status == 1) {
// if let discountFloat = Float(coupon.discount ?? "0.0") {
// unifiedCouponsDiscount += discountFloat
// }
// }
// }
// }
//
// let marketDiscount = Float(round(100 * unifiedCouponsDiscount) / 100)
// var marketDiscountString = "0"
// marketDiscountString = String(format: "%.2f", marketDiscount).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
//
// self.marketBadgeLabel.text = marketDiscountString + "€"
// TODO: Fix empty check
if (false) {
marketBadgeImage.image = UIImage(named: "wallet_market_empty", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
marketBadgeLabel.isHidden = true
} else {
marketBadgeImage.image = UIImage(named: "wallet_market", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
marketBadgeLabel.isHidden = false
}
// if (unifiedCouponsDiscount == 0.0) {
// marketBadgeImage.image = UIImage(named: "wallet_market_empty", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
// marketBadgeLabel.isHidden = true
//
// } else {
// marketBadgeImage.image = UIImage(named: "wallet_market", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
// marketBadgeLabel.isHidden = false
// }
// TODO: Fix dynamic value
marketBadgeLabel.text = "10,00" + "€"
// marketBadgeLabel.text = "0,00" + "€"
// Rewards View
// TODO: Add market value
let sumRewards = totalCouponValue + totalCouponDiscount
// sumRewards = Float(round(100 * sumRewards) / 100)
var sumRewardsString = "0"
sumRewardsString = String(format: "%.2f", sumRewards).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
sumBadgeLabel.text = sumRewardsString + "€"
// let sumRewards = totalCouponValue + totalCouponDiscount + unifiedCouponsDiscount
//// sumRewards = Float(round(100 * sumRewards) / 100)
// var sumRewardsString = "0"
// sumRewardsString = String(format: "%.2f", sumRewards).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
// sumBadgeLabel.text = sumRewardsString + "€"
// activeCodeView
activeCodeView.layer.cornerRadius = 5.0
......@@ -433,24 +457,24 @@ import SwiftEventBus
emptyLabel.text = "Δεν έχεις κάποιον ενεργό κωδικό ή κουπόνι! Μπες τώρα στην ενότητα COSMOTE For You και βρες αποκλειστικές προσφορές!"
// TODO: FIX emptyView check - add market badge check
if (totalCouponValue == 0.0 && loyaltyBadge._couponCount == 0) {
rewardsView.isHidden = true
rewardsViewHeight.constant = 0
} else {
rewardsView.isHidden = false
rewardsViewHeight.constant = rewardsView.intrinsicContentSize.height
}
// if (totalCouponValue == 0.0 && loyaltyBadge._couponCount == 0 && unifiedCouponsDiscount == 0.0) {
// rewardsView.isHidden = true
// rewardsViewHeight.constant = 0
// } else {
// rewardsView.isHidden = false
// rewardsViewHeight.constant = rewardsView.intrinsicContentSize.height
// }
// TODO: FIX emptyView check - add market badge check
// if (totalCouponValue == 0.0 && loyaltyBadge._couponCount == 0 && dfyCoupons.count == 0 && coupons.count == 0) {
if (totalCouponValue == 0.0 && loyaltyBadge._couponCount == 0 && dfyCoupons.count == 0 && coupons.count == 0 && unifiedCoupons.count == 0) {
emptyView.isHidden = false
emptyViewHeight.constant = rewardsView.intrinsicContentSize.height
} else {
emptyView.isHidden = true
emptyViewHeight.constant = 0
}
// if (totalCouponValue == 0.0 && loyaltyBadge._couponCount == 0 && dfyCoupons.count == 0 && coupons.count == 0 && unifiedCoupons.count == 0 && unifiedCouponsDiscount == 0.0) {
// emptyView.isHidden = false
// emptyViewHeight.constant = rewardsView.intrinsicContentSize.height
// } else {
// emptyView.isHidden = true
// emptyViewHeight.constant = 0
// }
updateMarketBadge()
}
public override func viewWillAppear(_ animated: Bool) {
......@@ -494,6 +518,8 @@ import SwiftEventBus
}
self.coupons = swiftApi().getCouponList()
self.unifiedCoupons = swiftApi().getUnifiedCouponList()
self.updateMarketBadge()
self.tableView.reloadData()
self.startTimer()
......@@ -577,6 +603,77 @@ import SwiftEventBus
seconds = 0
}
func updateMarketBadge() {
for uniCoupon in self.unifiedCoupons {
for coupon in uniCoupon._coupons {
if (coupon.status == 1) {
if let discountFloat = Float(coupon.discount ?? "0.0") {
unifiedCouponsDiscount += discountFloat
}
}
}
}
let marketDiscount = Float(round(100 * unifiedCouponsDiscount) / 100)
var marketDiscountString = "0"
marketDiscountString = String(format: "%.2f", marketDiscount).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
self.marketBadgeLabel.text = marketDiscountString + "€"
if (unifiedCouponsDiscount == 0.0) {
marketBadgeImage.image = UIImage(named: "wallet_market_empty", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
marketBadgeLabel.isHidden = true
} else {
marketBadgeImage.image = UIImage(named: "wallet_market", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
marketBadgeLabel.isHidden = false
}
let sumRewards = totalCouponValue + totalCouponDiscount + unifiedCouponsDiscount
// sumRewards = Float(round(100 * sumRewards) / 100)
var sumRewardsString = "0"
sumRewardsString = String(format: "%.2f", sumRewards).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
sumBadgeLabel.text = sumRewardsString + "€"
if (totalCouponValue == 0.0 && loyaltyBadge._couponCount == 0 && unifiedCouponsDiscount == 0.0) {
rewardsView.isHidden = true
rewardsViewHeight.constant = 0
} else {
rewardsView.isHidden = false
rewardsViewHeight.constant = rewardsView.intrinsicContentSize.height
}
// TODO: FIX emptyView check - add market badge check
// if (totalCouponValue == 0.0 && loyaltyBadge._couponCount == 0 && dfyCoupons.count == 0 && coupons.count == 0) {
if (totalCouponValue == 0.0 && loyaltyBadge._couponCount == 0 && dfyCoupons.count == 0 && coupons.count == 0 && unifiedCoupons.count == 0 && unifiedCouponsDiscount == 0.0) {
emptyView.isHidden = false
emptyViewHeight.constant = rewardsView.intrinsicContentSize.height
} else {
emptyView.isHidden = true
emptyViewHeight.constant = 0
}
}
// MARK: - API Functions
func getUnifiedCouponsRequest() {
swiftApi().getUnifiedCouponsAsync(getUnifiedCouponsCallback, failureCallback: {errorCode in
self.unifiedCoupons = []
})
}
func getUnifiedCouponsCallback (_ couponsData: Array<swiftApi.UnifiedCouponModel>?) -> Void {
if (couponsData != nil) {
self.unifiedCoupons = couponsData ?? []
DispatchQueue.main.async {
self.updateMarketBadge()
self.tableView.reloadData()
}
} else {
self.unifiedCoupons = []
}
}
// MARK: - Actions
@IBAction func qustionnaireButtonAction(_ sender: Any) {
swiftApi().logTrackersEvent("click", ("LoyaltyWalletScreen:" + "Questionnaire"))
......@@ -670,9 +767,7 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if (section == 0) {
// TODO: Dynamic
return 3
// return self.unifiedCoupons.count
return self.unifiedCoupons.count
} else if (section == 1) {
if (self.dfyCoupons.count > 0) {
return 1
......@@ -793,7 +888,7 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{
if (indexPath.section == 0) {
let cell = tableView.dequeueReusableCell(withIdentifier: "UnifiedCouponsTableViewCellId", for: indexPath) as! UnifiedCouponsTableViewCell
cell.configureCell(coupon: coupons[indexPath.row])
cell.configureCell(coupon: unifiedCoupons[indexPath.row])
return cell
} else if (indexPath.section == 1) {
......