Manos Chorianopoulos

add spinner at WalletVC

......@@ -2274,23 +2274,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="883" width="414" height="64.5"/>
<rect key="frame" x="0.0" y="883" width="414" height="44"/>
<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="64.5"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="WW2-mP-ZJD">
<rect key="frame" x="10" y="0.0" width="394" height="64.5"/>
<rect key="frame" x="10" y="0.0" width="394" height="44"/>
<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="64.5"/>
<rect key="frame" x="0.0" y="0.0" width="394" height="44"/>
</imageView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="87q-5c-uea">
<rect key="frame" x="20" y="10" width="79" height="44.5"/>
<rect key="frame" x="20" y="10" width="79" height="24"/>
<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="8.5"/>
<rect key="frame" x="18" y="18" width="43" height="0.0"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</imageView>
</subviews>
......@@ -2303,7 +2303,7 @@
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="u97-5H-Y40">
<rect key="frame" x="104" y="10" width="10" height="44.5"/>
<rect key="frame" x="104" y="10" width="10" height="24"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" constant="10" id="Tcx-FG-KC0"/>
......@@ -2316,13 +2316,13 @@
<nil key="highlightedColor"/>
</label>
<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"/>
<rect key="frame" x="292.5" y="14.5" 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"/>
<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="34.5" width="255" height="15"/>
<rect key="frame" x="119" y="14" width="255" 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"/>
<nil key="highlightedColor"/>
......@@ -2372,7 +2372,7 @@
</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="260"/>
<rect key="frame" x="0.0" y="927" 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="260"/>
......@@ -2599,7 +2599,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="1207.5" width="414" height="404"/>
<rect key="frame" x="0.0" y="1187" 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"/>
......@@ -2967,7 +2967,7 @@
</connections>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" reuseIdentifier="WalletActiveCouponsTableViewCellId" id="qaY-Zw-d8E" customClass="WalletActiveCouponsTableViewCell" customModule="SwiftWarplyFramework">
<rect key="frame" x="0.0" y="1611.5" width="414" height="98"/>
<rect key="frame" x="0.0" y="1015" width="414" height="98"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="qaY-Zw-d8E" id="MoF-lG-k6u">
<rect key="frame" x="0.0" y="0.0" width="414" height="98"/>
......@@ -3250,7 +3250,7 @@
</connections>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" reuseIdentifier="WalletVouchersBannerTableViewCellId" id="F1i-u5-1v2" customClass="WalletVouchersBannerTableViewCell" customModule="SwiftWarplyFramework">
<rect key="frame" x="0.0" y="1709.5" width="414" height="181"/>
<rect key="frame" x="0.0" y="1689" width="414" height="181"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="F1i-u5-1v2" id="q9T-Eg-Gxw">
<rect key="frame" x="0.0" y="0.0" width="414" height="181"/>
......@@ -3334,12 +3334,54 @@
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<connections>
<outlet property="sectionTitleLabel" destination="0yZ-ge-5qY" id="zsT-WW-anR"/>
<outlet property="separatorTopSpace" destination="iGG-ot-2k8" id="nZT-4o-Yuq"/>
<outlet property="separatorView" destination="zKi-zm-jUP" id="Toh-Ph-9np"/>
<outlet property="voucherBannerArrowImage" destination="cSu-mM-1Ep" id="hDY-vI-sfK"/>
<outlet property="voucherBannerIconImage" destination="U9f-Ar-TCE" id="cy8-jG-sg7"/>
<outlet property="voucherBannerLabel" destination="2p1-v2-lAL" id="Wlm-z2-nrW"/>
<outlet property="voucherBannerView" destination="eBr-vb-7oH" id="RU1-Lx-048"/>
</connections>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" reuseIdentifier="WalletSpinnerTableViewCellId" id="ShU-xo-DhW" customClass="WalletSpinnerTableViewCell" customModule="SwiftWarplyFramework">
<rect key="frame" x="0.0" y="1870" width="414" height="98"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="ShU-xo-DhW" id="U4r-xF-gbA">
<rect key="frame" x="0.0" y="0.0" width="414" height="98"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="hm4-ma-8T7" userLabel="ParentView">
<rect key="frame" x="0.0" y="0.0" width="414" height="98"/>
<subviews>
<activityIndicatorView opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" ambiguous="YES" style="large" translatesAutoresizingMaskIntoConstraints="NO" id="Kes-eE-1K8">
<rect key="frame" x="183" y="30" width="48" height="48"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="48" id="MxX-gd-WB6"/>
<constraint firstAttribute="width" constant="48" id="kjs-ti-uR8"/>
</constraints>
</activityIndicatorView>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="Kes-eE-1K8" firstAttribute="centerX" secondItem="hm4-ma-8T7" secondAttribute="centerX" id="Zem-vK-XXa"/>
<constraint firstAttribute="bottom" secondItem="Kes-eE-1K8" secondAttribute="bottom" constant="20" id="dBw-Vl-a7k"/>
<constraint firstItem="Kes-eE-1K8" firstAttribute="top" secondItem="hm4-ma-8T7" secondAttribute="top" constant="20" id="o0b-VF-Kdo"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="hm4-ma-8T7" secondAttribute="bottom" id="8Iu-l7-LLN"/>
<constraint firstItem="hm4-ma-8T7" firstAttribute="leading" secondItem="U4r-xF-gbA" secondAttribute="leading" id="98d-58-43v"/>
<constraint firstItem="hm4-ma-8T7" firstAttribute="top" secondItem="U4r-xF-gbA" secondAttribute="top" id="aQR-NQ-sYL"/>
<constraint firstAttribute="trailing" secondItem="hm4-ma-8T7" secondAttribute="trailing" id="w6m-EM-giU"/>
</constraints>
</tableViewCellContentView>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<connections>
<outlet property="spinner" destination="Kes-eE-1K8" id="SP3-Mn-lgc"/>
</connections>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="pKQ-52-a1r" id="AvY-tV-KMr"/>
......
......@@ -8,10 +8,16 @@
import UIKit
@objc public class WalletSpinnerTableViewCell: UITableViewCell {
@IBOutlet weak var spinner: UIActivityIndicatorView!
public override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
spinner.color = UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00)
spinner.translatesAutoresizingMaskIntoConstraints = false
spinner.startAnimating()
}
public override func setSelected(_ selected: Bool, animated: Bool) {
......@@ -19,5 +25,12 @@ import UIKit
// Configure the view for the selected state
}
// This is a fix for spinner stopping its animation when reusing cells
public override func prepareForReuse() {
super.prepareForReuse()
if let spinner = self.spinner {
spinner.startAnimating()
}
}
}
......
......@@ -78,6 +78,8 @@ import SwiftEventBus
var unifiedCouponsDiscount:Float = 0.0
var forYouExpanded: Bool = false;
var showSpinner: Bool = false;
var showActiveCouponsBanners: Bool = false;
public override func viewDidLoad() {
......@@ -100,8 +102,10 @@ import SwiftEventBus
DispatchQueue.main.async {
self.unifiedCoupons = swiftApi().getUnifiedCouponList()
// TODO: Maybe add this
self.matchOldSMCoupons()
self.updateMarketBadge()
// TODO: Uncomment if discounts are shown again in wallet
// self.matchOldSMCoupons()
// self.updateMarketBadge()
self.handleSpinnerAndEmptyView()
self.tableView.reloadData()
}
}
......@@ -111,13 +115,9 @@ import SwiftEventBus
DispatchQueue.main.async {
print("=== vouchers_fetched event ===")
// TODO: hide Spinner
if (swiftApi().getShowVouchersBanner() == "true") {
// TODO: show Vouchers Banner
} else {
// TODO: hide Vouchers Banner
}
self.handleSpinnerAndEmptyView()
// self.showSpinner = false
self.tableView.reloadData()
}
}
......@@ -481,21 +481,15 @@ import SwiftEventBus
emptyImage.image = UIImage(named: "ic_empty_wallet_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
emptyLabel.text = "Δεν έχεις κάποιον ενεργό κωδικό ή κουπόνι! Μπες τώρα στην ενότητα COSMOTE For You και βρες αποκλειστικές προσφορές!"
matchOldSMCoupons()
updateMarketBadge()
// TODO: Uncomment if discounts are shown again in wallet
// matchOldSMCoupons()
// updateMarketBadge()
// TODO: DELETE if emptyView is needed again
emptyView.isHidden = true
emptyViewHeight.constant = 0
// emptyView.isHidden = true
// emptyViewHeight.constant = 0
if (swiftApi().getShowVouchersBanner() == "") {
// TODO: show Spinner
// TODO: hide Vouchers Banner
} else if (swiftApi().getShowVouchersBanner() == "true") {
// TODO: show Vouchers Banner
} else {
// TODO: hide Vouchers Banner
}
self.handleSpinnerAndEmptyView()
}
......@@ -554,7 +548,9 @@ import SwiftEventBus
// TODO: Maybe add this
// self.matchOldSMCoupons()
// <===
self.updateMarketBadge()
// TODO: Uncomment if discounts are shown again in wallet
// self.updateMarketBadge()
self.handleSpinnerAndEmptyView()
self.tableView.reloadData()
self.startTimer()
......@@ -705,6 +701,40 @@ import SwiftEventBus
}
func handleSpinnerAndEmptyView() {
if (swiftApi().getShowVouchersBanner() == "") {
self.showSpinner = true
if (self.dfyCoupons.count == 0 && self.unifiedCoupons.count == 0 && self.coupons.count == 0) {
self.showSpinner = false
self.showActiveCouponsBanners = false
self.emptyView.isHidden = false
self.emptyViewHeight.constant = self.emptyView.intrinsicContentSize.height
} else {
self.emptyView.isHidden = true
self.emptyViewHeight.constant = 0
self.showActiveCouponsBanners = true
}
} else {
self.emptyView.isHidden = true
self.emptyViewHeight.constant = 0
self.showSpinner = false
if (self.dfyCoupons.count == 0 && self.unifiedCoupons.count == 0 && self.coupons.count == 0) {
self.showActiveCouponsBanners = false
} else {
self.showActiveCouponsBanners = true
}
}
}
// MARK: - API Functions
func getCouponsSetsDealsRequest() {
swiftApi().getCouponSetsDealsAsync(getCouponsSetsDealsCallback, failureCallback: {errorCode in
......@@ -734,6 +764,7 @@ import SwiftEventBus
DispatchQueue.main.async {
self.matchOldSMCoupons()
self.updateMarketBadge()
self.handleSpinnerAndEmptyView()
self.tableView.reloadData()
}
} else {
......@@ -957,7 +988,7 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{
public func numberOfSections(in tableView: UITableView) -> Int {
// return 4
return 2
return 3
}
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
......@@ -994,6 +1025,12 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{
} else {
return 0
}
} else if (section == 2) {
if (self.showSpinner == true) {
return 1
} else {
return 0
}
} else {
return 0
}
......@@ -1042,6 +1079,12 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{
} else {
return 0.0
}
} else if (indexPath.section == 2) {
if (self.showSpinner == true) {
return UITableView.automaticDimension
} else {
return 0.0
}
} else {
return 0.0
}
......@@ -1141,6 +1184,8 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{
// } else {
return nil
// }
} else if (section == 2) {
return nil
} else {
return nil
}
......@@ -1187,6 +1232,8 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{
// } else {
return 0.0
// }
} else if (section == 2) {
return 0.0
} else {
return 0.0
}
......@@ -1232,12 +1279,15 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{
cell.configureCell(dfyCount: self.dfyCoupons.count, smCount: self.unifiedCoupons.count, gfyCount: self.coupons.count)
return cell
} else {
} else if (indexPath.section == 1) {
let cell = tableView.dequeueReusableCell(withIdentifier: "WalletVouchersBannerTableViewCellId", for: indexPath) as! WalletVouchersBannerTableViewCell
// cell.configureCell(totalCouponValue: self.totalCouponValue, totalCouponDiscount: self.totalCouponDiscount, unifiedCouponsDiscount: self.unifiedCouponsDiscount, forYouExpanded: self.forYouExpanded)
cell.configureCell(showSeparator: self.showActiveCouponsBanners)
return cell
} else {
let cell = tableView.dequeueReusableCell(withIdentifier: "WalletSpinnerTableViewCellId", for: indexPath) as! WalletSpinnerTableViewCell
return cell
}
}
public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
......@@ -1292,6 +1342,8 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{
SwiftEventBus.post("vouchers_banner_pressed")
} else if (indexPath.section == 2) {
// Do nothing
} else {
// Do nothing
}
......
......@@ -8,6 +8,8 @@
import UIKit
@objc public class WalletVouchersBannerTableViewCell: UITableViewCell {
@IBOutlet weak var separatorView: UIView!
@IBOutlet weak var separatorTopSpace: NSLayoutConstraint!
@IBOutlet weak var sectionTitleLabel: UILabel!
@IBOutlet weak var voucherBannerView: UIView!
@IBOutlet weak var voucherBannerIconImage: UIImageView!
......@@ -41,5 +43,16 @@ import UIKit
// Configure the view for the selected state
}
func configureCell(showSeparator: Bool) {
if (showSeparator == true) {
separatorView.isHidden = false
separatorTopSpace.constant = 25
} else {
separatorView.isHidden = true
separatorTopSpace.constant = 0
}
}
}
......