Manos Chorianopoulos

add more button at HistoryViewController

...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
28 1ECA079428D9E53F00D2BDE0 /* MapsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1ECA079228D9E53F00D2BDE0 /* MapsViewController.swift */; }; 28 1ECA079428D9E53F00D2BDE0 /* MapsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1ECA079228D9E53F00D2BDE0 /* MapsViewController.swift */; };
29 1ECA079528D9E53F00D2BDE0 /* MapsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1ECA079328D9E53F00D2BDE0 /* MapsViewController.xib */; }; 29 1ECA079528D9E53F00D2BDE0 /* MapsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1ECA079328D9E53F00D2BDE0 /* MapsViewController.xib */; };
30 1ECA079728D9E66200D2BDE0 /* MerchantAnnotation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1ECA079628D9E66200D2BDE0 /* MerchantAnnotation.swift */; }; 30 1ECA079728D9E66200D2BDE0 /* MerchantAnnotation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1ECA079628D9E66200D2BDE0 /* MerchantAnnotation.swift */; };
31 + 1EDCDFAC28DB29E8002ED8F0 /* AnalysisMoreViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EDCDFAB28DB29E8002ED8F0 /* AnalysisMoreViewCell.swift */; };
31 7630AD9A6242D60846D6750C /* Pods_SwiftWarplyFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C0D5F56DD4E5371A50AD2D87 /* Pods_SwiftWarplyFramework.framework */; }; 32 7630AD9A6242D60846D6750C /* Pods_SwiftWarplyFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C0D5F56DD4E5371A50AD2D87 /* Pods_SwiftWarplyFramework.framework */; };
32 A02F34052882B6E60086465F /* TelcoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A02F34042882B6E60086465F /* TelcoViewController.swift */; }; 33 A02F34052882B6E60086465F /* TelcoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A02F34042882B6E60086465F /* TelcoViewController.swift */; };
33 A04D31DE288FF670000E43B5 /* HistoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A04D31DD288FF670000E43B5 /* HistoryViewController.swift */; }; 34 A04D31DE288FF670000E43B5 /* HistoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A04D31DD288FF670000E43B5 /* HistoryViewController.swift */; };
...@@ -187,6 +188,7 @@ ...@@ -187,6 +188,7 @@
187 1ECA079228D9E53F00D2BDE0 /* MapsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapsViewController.swift; sourceTree = "<group>"; }; 188 1ECA079228D9E53F00D2BDE0 /* MapsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapsViewController.swift; sourceTree = "<group>"; };
188 1ECA079328D9E53F00D2BDE0 /* MapsViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MapsViewController.xib; sourceTree = "<group>"; }; 189 1ECA079328D9E53F00D2BDE0 /* MapsViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MapsViewController.xib; sourceTree = "<group>"; };
189 1ECA079628D9E66200D2BDE0 /* MerchantAnnotation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MerchantAnnotation.swift; sourceTree = "<group>"; }; 190 1ECA079628D9E66200D2BDE0 /* MerchantAnnotation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MerchantAnnotation.swift; sourceTree = "<group>"; };
191 + 1EDCDFAB28DB29E8002ED8F0 /* AnalysisMoreViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalysisMoreViewCell.swift; sourceTree = "<group>"; };
190 A02F34042882B6E60086465F /* TelcoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TelcoViewController.swift; sourceTree = "<group>"; }; 192 A02F34042882B6E60086465F /* TelcoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TelcoViewController.swift; sourceTree = "<group>"; };
191 A04D31DD288FF670000E43B5 /* HistoryViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HistoryViewController.swift; sourceTree = "<group>"; }; 193 A04D31DD288FF670000E43B5 /* HistoryViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HistoryViewController.swift; sourceTree = "<group>"; };
192 A079366D2885D07700064122 /* AnalysisChildViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalysisChildViewController.swift; sourceTree = "<group>"; }; 194 A079366D2885D07700064122 /* AnalysisChildViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalysisChildViewController.swift; sourceTree = "<group>"; };
...@@ -460,6 +462,7 @@ ...@@ -460,6 +462,7 @@
460 E6A77A35282BB4CB0045BBA8 /* MakeItAPresentViewController.swift */, 462 E6A77A35282BB4CB0045BBA8 /* MakeItAPresentViewController.swift */,
461 E6A7785A282933E40045BBA8 /* Helpers */, 463 E6A7785A282933E40045BBA8 /* Helpers */,
462 E6A77861282933E50045BBA8 /* Main.storyboard */, 464 E6A77861282933E50045BBA8 /* Main.storyboard */,
465 + 1EDCDFAB28DB29E8002ED8F0 /* AnalysisMoreViewCell.swift */,
463 1E87A9EE28C2021200C79F90 /* ContextualViewController.swift */, 466 1E87A9EE28C2021200C79F90 /* ContextualViewController.swift */,
464 1EB236AA28816B680063777A /* ShareViewController.swift */, 467 1EB236AA28816B680063777A /* ShareViewController.swift */,
465 1EB236AC28816C560063777A /* NumberPopupViewController.swift */, 468 1EB236AC28816C560063777A /* NumberPopupViewController.swift */,
...@@ -958,6 +961,7 @@ ...@@ -958,6 +961,7 @@
958 E6A778E3282933E60045BBA8 /* WalletViewController.swift in Sources */, 961 E6A778E3282933E60045BBA8 /* WalletViewController.swift in Sources */,
959 E6A7790C282933E60045BBA8 /* WLBeaconManager.m in Sources */, 962 E6A7790C282933E60045BBA8 /* WLBeaconManager.m in Sources */,
960 E6A77940282933E70045BBA8 /* AFURLSessionManager.m in Sources */, 963 E6A77940282933E70045BBA8 /* AFURLSessionManager.m in Sources */,
964 + 1EDCDFAC28DB29E8002ED8F0 /* AnalysisMoreViewCell.swift in Sources */,
961 ); 965 );
962 runOnlyForDeploymentPostprocessing = 0; 966 runOnlyForDeploymentPostprocessing = 0;
963 }; 967 };
......
1 +//
2 +// AnalysisMoreViewCell.swift
3 +// SwiftWarplyFramework
4 +//
5 +// Created by Manos Chorianopoulos on 21/9/22.
6 +//
7 +
8 +import UIKit
9 +
10 +@objc public class AnalysisMoreViewCell: UITableViewCell {
11 + @IBOutlet weak var titleLabel: UILabel!
12 +
13 + // lifecycle
14 + public override func awakeFromNib() {
15 + super.awakeFromNib()
16 +
17 + // title
18 + titleLabel.font = UIFont(name: "PFSquareSansPro-Medium", size: 16)
19 + titleLabel.textColor = UIColor(rgb: 0x415564)
20 + titleLabel.text = "Δες Περισσότερα"
21 + }
22 +}
...@@ -26,7 +26,7 @@ import UIKit ...@@ -26,7 +26,7 @@ import UIKit
26 26
27 private extension CSMButton { 27 private extension CSMButton {
28 func configure() { 28 func configure() {
29 - setImage(UIImage(named: "directions"), for: .normal) 29 + setImage(UIImage(named: "ic_directions", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil), for: .normal)
30 titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 18) 30 titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 18)
31 setTitleColor(.white, for: .normal) 31 setTitleColor(.white, for: .normal)
32 backgroundColor = UIColor(rgb: 0x79BF14) 32 backgroundColor = UIColor(rgb: 0x79BF14)
......
...@@ -8,9 +8,9 @@ ...@@ -8,9 +8,9 @@
8 import UIKit 8 import UIKit
9 9
10 class HistoryViewController: AnalysisChildViewController { 10 class HistoryViewController: AnalysisChildViewController {
11 -
12 var loading: Bool = false 11 var loading: Bool = false
13 var items: Array<swiftApi.CouponItemModel> = swiftApi().getOldCouponList() 12 var items: Array<swiftApi.CouponItemModel> = swiftApi().getOldCouponList()
13 + var showMore = false
14 14
15 // TODO: remove this when configuring model 15 // TODO: remove this when configuring model
16 let hasMessage = true 16 let hasMessage = true
...@@ -20,6 +20,9 @@ class HistoryViewController: AnalysisChildViewController { ...@@ -20,6 +20,9 @@ class HistoryViewController: AnalysisChildViewController {
20 20
21 super.viewDidLoad() 21 super.viewDidLoad()
22 22
23 + self.tableView.delegate = self
24 + self.tableView.dataSource = self
25 +
23 self.refreshControl = UIRefreshControl() 26 self.refreshControl = UIRefreshControl()
24 self.refreshControl?.addTarget(self, action: #selector(handleRefresh(_:)), for: .valueChanged) 27 self.refreshControl?.addTarget(self, action: #selector(handleRefresh(_:)), for: .valueChanged)
25 28
...@@ -36,6 +39,13 @@ class HistoryViewController: AnalysisChildViewController { ...@@ -36,6 +39,13 @@ class HistoryViewController: AnalysisChildViewController {
36 showLoading() 39 showLoading()
37 40
38 items = swiftApi().getOldCouponList() 41 items = swiftApi().getOldCouponList()
42 +
43 + self.showMore = (self.items.count > 3)
44 +
45 + if (self.showMore == true) {
46 + self.items = Array(self.items[0...2])
47 + }
48 +
39 showContent() 49 showContent()
40 self.tableView.reloadData() 50 self.tableView.reloadData()
41 } 51 }
...@@ -63,6 +73,11 @@ class HistoryViewController: AnalysisChildViewController { ...@@ -63,6 +73,11 @@ class HistoryViewController: AnalysisChildViewController {
63 func responseCallback (_ data: Array<swiftApi.CouponItemModel>?) -> Void { 73 func responseCallback (_ data: Array<swiftApi.CouponItemModel>?) -> Void {
64 74
65 self.items = data! 75 self.items = data!
76 + self.showMore = (self.items.count > 3)
77 +
78 + if (self.showMore == true) {
79 + self.items = Array(self.items[0...2])
80 + }
66 showContent() 81 showContent()
67 DispatchQueue.main.async { 82 DispatchQueue.main.async {
68 self.tableView.reloadData() 83 self.tableView.reloadData()
...@@ -81,9 +96,12 @@ class HistoryViewController: AnalysisChildViewController { ...@@ -81,9 +96,12 @@ class HistoryViewController: AnalysisChildViewController {
81 96
82 override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 97 override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
83 if (section == 0) { 98 if (section == 0) {
84 - return 1; 99 + return 1
85 } 100 }
86 101
102 + if (self.showMore == true) {
103 + return 4
104 + }
87 return items.count 105 return items.count
88 } 106 }
89 107
...@@ -94,7 +112,6 @@ class HistoryViewController: AnalysisChildViewController { ...@@ -94,7 +112,6 @@ class HistoryViewController: AnalysisChildViewController {
94 112
95 return 140.0 113 return 140.0
96 } 114 }
97 -
98 override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 115 override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
99 116
100 // header 117 // header
...@@ -108,9 +125,26 @@ class HistoryViewController: AnalysisChildViewController { ...@@ -108,9 +125,26 @@ class HistoryViewController: AnalysisChildViewController {
108 return tableView.dequeueReusableCell(withIdentifier: "AnalysisHeaderViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisHeaderViewCell 125 return tableView.dequeueReusableCell(withIdentifier: "AnalysisHeaderViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisHeaderViewCell
109 } 126 }
110 127
128 + if (self.showMore && indexPath.row == 3) {
129 + let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisMoreViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisMoreViewCell
130 + return cell
131 + }
132 +
111 let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisItemViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisItemViewCell 133 let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisItemViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisItemViewCell
112 cell.configureCell(item: items[indexPath.row]) 134 cell.configureCell(item: items[indexPath.row])
113 135
114 return cell 136 return cell
115 } 137 }
138 +
139 + override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
140 + if (indexPath.section == 0) {
141 + return
142 + }
143 +
144 + if (self.showMore && indexPath.row == 3) {
145 + self.items = swiftApi().getOldCouponList()
146 + self.showMore = false
147 + self.tableView.reloadData()
148 + }
149 + }
116 } 150 }
......
...@@ -43,7 +43,7 @@ import MapKit ...@@ -43,7 +43,7 @@ import MapKit
43 setBackButton() 43 setBackButton()
44 setNavigationTitle("Καταστήματα") 44 setNavigationTitle("Καταστήματα")
45 45
46 - backgroundImage.image = UIImage(named: "coupons_scrollview_white") 46 + backgroundImage.image = UIImage(named: "coupons_scrollview_white", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil)
47 47
48 mapView.delegate = self 48 mapView.delegate = self
49 mapView.centerToLocation(initialLocation, regionRadius: 1000000) 49 mapView.centerToLocation(initialLocation, regionRadius: 1000000)
...@@ -72,7 +72,7 @@ import MapKit ...@@ -72,7 +72,7 @@ import MapKit
72 72
73 //directionsButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 16) 73 //directionsButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 16)
74 directionsButton.setTitle("Οδηγίες", for: .normal) 74 directionsButton.setTitle("Οδηγίες", for: .normal)
75 - directionsButton.setImage(UIImage(named: "ic_directions"), for: .normal) 75 + directionsButton.setImage(UIImage(named: "ic_directions", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil), for: .normal)
76 76
77 // directionsButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 5); 77 // directionsButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 5);
78 // directionsButton.titleEdgeInsets = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 0); 78 // directionsButton.titleEdgeInsets = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 0);
......
...@@ -11,6 +11,8 @@ class SharingHistoryViewController: AnalysisChildViewController { ...@@ -11,6 +11,8 @@ class SharingHistoryViewController: AnalysisChildViewController {
11 11
12 var loading: Bool = false 12 var loading: Bool = false
13 var items: Array<swiftApi.SharingCouponModel> = Array() 13 var items: Array<swiftApi.SharingCouponModel> = Array()
14 + var allItems: Array<swiftApi.SharingCouponModel> = Array()
15 + var showMore = false
14 16
15 // TODO: remove this when configuring model 17 // TODO: remove this when configuring model
16 let hasMessage = false 18 let hasMessage = false
...@@ -20,6 +22,9 @@ class SharingHistoryViewController: AnalysisChildViewController { ...@@ -20,6 +22,9 @@ class SharingHistoryViewController: AnalysisChildViewController {
20 22
21 super.viewDidLoad() 23 super.viewDidLoad()
22 24
25 + self.tableView.delegate = self
26 + self.tableView.dataSource = self
27 +
23 self.refreshControl = UIRefreshControl() 28 self.refreshControl = UIRefreshControl()
24 self.refreshControl?.addTarget(self, action: #selector(handleRefresh(_:)), for: .valueChanged) 29 self.refreshControl?.addTarget(self, action: #selector(handleRefresh(_:)), for: .valueChanged)
25 30
...@@ -61,6 +66,12 @@ class SharingHistoryViewController: AnalysisChildViewController { ...@@ -61,6 +66,12 @@ class SharingHistoryViewController: AnalysisChildViewController {
61 func responseCallback (_ data: Array<swiftApi.SharingCouponModel>?) -> Void { 66 func responseCallback (_ data: Array<swiftApi.SharingCouponModel>?) -> Void {
62 67
63 self.items = data! 68 self.items = data!
69 + self.allItems = data!
70 + self.showMore = (self.items.count > 3)
71 +
72 + if (self.showMore == true) {
73 + self.items = Array(self.items[0...2])
74 + }
64 showContent() 75 showContent()
65 DispatchQueue.main.async { 76 DispatchQueue.main.async {
66 self.tableView.reloadData() 77 self.tableView.reloadData()
...@@ -82,6 +93,9 @@ class SharingHistoryViewController: AnalysisChildViewController { ...@@ -82,6 +93,9 @@ class SharingHistoryViewController: AnalysisChildViewController {
82 return 1; 93 return 1;
83 } 94 }
84 95
96 + if (self.showMore == true) {
97 + return 4
98 + }
85 return items.count 99 return items.count
86 } 100 }
87 101
...@@ -106,9 +120,26 @@ class SharingHistoryViewController: AnalysisChildViewController { ...@@ -106,9 +120,26 @@ class SharingHistoryViewController: AnalysisChildViewController {
106 return cell 120 return cell
107 } 121 }
108 122
123 + if ((self.showMore == true) && (indexPath.row == 3)) {
124 + let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisMoreViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisMoreViewCell
125 + return cell
126 + }
127 +
109 let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisItemViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisItemViewCell 128 let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisItemViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisItemViewCell
110 cell.configureCell(item: items[indexPath.row]) 129 cell.configureCell(item: items[indexPath.row])
111 130
112 return cell 131 return cell
113 } 132 }
133 +
134 + override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
135 + if (indexPath.section == 0) {
136 + return
137 + }
138 +
139 + if ((self.showMore == true) && (indexPath.row == 3)) {
140 + self.items = self.allItems
141 + self.showMore = false
142 + self.tableView.reloadData()
143 + }
144 + }
114 } 145 }
......