Manos Chorianopoulos

Add Unified Coupons discount value at My Rewards

......@@ -2278,7 +2278,7 @@
<color key="textColor" red="0.12941176470588234" green="0.12941176470588234" blue="0.12941176470588234" 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">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" numberOfLines="4" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="KJD-Db-B4t">
<rect key="frame" x="292.5" y="25" width="81.5" height="15"/>
<fontDescription key="fontDescription" name="PeridotPE-Regular" family="Peridot PE" pointSize="12"/>
<color key="textColor" red="0.12941176470588234" green="0.12941176470588234" blue="0.12941176470588234" alpha="1" colorSpace="calibratedRGB"/>
......@@ -2335,23 +2335,23 @@
</connections>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" reuseIdentifier="WalletBadgesTableViewCellId" id="TeS-tP-Ilh" customClass="WalletBadgesTableViewCell" customModule="SwiftWarplyFramework">
<rect key="frame" x="0.0" y="947.5" width="414" height="44"/>
<rect key="frame" x="0.0" y="947.5" width="414" height="260"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="TeS-tP-Ilh" id="FFV-uA-HHA">
<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="260"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="AV7-t1-eK0">
<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="260"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="COSMOTE Επιβράβευση" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Z0E-V6-vKD">
<rect key="frame" x="20" y="30" width="374" height="0.0"/>
<rect key="frame" x="20" y="30" width="374" height="21"/>
<fontDescription key="fontDescription" name="PFSquareSansPro-Medium" family="PF Square Sans Pro" pointSize="21"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="kge-nO-6ZA" userLabel="BadgesView">
<rect key="frame" x="0.0" y="44" width="414" height="0.0"/>
<rect key="frame" x="0.0" y="65" width="414" height="195"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="wallet_badge_lines" translatesAutoresizingMaskIntoConstraints="NO" id="Cib-tj-hT7">
<rect key="frame" x="7" y="50" width="400" height="80"/>
......@@ -2429,19 +2429,19 @@
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Qge-34-vJ3">
<rect key="frame" x="169.5" y="120" width="75" height="73"/>
<rect key="frame" x="169.5" y="120" width="75" height="75"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="wallet_dfy_earn" translatesAutoresizingMaskIntoConstraints="NO" id="gGn-2u-akB">
<rect key="frame" x="0.0" y="0.0" width="75" height="73"/>
<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="0,00€" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="8JV-5a-Jar">
<rect key="frame" x="5" y="44" width="65" height="11"/>
<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"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="6UC-iU-ey4">
<rect key="frame" x="0.0" y="0.0" width="75" height="73"/>
<rect key="frame" x="0.0" y="0.0" width="75" height="75"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="Button">
......@@ -2562,7 +2562,7 @@
</connections>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" reuseIdentifier="WalletBannersTableViewCellId" id="fgI-zL-RPZ" customClass="WalletBannersTableViewCell" customModule="SwiftWarplyFramework">
<rect key="frame" x="0.0" y="991.5" width="414" height="404"/>
<rect key="frame" x="0.0" y="1207.5" width="414" height="404"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="fgI-zL-RPZ" id="gNB-PU-R1J">
<rect key="frame" x="0.0" y="0.0" width="414" height="404"/>
......
......@@ -55,7 +55,7 @@ import AVFoundation
couponImageHeight.constant = 255 //230 // 253 // self.uiscreen.height * 0.25
nameLabel.text = "Εκπτωτικό κουπόνι COSMOTE SuperMarket Deals!"
discriptionLabel.text = "Χρησιμοποίησε τον παρακάτω κωδικό και πάρε έκπτωση στα ενεργά κουπόνια προσφορών."
// discriptionLabel.text = "Χρησιμοποίησε τον παρακάτω κωδικό και πάρε έκπτωση στα ενεργά κουπόνια προσφορών."
merchantDescrTextView.text = ""
merchantDescrTextViewTopSpace.constant = CGFloat(0)
......@@ -126,6 +126,26 @@ import AVFoundation
couponNumberLabel.text = coupon?._barcode ?? ""
couponView.frame = CGRect(x: 0.0, y: 0.0, width: couponView.intrinsicContentSize.width, height: 55)
let activeCoupons = coupon?._coupons.filter { $0.status == 1 }
let activeCouponsDiscount = (activeCoupons?.reduce(0) { $0 + (Float($1.discount ?? "0") ?? 0) }) ?? 0
// discriptionLabel.text = "Χρησιμοποίησε τον παρακάτω κωδικό και πάρε έκπτωση στα ενεργά κουπόνια προσφορών αξίας " + String(activeCouponsDiscount) + "€."
// ========
let discrNormalText1 = "Χρησιμοποίησε τον παρακάτω κωδικό και πάρε έκπτωση στα ενεργά κουπόνια προσφορών αξίας "
let discrBoldText = String(activeCouponsDiscount) + "€."
let attrRegular = [NSAttributedString.Key.font : UIFont(name: "PeridotPE-Regular", size: 16) ?? UIFont.systemFont(ofSize: 15), NSAttributedString.Key.foregroundColor: UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)]
let attrBold = [NSAttributedString.Key.font : UIFont(name: "PeridotPE-Bold", size: 16) ?? UIFont.boldSystemFont(ofSize: 15), NSAttributedString.Key.foregroundColor: UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)]
let sumAttributedString = NSMutableAttributedString(string:discrNormalText1, attributes:attrRegular)
let sumBoldString = NSMutableAttributedString(string: discrBoldText, attributes:attrBold)
sumAttributedString.append(sumBoldString)
discriptionLabel.attributedText = sumAttributedString
// ========
// let barcodeString = constructBarcode(coupon: coupon) ?? ""
let barcodeString = coupon?._barcode ?? ""
barcodeLabel.text = barcodeString
......
......@@ -51,6 +51,7 @@ import UIKit
func configureCell(coupon: swiftApi.UnifiedCouponModel) {
let activeCoupons = coupon._coupons.filter { $0.status == 1 }
let activeCouponsCount = activeCoupons.count
let activeCouponsDiscount = activeCoupons.reduce(0) { $0 + (Float($1.discount ?? "0") ?? 0) }
// var activeCouponsCount:Int = 0
// for coupon in coupon._coupons {
......@@ -62,8 +63,11 @@ import UIKit
nameLabel.text = "COSMOTE SuperMarket Deals"
discriptionLabel.text =
activeCouponsCount == 1 ? "έχεις " + String(activeCouponsCount) + " ενεργό κουπόνι"
: "έχεις " + String(activeCouponsCount) + " ενεργά κουπόνια"
"έχεις " + String(activeCouponsCount) +
(
activeCouponsCount == 1 ? " ενεργό κουπόνι" : " ενεργά κουπόνια"
)
+ " αξίας " + String(activeCouponsDiscount) + "€"
if let earliestExpiration = activeCoupons.min(by: { ($0.expiration ?? "") < ($1.expiration ?? "") }) {
expirationLabel.text = "Ισχύει έως " + (earliestExpiration.expiration ?? "")
......