Manos Chorianopoulos

add more button at HistoryViewController

......@@ -28,6 +28,7 @@
1ECA079428D9E53F00D2BDE0 /* MapsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1ECA079228D9E53F00D2BDE0 /* MapsViewController.swift */; };
1ECA079528D9E53F00D2BDE0 /* MapsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1ECA079328D9E53F00D2BDE0 /* MapsViewController.xib */; };
1ECA079728D9E66200D2BDE0 /* MerchantAnnotation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1ECA079628D9E66200D2BDE0 /* MerchantAnnotation.swift */; };
1EDCDFAC28DB29E8002ED8F0 /* AnalysisMoreViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EDCDFAB28DB29E8002ED8F0 /* AnalysisMoreViewCell.swift */; };
7630AD9A6242D60846D6750C /* Pods_SwiftWarplyFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C0D5F56DD4E5371A50AD2D87 /* Pods_SwiftWarplyFramework.framework */; };
A02F34052882B6E60086465F /* TelcoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A02F34042882B6E60086465F /* TelcoViewController.swift */; };
A04D31DE288FF670000E43B5 /* HistoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A04D31DD288FF670000E43B5 /* HistoryViewController.swift */; };
......@@ -187,6 +188,7 @@
1ECA079228D9E53F00D2BDE0 /* MapsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapsViewController.swift; sourceTree = "<group>"; };
1ECA079328D9E53F00D2BDE0 /* MapsViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MapsViewController.xib; sourceTree = "<group>"; };
1ECA079628D9E66200D2BDE0 /* MerchantAnnotation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MerchantAnnotation.swift; sourceTree = "<group>"; };
1EDCDFAB28DB29E8002ED8F0 /* AnalysisMoreViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalysisMoreViewCell.swift; sourceTree = "<group>"; };
A02F34042882B6E60086465F /* TelcoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TelcoViewController.swift; sourceTree = "<group>"; };
A04D31DD288FF670000E43B5 /* HistoryViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HistoryViewController.swift; sourceTree = "<group>"; };
A079366D2885D07700064122 /* AnalysisChildViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalysisChildViewController.swift; sourceTree = "<group>"; };
......@@ -460,6 +462,7 @@
E6A77A35282BB4CB0045BBA8 /* MakeItAPresentViewController.swift */,
E6A7785A282933E40045BBA8 /* Helpers */,
E6A77861282933E50045BBA8 /* Main.storyboard */,
1EDCDFAB28DB29E8002ED8F0 /* AnalysisMoreViewCell.swift */,
1E87A9EE28C2021200C79F90 /* ContextualViewController.swift */,
1EB236AA28816B680063777A /* ShareViewController.swift */,
1EB236AC28816C560063777A /* NumberPopupViewController.swift */,
......@@ -958,6 +961,7 @@
E6A778E3282933E60045BBA8 /* WalletViewController.swift in Sources */,
E6A7790C282933E60045BBA8 /* WLBeaconManager.m in Sources */,
E6A77940282933E70045BBA8 /* AFURLSessionManager.m in Sources */,
1EDCDFAC28DB29E8002ED8F0 /* AnalysisMoreViewCell.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
//
// AnalysisMoreViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 21/9/22.
//
import UIKit
@objc public class AnalysisMoreViewCell: UITableViewCell {
@IBOutlet weak var titleLabel: UILabel!
// lifecycle
public override func awakeFromNib() {
super.awakeFromNib()
// title
titleLabel.font = UIFont(name: "PFSquareSansPro-Medium", size: 16)
titleLabel.textColor = UIColor(rgb: 0x415564)
titleLabel.text = "Δες Περισσότερα"
}
}
......@@ -26,7 +26,7 @@ import UIKit
private extension CSMButton {
func configure() {
setImage(UIImage(named: "directions"), for: .normal)
setImage(UIImage(named: "ic_directions", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil), for: .normal)
titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 18)
setTitleColor(.white, for: .normal)
backgroundColor = UIColor(rgb: 0x79BF14)
......
......@@ -8,9 +8,9 @@
import UIKit
class HistoryViewController: AnalysisChildViewController {
var loading: Bool = false
var items: Array<swiftApi.CouponItemModel> = swiftApi().getOldCouponList()
var showMore = false
// TODO: remove this when configuring model
let hasMessage = true
......@@ -20,6 +20,9 @@ class HistoryViewController: AnalysisChildViewController {
super.viewDidLoad()
self.tableView.delegate = self
self.tableView.dataSource = self
self.refreshControl = UIRefreshControl()
self.refreshControl?.addTarget(self, action: #selector(handleRefresh(_:)), for: .valueChanged)
......@@ -36,6 +39,13 @@ class HistoryViewController: AnalysisChildViewController {
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()
}
......@@ -63,6 +73,11 @@ class HistoryViewController: AnalysisChildViewController {
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()
......@@ -81,9 +96,12 @@ class HistoryViewController: AnalysisChildViewController {
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if (section == 0) {
return 1;
return 1
}
if (self.showMore == true) {
return 4
}
return items.count
}
......@@ -94,7 +112,6 @@ class HistoryViewController: AnalysisChildViewController {
return 140.0
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// header
......@@ -108,9 +125,26 @@ class HistoryViewController: AnalysisChildViewController {
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()
}
}
}
......
......@@ -43,7 +43,7 @@ import MapKit
setBackButton()
setNavigationTitle("Καταστήματα")
backgroundImage.image = UIImage(named: "coupons_scrollview_white")
backgroundImage.image = UIImage(named: "coupons_scrollview_white", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil)
mapView.delegate = self
mapView.centerToLocation(initialLocation, regionRadius: 1000000)
......@@ -72,7 +72,7 @@ import MapKit
//directionsButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 16)
directionsButton.setTitle("Οδηγίες", for: .normal)
directionsButton.setImage(UIImage(named: "ic_directions"), for: .normal)
directionsButton.setImage(UIImage(named: "ic_directions", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil), for: .normal)
// directionsButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 5);
// directionsButton.titleEdgeInsets = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 0);
......
......@@ -11,6 +11,8 @@ class SharingHistoryViewController: 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
......@@ -20,6 +22,9 @@ class SharingHistoryViewController: AnalysisChildViewController {
super.viewDidLoad()
self.tableView.delegate = self
self.tableView.dataSource = self
self.refreshControl = UIRefreshControl()
self.refreshControl?.addTarget(self, action: #selector(handleRefresh(_:)), for: .valueChanged)
......@@ -61,6 +66,12 @@ class SharingHistoryViewController: AnalysisChildViewController {
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()
......@@ -82,6 +93,9 @@ class SharingHistoryViewController: AnalysisChildViewController {
return 1;
}
if (self.showMore == true) {
return 4
}
return items.count
}
......@@ -106,9 +120,26 @@ class SharingHistoryViewController: AnalysisChildViewController {
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()
}
}
}
......