Manos Chorianopoulos

add multiple dfyactiveCodes UI at WalletVC

......@@ -7,7 +7,7 @@
<key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
</dict>
</dict>
......
......@@ -7,7 +7,7 @@
<key>SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>0</integer>
</dict>
</dict>
</dict>
......
......@@ -615,19 +615,19 @@
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="2" translatesAutoresizingMaskIntoConstraints="NO" id="MCY-xv-vpg">
<rect key="frame" x="20" y="20" width="254" height="60.5"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="Ενεργός κωδικός:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ucC-u4-AQL">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Ενεργός κωδικός:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ucC-u4-AQL">
<rect key="frame" x="0.0" y="0.0" width="254" height="21.5"/>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="18"/>
<color key="textColor" red="0.23529411759999999" green="0.32549019610000002" blue="0.39607843139999999" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="961544809" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qBe-Jw-QUx">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="961544809" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qBe-Jw-QUx">
<rect key="frame" x="0.0" y="23.5" width="254" height="21.5"/>
<fontDescription key="fontDescription" type="system" weight="heavy" pointSize="18"/>
<color key="textColor" red="0.23529411759999999" green="0.32549019610000002" blue="0.39607843139999999" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="Λήγει σε 4 ημέρες" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qL0-3b-eqA">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Λήγει σε 4 ημέρες" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qL0-3b-eqA">
<rect key="frame" x="0.0" y="47" width="254" height="13.5"/>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="11"/>
<color key="textColor" red="0.2274509804" green="0.32156862749999998" blue="0.40000000000000002" alpha="1" colorSpace="calibratedRGB"/>
......@@ -819,6 +819,7 @@
<outlet property="activeCodeLabel" destination="qBe-Jw-QUx" id="mlj-zT-T0Z"/>
<outlet property="activeCodeView" destination="zFT-By-XHL" id="M0w-Ln-iC9"/>
<outlet property="activeCodeViewHeight" destination="7r0-fu-7H9" id="nDr-bk-ViP"/>
<outlet property="activeCodesCountLabel" destination="ucC-u4-AQL" id="BCn-Ul-WqA"/>
<outlet property="couponEarnAmountLabel" destination="cbA-fm-1uO" id="o0w-tT-Etg"/>
<outlet property="couponEarnImage" destination="Vfg-nm-Igo" id="iLu-eS-mW3"/>
<outlet property="couponEarnLabel" destination="WdW-lP-g1v" id="GeT-9O-3ZD"/>
......
......@@ -27,6 +27,7 @@ import SwiftEventBus
@IBOutlet weak var dfyLogoImageHeight: NSLayoutConstraint!
@IBOutlet weak var activeCodeView: UIView!
@IBOutlet weak var activeCodeViewHeight: NSLayoutConstraint!
@IBOutlet weak var activeCodesCountLabel: UILabel!
@IBOutlet weak var activeCodeLabel: UILabel!
@IBOutlet weak var activeCodeExpirationLabel: UILabel!
@IBOutlet weak var tableView: UITableView!
......@@ -65,7 +66,7 @@ import SwiftEventBus
}
let userTag = swiftApi().getUserTag()
if (userTag != "") {
if (userTag != "" && userTag != "undefined") {
questionnaireButton.setTitle(userTag, for: .normal)
questionnaireButton.titleLabel?.font = UIFont.systemFont(ofSize: 13, weight: .semibold)
questionnaireButton.setTitleColor(.white, for: .normal)
......@@ -122,35 +123,59 @@ import SwiftEventBus
activeCodeView.layer.shadowRadius = 6.0
if (dfyCoupons.count > 0) {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd hh:mm:ss"
// sort dfyCoupons by date
dfyCoupons.sort(by: {
let date1 = dateFormatter.date(from: $0._date)
let date2 = dateFormatter.date(from: $1._date)
if (dfyCoupons.count == 1) {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd hh:mm:ss"
// sort dfyCoupons by date
dfyCoupons.sort(by: {
let date1 = dateFormatter.date(from: $0._date)
let date2 = dateFormatter.date(from: $1._date)
if ((date1 != nil) && (date2 != nil)) {
return date1!.compare(date2!) == .orderedAscending
} else {
return false
}
})
// Get days from now of the most recet coupon
var daysFromNow = ""
let calendar = Calendar.current
// Replace the hour (time) of both dates with 00:00
let date1 = calendar.startOfDay(for: Date())
if let date2 = dateFormatter.date(from: dfyCoupons[0]._date) {
let components = calendar.dateComponents([.day], from: date1, to: date2)
daysFromNow = (components.day) != nil ? String(components.day ?? 0) : ""
}
if ((date1 != nil) && (date2 != nil)) {
return date1!.compare(date2!) == .orderedAscending
activeCodesCountLabel.text = "Ενεργός κωδικός:"
activeCodeLabel.text = dfyCoupons[0]._code
// TODO: UNHIDE IT
activeCodeExpirationLabel.isHidden = true
if (daysFromNow == "1") {
activeCodeExpirationLabel.text = "Λήγει σε " + daysFromNow + " ημέρα"
} else {
return false
activeCodeExpirationLabel.text = "Λήγει σε " + daysFromNow + " ημέρες"
}
})
// Get days from now of the most recet coupon
var daysFromNow = ""
let calendar = Calendar.current
// Replace the hour (time) of both dates with 00:00
let date1 = calendar.startOfDay(for: Date())
if let date2 = dateFormatter.date(from: dfyCoupons[0]._date) {
let components = calendar.dateComponents([.day], from: date1, to: date2)
daysFromNow = (components.day) != nil ? String(components.day ?? 0) : ""
} else {
var couponCodesString = ""
for (index, item) in dfyCoupons.enumerated() {
if (index == (dfyCoupons.endIndex - 1)) {
couponCodesString += String(item._code)
} else {
couponCodesString += String(item._code) + ", "
}
}
activeCodesCountLabel.text = String(dfyCoupons.count) + " Ενεργοί κωδικοί:"
activeCodeLabel.text = couponCodesString
activeCodeExpirationLabel.isHidden = true
}
activeCodeLabel.text = dfyCoupons[0]._code
activeCodeExpirationLabel.text = "Λήγει σε " + daysFromNow + " ημέρες"
} else {
activeCodeLabel.text = "-"
activeCodeExpirationLabel.text = ""
......@@ -169,7 +194,7 @@ import SwiftEventBus
let userTag = swiftApi().getUserTag()
if (questionnaireButton.currentTitle != userTag) {
if (userTag != "") {
if (userTag != "" && userTag != "undefined") {
questionnaireButton.setTitle(userTag, for: .normal)
questionnaireButton.titleLabel?.font = UIFont.systemFont(ofSize: 13, weight: .semibold)
questionnaireButton.setTitleColor(.white, for: .normal)
......