Manos Chorianopoulos

Add Maket History

......@@ -7,7 +7,7 @@
<key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>0</integer>
</dict>
</dict>
</dict>
......
......@@ -14,6 +14,8 @@
1E108A9628A3F9280008B8E7 /* pf_square_sans_pro_bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1E108A9128A3F9280008B8E7 /* pf_square_sans_pro_bold.ttf */; };
1E151F1829DAE48500951FA0 /* UnifiedCouponsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E151F1729DAE48500951FA0 /* UnifiedCouponsTableViewCell.swift */; };
1E151F1A29DAE4D500951FA0 /* ActiveCodeTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E151F1929DAE4D500951FA0 /* ActiveCodeTableViewCell.swift */; };
1E15B9A229DDCF02000A408D /* MarketSharingHistoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E15B9A129DDCF02000A408D /* MarketSharingHistoryViewController.swift */; };
1E15B9A429DDD211000A408D /* MarketHistoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E15B9A329DDD211000A408D /* MarketHistoryViewController.swift */; };
1E2966EA2837A21D00F83FAC /* RSBarcodes_Swift in Frameworks */ = {isa = PBXBuildFile; productRef = 1E2966E92837A21D00F83FAC /* RSBarcodes_Swift */; };
1E4410B128F5855000859F92 /* CampaignCategory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E4410B028F5855000859F92 /* CampaignCategory.swift */; };
1E479FB329DD948B00C38193 /* WalletBadgesTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E479FB229DD948B00C38193 /* WalletBadgesTableViewCell.swift */; };
......@@ -22,6 +24,7 @@
1EA1AF0A2835346A008998AA /* CouponsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */; };
1EA2BB792865BFE8003F2AB0 /* InboxTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA2BB782865BFE8003F2AB0 /* InboxTableViewCell.swift */; };
1EA771AC290977CA0030924C /* CopyableLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA771AB290977CA0030924C /* CopyableLabel.swift */; };
1EAEFC7A29DDCAF500114A1C /* MarketLoyaltyAnalysisViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EAEFC7929DDCAF500114A1C /* MarketLoyaltyAnalysisViewController.swift */; };
1EB236AB28816B680063777A /* ShareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EB236AA28816B680063777A /* ShareViewController.swift */; };
1EB236AD28816C560063777A /* NumberPopupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EB236AC28816C560063777A /* NumberPopupViewController.swift */; };
1EB236AF28816CAC0063777A /* NumbersTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EB236AE28816CAB0063777A /* NumbersTableViewCell.swift */; };
......@@ -182,6 +185,8 @@
1E108A9728A3FA9B0008B8E7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
1E151F1729DAE48500951FA0 /* UnifiedCouponsTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnifiedCouponsTableViewCell.swift; sourceTree = "<group>"; };
1E151F1929DAE4D500951FA0 /* ActiveCodeTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActiveCodeTableViewCell.swift; sourceTree = "<group>"; };
1E15B9A129DDCF02000A408D /* MarketSharingHistoryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarketSharingHistoryViewController.swift; sourceTree = "<group>"; };
1E15B9A329DDD211000A408D /* MarketHistoryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarketHistoryViewController.swift; sourceTree = "<group>"; };
1E4410B028F5855000859F92 /* CampaignCategory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CampaignCategory.swift; sourceTree = "<group>"; };
1E479FB229DD948B00C38193 /* WalletBadgesTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletBadgesTableViewCell.swift; sourceTree = "<group>"; };
1E74838C28378AF40042A589 /* CouponBarcodeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponBarcodeViewController.swift; sourceTree = "<group>"; };
......@@ -189,6 +194,7 @@
1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponsTableViewCell.swift; sourceTree = "<group>"; };
1EA2BB782865BFE8003F2AB0 /* InboxTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InboxTableViewCell.swift; sourceTree = "<group>"; };
1EA771AB290977CA0030924C /* CopyableLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CopyableLabel.swift; sourceTree = "<group>"; };
1EAEFC7929DDCAF500114A1C /* MarketLoyaltyAnalysisViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarketLoyaltyAnalysisViewController.swift; sourceTree = "<group>"; };
1EB236AA28816B680063777A /* ShareViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareViewController.swift; sourceTree = "<group>"; };
1EB236AC28816C560063777A /* NumberPopupViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumberPopupViewController.swift; sourceTree = "<group>"; };
1EB236AE28816CAB0063777A /* NumbersTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumbersTableViewCell.swift; sourceTree = "<group>"; };
......@@ -452,6 +458,7 @@
E6A77850282933340045BBA8 /* SwiftWarplyFramework */ = {
isa = PBXGroup;
children = (
1E15B9A329DDD211000A408D /* MarketHistoryViewController.swift */,
1EBC75422922829D004FBE75 /* SpinnerViewController.swift */,
1ECA079028D9E3BA00D2BDE0 /* CSMButton.swift */,
1E108A9728A3FA9B0008B8E7 /* Info.plist */,
......@@ -477,6 +484,8 @@
E6A77A35282BB4CB0045BBA8 /* MakeItAPresentViewController.swift */,
E6A7785A282933E40045BBA8 /* Helpers */,
E6A77861282933E50045BBA8 /* Main.storyboard */,
1E15B9A129DDCF02000A408D /* MarketSharingHistoryViewController.swift */,
1EAEFC7929DDCAF500114A1C /* MarketLoyaltyAnalysisViewController.swift */,
1E479FB229DD948B00C38193 /* WalletBadgesTableViewCell.swift */,
1EA771AB290977CA0030924C /* CopyableLabel.swift */,
1E4410B028F5855000859F92 /* CampaignCategory.swift */,
......@@ -917,6 +926,7 @@
E6A7793E282933E70045BBA8 /* AFHTTPSessionManager.m in Sources */,
E6A77933282933E70045BBA8 /* UIButton+AFNetworking.m in Sources */,
E6A77919282933E60045BBA8 /* Warply.m in Sources */,
1E15B9A429DDD211000A408D /* MarketHistoryViewController.swift in Sources */,
E6A77953282933E70045BBA8 /* MFYViewController.swift in Sources */,
E6A7794B282933E70045BBA8 /* FMDatabase.m in Sources */,
E6A778EC282933E60045BBA8 /* WLNativeVideoTableViewCell.m in Sources */,
......@@ -933,6 +943,7 @@
E6A77925282933E70045BBA8 /* UIProgressView+AFNetworking.m in Sources */,
E6A77944282933E70045BBA8 /* AFSecurityPolicy.m in Sources */,
1EA1AF0A2835346A008998AA /* CouponsTableViewCell.swift in Sources */,
1EAEFC7A29DDCAF500114A1C /* MarketLoyaltyAnalysisViewController.swift in Sources */,
E6A77A32282BA9C60045BBA8 /* CampaignViewController.swift in Sources */,
E6A77917282933E60045BBA8 /* UIViewController+WLAdditions.m in Sources */,
1EA2BB792865BFE8003F2AB0 /* InboxTableViewCell.swift in Sources */,
......@@ -967,6 +978,7 @@
1ECA079128D9E3BA00D2BDE0 /* CSMButton.swift in Sources */,
1E4410B128F5855000859F92 /* CampaignCategory.swift in Sources */,
E6A7790B282933E60045BBA8 /* WLPushManager.m in Sources */,
1E15B9A229DDCF02000A408D /* MarketSharingHistoryViewController.swift in Sources */,
A079366E2885D07700064122 /* AnalysisChildViewController.swift in Sources */,
E6A77950282933E70045BBA8 /* FMResultSet.m in Sources */,
1E151F1A29DAE4D500951FA0 /* ActiveCodeTableViewCell.swift in Sources */,
......
......@@ -7,7 +7,7 @@
<key>SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
</dict>
</dict>
......
......@@ -22,7 +22,7 @@ class AnalysisHeaderMessageViewCell: UITableViewCell {
super.awakeFromNib()
// image
itemImage.image = UIImage(named: "ic_gift_circle_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
// itemImage.image = UIImage(named: "ic_gift_circle_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
// title
titleLabel.textColor = UIColor(rgb: 0x435563)
......@@ -64,7 +64,7 @@ class AnalysisHeaderMessageViewCell: UITableViewCell {
}
extension AnalysisHeaderMessageViewCell {
func configureCell(isEmpty: Bool) {
func configureCell(isEmpty: Bool, isMarket: Bool) {
if (isEmpty == true) {
emptyLabel.isHidden = false
......@@ -72,5 +72,11 @@ extension AnalysisHeaderMessageViewCell {
emptyLabel.isHidden = true
}
if (isMarket == true) {
itemImage.image = UIImage(named: "ic_history_market", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
} else {
itemImage.image = UIImage(named: "ic_gift_circle_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
}
}
}
......
......@@ -19,7 +19,7 @@ class AnalysisHeaderViewCell: UITableViewCell {
super.awakeFromNib()
// image
itemImage.image = UIImage(named: "ic_gift_circle_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
// itemImage.image = UIImage(named: "ic_gift_circle_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
// title
titleLabel.textColor = UIColor(rgb: 0x435563)
......@@ -28,7 +28,7 @@ class AnalysisHeaderViewCell: UITableViewCell {
}
extension AnalysisHeaderViewCell {
func configureCell(isEmpty: Bool) {
func configureCell(isEmpty: Bool, isMarket: Bool) {
if (isEmpty == true) {
emptyLabel.isHidden = false
......@@ -36,5 +36,11 @@ extension AnalysisHeaderViewCell {
emptyLabel.isHidden = true
}
if (isMarket == true) {
itemImage.image = UIImage(named: "ic_history_market", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
} else {
itemImage.image = UIImage(named: "ic_gift_circle_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
}
}
}
......
......@@ -118,7 +118,7 @@ class HistoryViewController: AnalysisChildViewController {
if (indexPath.section == 0) {
if (hasMessage) {
let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisHeaderMessageViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisHeaderMessageViewCell
cell.configureCell(isEmpty: items.count == 0)
cell.configureCell(isEmpty: items.count == 0, isMarket: false)
return cell
}
......
This diff could not be displayed because it is too large.
//
// MarketHistoryViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 5/4/23.
//
import UIKit
class MarketHistoryViewController: AnalysisChildViewController {
var loading: Bool = false
var items: Array<swiftApi.CouponItemModel> = swiftApi().getOldCouponList()
var showMore = false
// TODO: remove this when configuring model
let hasMessage = true
// lifecycle
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.delegate = self
self.tableView.dataSource = self
self.refreshControl = UIRefreshControl()
self.refreshControl?.addTarget(self, action: #selector(handleRefresh(_:)), for: .valueChanged)
handleRefresh(self.refreshControl!)
}
// mvp
@objc func load() {
if (loading) {
return;
}
showLoading()
items = swiftApi().getOldCouponList()
self.showMore = (self.items.count > 3)
if (self.showMore == true) {
self.items = Array(self.items[0...2])
}
showContent()
self.tableView.reloadData()
}
private func showLoading() {
loading = true
if (self.refreshControl!.isRefreshing) {
return;
}
self.refreshControl!.beginRefreshing()
}
private func showError() {
}
private func showContent() {
loading = false
self.refreshControl!.endRefreshing()
}
// private
func responseCallback (_ data: Array<swiftApi.CouponItemModel>?) -> Void {
self.items = data!
self.showMore = (self.items.count > 3)
if (self.showMore == true) {
self.items = Array(self.items[0...2])
}
showContent()
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
@objc func handleRefresh(_ refreshControl: UIRefreshControl) {
self.perform(_: #selector(load), with: nil, afterDelay: 0.5)
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
return 2
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if (section == 0) {
return 1
}
if (self.showMore == true) {
return 4
}
return items.count
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if (indexPath.section == 0) {
return hasMessage ? (items.count > 0 ? 380.0 : 480.0) : 280
}
return 140.0
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// header
if (indexPath.section == 0) {
if (hasMessage) {
let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisHeaderMessageViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisHeaderMessageViewCell
cell.configureCell(isEmpty: items.count == 0, isMarket: true)
return cell
}
return tableView.dequeueReusableCell(withIdentifier: "AnalysisHeaderViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisHeaderViewCell
}
if (self.showMore && indexPath.row == 3) {
let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisMoreViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisMoreViewCell
return cell
}
let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisItemViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisItemViewCell
cell.configureCell(item: items[indexPath.row])
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if (indexPath.section == 0) {
return
}
if (self.showMore && indexPath.row == 3) {
self.items = swiftApi().getOldCouponList()
self.showMore = false
self.tableView.reloadData()
}
}
}
//
// MarketLoyaltyAnalysisViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 5/4/23.
//
import UIKit
import SwiftEventBus
@objc public class MarketLoyaltyAnalysisViewController: UIViewController {
@IBOutlet weak var leftButton: UIButton!
@IBOutlet weak var rightButton: UIButton!
@IBOutlet weak var leftLineView: UIView!
@IBOutlet weak var rightLineView: UIView!
@IBOutlet weak var contentView: UIView!
var pageController: UIPageViewController!
var tabSelected = 0
var timerHistory: DispatchSourceTimer?
var seconds: Int = 0
public override func viewDidLoad() {
super.viewDidLoad()
self.hidesBottomBarWhenPushed = true
// setup view
setBackButton()
setNavigationTitle("Ανάλυση")
// tab
leftButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Bold", size: 14)
leftButton.setTitle("Εξαργυρωμένα", for:.normal)
leftButton.backgroundColor = . clear
leftButton.setTitleColor(UIColor(rgb: 0x2EAFB9), for:.normal)
rightButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Regular", size: 14)
rightButton.setTitle("Μοιρασμένα δώρα", for:.normal)
rightButton.backgroundColor = . clear
rightButton.setTitleColor(UIColor(rgb: 0x394A5B), for:.normal)
leftLineView.applyGradient(colours: [UIColor(rgb: 0x1DA6B9), UIColor(rgb: 0xB2CE69)], gradient: GradientOrientation.horizontal, cornerRadius: 0.0)
rightLineView.applyGradient(colours: [UIColor(rgb: 0x1DA6B9), UIColor(rgb: 0xB2CE69)], gradient: GradientOrientation.horizontal, cornerRadius: 0.0)
leftLineView.isHidden = false
rightLineView.isHidden = true
// pages
pageController = UIPageViewController(transitionStyle:.scroll, navigationOrientation:.horizontal)
pageController.dataSource = self;
pageController.delegate = self;
pageController.view.frame = contentView.bounds;
addChild(pageController)
contentView.addSubview(pageController.view)
pageController .didMove(toParent: self)
let analysisVC = self.viewControllerAt(0)
pageController.setViewControllers([analysisVC!], direction:.forward, animated:false)
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
swiftApi().logTrackersEvent("screen", "LoyaltyHistoryScreen")
self.startTimer()
}
public override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
self.stopTimer()
}
// MARK: - Functions
func startTimer() {
print("========= GiftsCalculator Timer Started! =========")
let queue = DispatchQueue(label: Bundle.main.bundleIdentifier! + ".history.timer")
timerHistory = DispatchSource.makeTimerSource(queue: queue)
timerHistory!.schedule(deadline: .now(), repeating: .seconds(1))
timerHistory!.setEventHandler { [weak self] in
// do whatever stuff you want on the background queue here here
print("========= GiftsCalculator interval! =========")
DispatchQueue.main.async {
// update your model objects and/or UI here
self?.seconds = (self?.seconds ?? 0) + 1
}
}
timerHistory!.resume()
}
func stopTimer() {
print("========= GiftsCalculator Timer Stopped! =========")
timerHistory?.cancel()
timerHistory = nil
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "time_spent_on_loyalty_sdk"
firebaseEvent.setParameter = ("name", "GiftsCalculator")
firebaseEvent.setParameter = ("seconds", String(seconds))
SwiftEventBus.post("firebase", sender: firebaseEvent)
seconds = 0
}
////////////////////////////////////////////////////////////////////////////////
private func viewControllerAt(_ index:Int) -> AnalysisChildViewController?
{
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
if (index == 1) {
swiftApi().logTrackersEvent("click", ("LoyaltyHistoryScreen:" + "TabShared"))
let analysisVC = storyboard.instantiateViewController(withIdentifier:"SharingHistoryViewController") as! SwiftWarplyFramework.SharingHistoryViewController
analysisVC.index = index;
return analysisVC;
}
swiftApi().logTrackersEvent("click", ("LoyaltyHistoryScreen:" + "TabExpired"))
let analysisVC = storyboard.instantiateViewController(withIdentifier:"HistoryViewController") as! SwiftWarplyFramework.HistoryViewController
analysisVC.index = index;
return analysisVC;
}
// MARK: - Handlers
@IBAction func handleLeft() {
if (tabSelected != 0) {
self.tabSelected = 0
UIView.animate(withDuration: 2.0, delay: 0.0) {
self.leftLineView.isHidden = false
self.rightLineView.isHidden = true
self.leftButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Bold", size: 14)
self.rightButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Regular", size: 14)
self.leftButton.setTitleColor(UIColor(rgb: 0x2EAFB9), for:.normal)
self.rightButton.setTitleColor(UIColor(rgb: 0x394A5B), for:.normal)
}
let analysisVC = self.viewControllerAt(0)
pageController.setViewControllers([analysisVC!], direction:.reverse, animated:true)
}
}
@IBAction func handleRight() {
if (tabSelected != 1) {
self.tabSelected = 1
UIView.animate(withDuration: 2.0, delay: 0.0) {
self.leftLineView.isHidden = true
self.rightLineView.isHidden = false
self.leftButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Regular", size: 14)
self.rightButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Bold", size: 14)
self.rightButton.setTitleColor(UIColor(rgb: 0x2EAFB9), for:.normal)
self.leftButton.setTitleColor(UIColor(rgb: 0x394A5B), for:.normal)
}
let analysisVC = self.viewControllerAt(1)
pageController.setViewControllers([analysisVC!], direction:.forward, animated:true)
}
}
}
// MARK: - PageViewController
extension MarketLoyaltyAnalysisViewController: UIPageViewControllerDataSource, UIPageViewControllerDelegate {
public func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
if let analysisVC = viewController as? AnalysisChildViewController {
var index = analysisVC.index
if (index == 0) {
return nil;
}
index -= 1;
return viewControllerAt(index);
}
return nil;
}
public func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
if let analysisVC = viewController as? AnalysisChildViewController {
var index = analysisVC.index
if (index == 1) {
return nil;
}
index += 1;
return viewControllerAt(index);
}
return nil;
}
public func pageViewController(_ pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool) {
if (!completed) {
return;
}
if let childVCs = pageViewController.viewControllers as? [AnalysisChildViewController] {
let currentIndex = childVCs[0].index
if (currentIndex == 0) {
self.leftButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Bold", size: 14)
self.rightButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Regular", size: 14)
self.leftButton.setTitleColor(UIColor(rgb: 0x2EAFB9), for:.normal)
self.rightButton.setTitleColor(UIColor(rgb: 0x394A5B), for:.normal)
self.tabSelected = 0
self.leftLineView.isHidden = false
self.rightLineView.isHidden = true
} else {
self.leftButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Regular", size: 14)
self.rightButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Bold", size: 14)
self.rightButton.setTitleColor(UIColor(rgb: 0x2EAFB9), for:.normal)
self.leftButton.setTitleColor(UIColor(rgb: 0x394A5B), for:.normal)
self.tabSelected = 1
self.leftLineView.isHidden = true
self.rightLineView.isHidden = false
}
}
}
}
//
// MarketSharingHistoryViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 5/4/23.
//
import UIKit
class MarketSharingHistoryViewController: AnalysisChildViewController {
var loading: Bool = false
var items: Array<swiftApi.SharingCouponModel> = Array()
var allItems: Array<swiftApi.SharingCouponModel> = Array()
var showMore = false
// TODO: remove this when configuring model
let hasMessage = false
// lifecycle
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.delegate = self
self.tableView.dataSource = self
self.refreshControl = UIRefreshControl()
self.refreshControl?.addTarget(self, action: #selector(handleRefresh(_:)), for: .valueChanged)
handleRefresh(self.refreshControl!)
}
// mvp
@objc func load() {
if (loading) {
return;
}
showLoading()
swiftApi().getSharingHistoryAsync(responseCallback, failureCallback: {errorCode in })
}
private func showLoading() {
loading = true
if (self.refreshControl!.isRefreshing) {
return;
}
self.refreshControl!.beginRefreshing()
}
private func showError() {
}
private func showContent() {
loading = false
self.refreshControl!.endRefreshing()
}
// private
func responseCallback (_ data: Array<swiftApi.SharingCouponModel>?) -> Void {
self.items = data!
self.allItems = data!
self.showMore = (self.items.count > 3)
if (self.showMore == true) {
self.items = Array(self.items[0...2])
}
showContent()
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
@objc func handleRefresh(_ refreshControl: UIRefreshControl) {
self.perform(_: #selector(load), with: nil, afterDelay: 0.5)
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
return 2
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if (section == 0) {
return 1;
}
if (self.showMore == true) {
return 4
}
return items.count
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if (indexPath.section == 0) {
return hasMessage ? 380.0 : (items.count > 0 ? 280 : 380)
}
return 140.0
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// header
if (indexPath.section == 0) {
if (hasMessage) {
return tableView.dequeueReusableCell(withIdentifier: "AnalysisHeaderMessageViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisHeaderMessageViewCell
}
let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisHeaderViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisHeaderViewCell
cell.configureCell(isEmpty: items.count == 0, isMarket: true)
return cell
}
if ((self.showMore == true) && (indexPath.row == 3)) {
let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisMoreViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisMoreViewCell
return cell
}
let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisItemViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisItemViewCell
cell.configureCell(item: items[indexPath.row])
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if (indexPath.section == 0) {
return
}
if ((self.showMore == true) && (indexPath.row == 3)) {
self.items = self.allItems
self.showMore = false
self.tableView.reloadData()
}
}
}
......@@ -116,7 +116,7 @@ class SharingHistoryViewController: AnalysisChildViewController {
}
let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisHeaderViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisHeaderViewCell
cell.configureCell(isEmpty: items.count == 0)
cell.configureCell(isEmpty: items.count == 0, isMarket: false)
return cell
}
......