Skip to content

Commit 4881505

Browse files
authored
Merge pull request #37 from BE-SOPT-Collaboration-Seminar-Coinone/feature/#31
Feature/#31
2 parents c05344a + 2f55dd1 commit 4881505

File tree

3 files changed

+72
-17
lines changed

3 files changed

+72
-17
lines changed

Coinone-iOS/Coinone-iOS/Source/Cells/FilterCollectionViewCell.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ class FilterCollectionViewCell: UICollectionViewCell {
1313

1414
// MARK: - Identifier
1515
let identifier = "FilterCollectionViewCell"
16+
static var titleTag = true
17+
static var currentPriceTag = true
18+
static var fluctuationTag = true
19+
static var totalPriceTag = true
1620

1721
// MARK: - LifeCycles
1822
override func awakeFromNib() {

Coinone-iOS/Coinone-iOS/Source/ReusableViews/CoinListCollectionReusableView.swift

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ class CoinListCollectionReusableView: UICollectionReusableView {
1414

1515
// MARK: - Identifier
1616
let identifier = "CoinListCollectionReusableView"
17+
var sort = "total-price"
18+
var ascending = "-1"
1719

1820
// MARK: - LifeCycles
1921
override func awakeFromNib() {
2022
super.awakeFromNib()
21-
setInitialList()
2223
register()
2324
layout()
2425
self.coinListTableView.delegate = self
@@ -27,20 +28,7 @@ class CoinListCollectionReusableView: UICollectionReusableView {
2728

2829
// MARK: - Components
2930
let coinListTableView = UITableView()
30-
var coinModel: [CoinListModel] = [CoinListModel(coinLogoImageName: "coinLogo",
31-
coinEnglishTitle: "XRP",
32-
coinKoreanTitle: "리플",
33-
coinCurrentPrice: "1625",
34-
riseOrDescent: "-",
35-
percentage: "0.37",
36-
coinTotalPrice: "2059"),
37-
CoinListModel(coinLogoImageName: "coinLogo",
38-
coinEnglishTitle: "XRP",
39-
coinKoreanTitle: "리플",
40-
coinCurrentPrice: "1625",
41-
riseOrDescent: "+",
42-
percentage: "0.37",
43-
coinTotalPrice: "2059")]
31+
var coinModel: [CoinListModel] = []
4432
}
4533

4634
// MARK: - Extensions
@@ -63,8 +51,8 @@ extension CoinListCollectionReusableView {
6351
}
6452
}
6553
}
66-
func setInitialList() {
67-
CoinFilterService.shared.sortCoin(sort: "total-price", ascending: "-1") {
54+
func setInitialList(sort: String, ascending: String) {
55+
CoinFilterService.shared.sortCoin(sort: sort, ascending: ascending) {
6856
(networkResult) in
6957
switch(networkResult) {
7058
case .success(let data):

Coinone-iOS/Coinone-iOS/Source/ViewControllers/TransactionViewController.swift

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,14 @@ class TransactionViewController: UIViewController {
3535
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
3636
collectionView.isScrollEnabled = true
3737
collectionView.translatesAutoresizingMaskIntoConstraints = false
38+
collectionView.allowsMultipleSelection = true
3839
return collectionView
3940
}()
4041

4142
var menuTitles: [String] = ["마이", "거래소", "간편구매", "정보"]
4243
var filterTitles: [String] = ["코인명", "현재가", "등락률", "거래대금"]
44+
var sort: String = "total-price"
45+
var ascending: String = "-1"
4346
}
4447

4548
// MARK: - Extensions
@@ -196,6 +199,7 @@ extension TransactionViewController: UICollectionViewDataSource {
196199
return UICollectionReusableView()
197200
}
198201
footerView.awakeFromNib()
202+
footerView.setInitialList(sort: self.sort, ascending: self.ascending)
199203
reusableView = footerView
200204
}
201205
}
@@ -211,5 +215,64 @@ extension TransactionViewController: UICollectionViewDataSource {
211215
HomeViewController.menuIndex = 0
212216
self.navigationController?.popViewController(animated: false)
213217
}
218+
if indexPath.section == 1 {
219+
switch(indexPath.item) {
220+
case 0:
221+
if FilterCollectionViewCell.titleTag == true {
222+
ascending = "-1"
223+
FilterCollectionViewCell.titleTag = false
224+
}
225+
else {
226+
ascending = "1"
227+
FilterCollectionViewCell.titleTag = true
228+
}
229+
self.sort = "title"
230+
collectionView.reloadData()
231+
case 1:
232+
if FilterCollectionViewCell.currentPriceTag == true {
233+
ascending = "-1"
234+
FilterCollectionViewCell.currentPriceTag = false
235+
}
236+
else {
237+
ascending = "1"
238+
FilterCollectionViewCell.currentPriceTag = true
239+
}
240+
self.sort = "current-price"
241+
collectionView.reloadData()
242+
case 2:
243+
if FilterCollectionViewCell.fluctuationTag == true {
244+
ascending = "-1"
245+
FilterCollectionViewCell.fluctuationTag = false
246+
}
247+
else {
248+
ascending = "1"
249+
FilterCollectionViewCell.fluctuationTag = true
250+
}
251+
self.sort = "degree"
252+
collectionView.reloadData()
253+
case 3:
254+
if FilterCollectionViewCell.totalPriceTag == true {
255+
ascending = "-1"
256+
FilterCollectionViewCell.totalPriceTag = false
257+
}
258+
else {
259+
ascending = "1"
260+
FilterCollectionViewCell.totalPriceTag = true
261+
}
262+
self.sort = "total-price"
263+
collectionView.reloadData()
264+
default:
265+
if FilterCollectionViewCell.totalPriceTag == true {
266+
ascending = "-1"
267+
FilterCollectionViewCell.totalPriceTag = false
268+
}
269+
else {
270+
ascending = "1"
271+
FilterCollectionViewCell.totalPriceTag = true
272+
}
273+
self.sort = "total-price"
274+
collectionView.reloadData()
275+
}
276+
}
214277
}
215278
}

0 commit comments

Comments
 (0)