From 2d79939a0746162f8a260c46cd504a9ad75e3747 Mon Sep 17 00:00:00 2001 From: hansol Date: Thu, 20 May 2021 23:53:10 +0900 Subject: [PATCH 1/2] =?UTF-8?q?:art:=20TransactionViewController=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Coinone-iOS.xcodeproj/project.pbxproj | 28 +++ .../switchDown.imageset/Contents.json | 23 +++ .../switchDown.imageset/switchDown.png | Bin 0 -> 280 bytes .../switchDown.imageset/switchDown@2x.png | Bin 0 -> 425 bytes .../switchDown.imageset/switchDown@3x.png | Bin 0 -> 569 bytes Coinone-iOS/Coinone-iOS/Resource/Info.plist | 2 +- .../Resource/Protocol/Identifiable.swift | 1 + .../Source/Cells/CoinListTableViewCell.swift | 139 ++++++++++++++ .../Cells/FilterCollectionViewCell.swift | 58 ++++++ .../Source/Models/CoinListModel.swift | 19 ++ .../CoinListCollectionReusableView.swift | 93 +++++++++ .../TitleCollectionReusableView.swift | 57 ++++++ .../ViewControllers/HomeViewController.swift | 3 +- .../TransactionViewController.swift | 178 ++++++++++++++++-- 14 files changed, 588 insertions(+), 13 deletions(-) create mode 100644 Coinone-iOS/Coinone-iOS/Resource/Assets.xcassets/switchDown.imageset/Contents.json create mode 100644 Coinone-iOS/Coinone-iOS/Resource/Assets.xcassets/switchDown.imageset/switchDown.png create mode 100644 Coinone-iOS/Coinone-iOS/Resource/Assets.xcassets/switchDown.imageset/switchDown@2x.png create mode 100644 Coinone-iOS/Coinone-iOS/Resource/Assets.xcassets/switchDown.imageset/switchDown@3x.png create mode 100644 Coinone-iOS/Coinone-iOS/Source/Cells/CoinListTableViewCell.swift create mode 100644 Coinone-iOS/Coinone-iOS/Source/Cells/FilterCollectionViewCell.swift create mode 100644 Coinone-iOS/Coinone-iOS/Source/Models/CoinListModel.swift create mode 100644 Coinone-iOS/Coinone-iOS/Source/ReusableViews/CoinListCollectionReusableView.swift create mode 100644 Coinone-iOS/Coinone-iOS/Source/ReusableViews/TitleCollectionReusableView.swift diff --git a/Coinone-iOS/Coinone-iOS.xcodeproj/project.pbxproj b/Coinone-iOS/Coinone-iOS.xcodeproj/project.pbxproj index 18aaab6..832cc56 100644 --- a/Coinone-iOS/Coinone-iOS.xcodeproj/project.pbxproj +++ b/Coinone-iOS/Coinone-iOS.xcodeproj/project.pbxproj @@ -8,6 +8,11 @@ /* Begin PBXBuildFile section */ 06A1A45591145692DA4F18C7 /* Pods_Coinone_iOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E0AB500236EDF60103A408AE /* Pods_Coinone_iOS.framework */; }; + CC0A1A9726564240000B65B9 /* FilterCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC0A1A9626564240000B65B9 /* FilterCollectionViewCell.swift */; }; + CC0A1A992656425A000B65B9 /* CoinListTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC0A1A982656425A000B65B9 /* CoinListTableViewCell.swift */; }; + CC0A1A9C265642E9000B65B9 /* TitleCollectionReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC0A1A9B265642E9000B65B9 /* TitleCollectionReusableView.swift */; }; + CC0A1A9E2656434B000B65B9 /* CoinListCollectionReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC0A1A9D2656434B000B65B9 /* CoinListCollectionReusableView.swift */; }; + CC0A1AA026564FDA000B65B9 /* CoinListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC0A1A9F26564FDA000B65B9 /* CoinListModel.swift */; }; CC0E23272652232700B982A0 /* MyViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC0E23262652232700B982A0 /* MyViewController.swift */; }; CC0E232B265223FE00B982A0 /* StockTVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC0E232A265223FE00B982A0 /* StockTVC.swift */; }; CC0E232D2652241D00B982A0 /* StockModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC0E232C2652241D00B982A0 /* StockModel.swift */; }; @@ -50,6 +55,11 @@ /* Begin PBXFileReference section */ 3E2F6097EABAAACC664AB52A /* Pods-Coinone-iOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Coinone-iOS.debug.xcconfig"; path = "Target Support Files/Pods-Coinone-iOS/Pods-Coinone-iOS.debug.xcconfig"; sourceTree = ""; }; 4BA5E0330054E48E147B52CA /* Pods-Coinone-iOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Coinone-iOS.release.xcconfig"; path = "Target Support Files/Pods-Coinone-iOS/Pods-Coinone-iOS.release.xcconfig"; sourceTree = ""; }; + CC0A1A9626564240000B65B9 /* FilterCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FilterCollectionViewCell.swift; sourceTree = ""; }; + CC0A1A982656425A000B65B9 /* CoinListTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoinListTableViewCell.swift; sourceTree = ""; }; + CC0A1A9B265642E9000B65B9 /* TitleCollectionReusableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TitleCollectionReusableView.swift; sourceTree = ""; }; + CC0A1A9D2656434B000B65B9 /* CoinListCollectionReusableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoinListCollectionReusableView.swift; sourceTree = ""; }; + CC0A1A9F26564FDA000B65B9 /* CoinListModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoinListModel.swift; sourceTree = ""; }; CC0E23262652232700B982A0 /* MyViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyViewController.swift; sourceTree = ""; }; CC0E232A265223FE00B982A0 /* StockTVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StockTVC.swift; sourceTree = ""; }; CC0E232C2652241D00B982A0 /* StockModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StockModel.swift; sourceTree = ""; }; @@ -104,6 +114,15 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + CC0A1A9A265642B6000B65B9 /* ReusableViews */ = { + isa = PBXGroup; + children = ( + CC0A1A9B265642E9000B65B9 /* TitleCollectionReusableView.swift */, + CC0A1A9D2656434B000B65B9 /* CoinListCollectionReusableView.swift */, + ); + path = ReusableViews; + sourceTree = ""; + }; CC0E2328265223B000B982A0 /* Cells */ = { isa = PBXGroup; children = ( @@ -111,6 +130,8 @@ CC770CFD26540902004095A6 /* TopMenuCollectionViewCell.swift */, CC770D02265426FA004095A6 /* FavoriteTableViewCell.swift */, E8EC22B1265445210027E8A8 /* MyTableViewCell.swift */, + CC0A1A9626564240000B65B9 /* FilterCollectionViewCell.swift */, + CC0A1A982656425A000B65B9 /* CoinListTableViewCell.swift */, ); path = Cells; sourceTree = ""; @@ -121,6 +142,7 @@ CC0E232C2652241D00B982A0 /* StockModel.swift */, CC770D0426542DDF004095A6 /* CoinModel.swift */, E8EC22B5265448200027E8A8 /* MyListDataModel.swift */, + CC0A1A9F26564FDA000B65B9 /* CoinListModel.swift */, ); path = Models; sourceTree = ""; @@ -177,6 +199,7 @@ CCAA9A1A264FAA0C008E50BF /* Source */ = { isa = PBXGroup; children = ( + CC0A1A9A265642B6000B65B9 /* ReusableViews */, CC0E2329265223B800B982A0 /* Models */, CC0E2328265223B000B982A0 /* Cells */, CCAA9A1E264FAA6C008E50BF /* ViewControllers */, @@ -386,12 +409,14 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + CC0A1A9C265642E9000B65B9 /* TitleCollectionReusableView.swift in Sources */, CCAA9A34264FAF68008E50BF /* UIView+.swift in Sources */, CC6608BE265450B0004DD7D2 /* PopupHsViewController.swift in Sources */, CC0E232D2652241D00B982A0 /* StockModel.swift in Sources */, CCAA9A2B264FACDD008E50BF /* UIColor+.swift in Sources */, CC770CF8265396CF004095A6 /* UILabel+.swift in Sources */, CC0E232B265223FE00B982A0 /* StockTVC.swift in Sources */, + CC0A1A992656425A000B65B9 /* CoinListTableViewCell.swift in Sources */, CC770CFE26540903004095A6 /* TopMenuCollectionViewCell.swift in Sources */, CC770D03265426FA004095A6 /* FavoriteTableViewCell.swift in Sources */, CC272E5B26517E6000637BCE /* TabbarViewController.swift in Sources */, @@ -399,10 +424,13 @@ CCA0ECC6264FA7A4001CC563 /* AppDelegate.swift in Sources */, CC26A39F2655075600C09C0D /* PopupViewController.swift in Sources */, CC770CFC265397BD004095A6 /* UIFont+.swift in Sources */, + CC0A1AA026564FDA000B65B9 /* CoinListModel.swift in Sources */, + CC0A1A9726564240000B65B9 /* FilterCollectionViewCell.swift in Sources */, E8EC22B2265445210027E8A8 /* MyTableViewCell.swift in Sources */, CC0E23272652232700B982A0 /* MyViewController.swift in Sources */, CCAA9A2E264FAEB9008E50BF /* CALayer+.swift in Sources */, CC272E6226517F0500637BCE /* HomeViewController.swift in Sources */, + CC0A1A9E2656434B000B65B9 /* CoinListCollectionReusableView.swift in Sources */, CC0E232F2652244F00B982A0 /* GeoraesoVC.swift in Sources */, CC770D0126540943004095A6 /* Identifiable.swift in Sources */, CCA0ECC8264FA7A4001CC563 /* SceneDelegate.swift in Sources */, diff --git a/Coinone-iOS/Coinone-iOS/Resource/Assets.xcassets/switchDown.imageset/Contents.json b/Coinone-iOS/Coinone-iOS/Resource/Assets.xcassets/switchDown.imageset/Contents.json new file mode 100644 index 0000000..ad5e7dc --- /dev/null +++ b/Coinone-iOS/Coinone-iOS/Resource/Assets.xcassets/switchDown.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "switchDown.png" + }, + { + "scale" : "2x", + "idiom" : "universal", + "filename" : "switchDown@2x.png" + }, + { + "idiom" : "universal", + "scale" : "3x", + "filename" : "switchDown@3x.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Coinone-iOS/Coinone-iOS/Resource/Assets.xcassets/switchDown.imageset/switchDown.png b/Coinone-iOS/Coinone-iOS/Resource/Assets.xcassets/switchDown.imageset/switchDown.png new file mode 100644 index 0000000000000000000000000000000000000000..37f2275df7f8d8deb17d517e7f3dea1347af5008 GIT binary patch literal 280 zcmeAS@N?(olHy`uVBq!ia0vp^96-#)!3HEdkIOdzDb50q$YKTtZeb8+WSBKa0w~B> z9OUlAuzS5b(e@PDP@8P~ZO`L5+ZiVYd5IqX$jmV9O0VJVMH+lln7^NMTHDGX_`Y)9`@8>G YdE6}CZnw;u1#~!rr>mdKI;Vst047sq4FCWD literal 0 HcmV?d00001 diff --git a/Coinone-iOS/Coinone-iOS/Resource/Assets.xcassets/switchDown.imageset/switchDown@2x.png b/Coinone-iOS/Coinone-iOS/Resource/Assets.xcassets/switchDown.imageset/switchDown@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..c2ef8719c690f388d93c1c2463b8d0b2ac5487cb GIT binary patch literal 425 zcmV;a0apHrP)O3kVu?*G*ADaHmjE7p9OvmU;t^5l9xUigZ!ZLMc_DH;4r<&?A_Q zAZ=!x*Thg`Gba1~@CfhmzK=;J0Fv~F&xgIis3F@SGI$>I69%O5G#DLK5(L3;58
?S3J_Ln{0a&Zf5A;&k_o!qm--gO7o0JzNT2|yYz~*W zyE02)qOxnz)uBuXMC_AvTCLNFV!u!ojVkON%7!JDO_D5c!8A>sQfgKL6(#UIZ@Rn% zP1ArecFQ@}OTsfk$YXW_jN>@EkWBuQq;S)9-Ptbz#=G`P)(+ z$^2BL)9HOll8(R!X_}_gYBdF~&3(Yk3xXg#fDZ};0*~xe#A{-qme^?w8;VVGTrQW3 z^RWqFw=_{zHNFXinJb}CC~l1{eC!Y+isCgEf=6KwAtYWZl_m@ERmJ&yK0+xS8io-8 z59YEgEB|u5Cbtkfb6Wr^m&@U6J7mW`rv#THUa3^L&&?KKfxL0j$9Co@$N!=~gUpIl z#>pHdf(wmCqj5AEowD`5#4&p=_tk1u2EUcfW{d17cUISceneDelegateClassName $(PRODUCT_MODULE_NAME).SceneDelegate UISceneStoryboardFile - Georaeso + Main diff --git a/Coinone-iOS/Coinone-iOS/Resource/Protocol/Identifiable.swift b/Coinone-iOS/Coinone-iOS/Resource/Protocol/Identifiable.swift index b7d1fca..8a55640 100644 --- a/Coinone-iOS/Coinone-iOS/Resource/Protocol/Identifiable.swift +++ b/Coinone-iOS/Coinone-iOS/Resource/Protocol/Identifiable.swift @@ -20,3 +20,4 @@ extension Identifiable { extension UITableViewCell: Identifiable {} extension UICollectionViewCell: Identifiable {} extension UIViewController: Identifiable {} +extension UICollectionReusableView: Identifiable {} diff --git a/Coinone-iOS/Coinone-iOS/Source/Cells/CoinListTableViewCell.swift b/Coinone-iOS/Coinone-iOS/Source/Cells/CoinListTableViewCell.swift new file mode 100644 index 0000000..22118a0 --- /dev/null +++ b/Coinone-iOS/Coinone-iOS/Source/Cells/CoinListTableViewCell.swift @@ -0,0 +1,139 @@ +// +// CoinListTableViewCell.swift +// Coinone-iOS +// +// Created by 노한솔 on 2021/05/20. +// +import SnapKit +import Then +import UIKit + +// MARK: - CoinListTableViewCell +class CoinListTableViewCell: UITableViewCell { + + // MARK: - Identifier + let identifier = "CoinListTableViewCell" + + // MARK: - LifeCycles + override func awakeFromNib() { + super.awakeFromNib() + layout() + + } + + // MARK: - Components + let containerView = UIView() + let coinTitleContainerView = UIView() + let coinTitleLogoImageView = UIImageView() + let coinTitleEnglishLabel = UILabel() + let coinTitleKoreanLabel = UILabel() + + let coinCurrentPriceLabel = UILabel() + let coinFluctuationDegreeLabel = UILabel() + let coinTotalPriceLabel = UILabel() +} + +// MARK: - Extensions +extension CoinListTableViewCell { + + // MARK: - Helpers + func layout() { + self.backgroundColor = .clear + layoutContainerView() + layoutCoinTitleContainerView() + layoutCoinTitleEnglishLabel() + layoutCoinTitleLogoImageView() + layoutCoinTitleKoreanLabel() + layoutCoinTotalPriceLabel() + layoutCoinFluctuationDegreeLabel() + layoutCoinCurrentPriceLabel() + } + func layoutContainerView() { + self.contentView.add(containerView) { + $0.backgroundColor = .white + $0.snp.makeConstraints { + $0.top.equalTo(self.contentView.snp.top).offset(6) + $0.leading.equalTo(self.contentView.snp.leading).offset(20) + $0.trailing.equalTo(self.contentView.snp.trailing).offset(-20) + $0.bottom.equalTo(self.contentView.snp.bottom).offset(-6) + } + } + } + func layoutCoinTitleContainerView() { + self.containerView.add(coinTitleContainerView) { + $0.backgroundColor = .clear + $0.snp.makeConstraints { + $0.leading.equalTo(self.containerView.snp.leading).offset(13) + $0.centerY.equalToSuperview() + $0.height.equalTo(34) + $0.width.equalTo(50) + } + } + } + func layoutCoinTitleEnglishLabel() { + self.coinTitleContainerView.add(coinTitleEnglishLabel) { + $0.snp.makeConstraints { + $0.leading.equalTo(self.coinTitleContainerView.snp.leading).offset(22) + $0.top.equalTo(self.coinTitleContainerView.snp.top) + } + } + } + func layoutCoinTitleLogoImageView() { + self.coinTitleContainerView.add(coinTitleLogoImageView) { + $0.snp.makeConstraints { + $0.leading.equalTo(self.coinTitleContainerView.snp.leading) + $0.top.equalTo(self.coinTitleEnglishLabel.snp.top) + $0.width.height.equalTo(12) + } + } + } + func layoutCoinTitleKoreanLabel() { + self.coinTitleContainerView.add(coinTitleKoreanLabel) { + $0.snp.makeConstraints { + $0.leading.equalTo(self.coinTitleEnglishLabel.snp.leading) + $0.top.equalTo(self.coinTitleEnglishLabel.snp.bottom) + } + } + } + func layoutCoinTotalPriceLabel() { + self.containerView.add(coinTotalPriceLabel) { + $0.snp.makeConstraints { + $0.trailing.equalTo(self.containerView.snp.trailing).offset(-10) + $0.centerY.equalTo(self.containerView.snp.centerY) + } + } + } + func layoutCoinFluctuationDegreeLabel() { + self.containerView.add(coinFluctuationDegreeLabel) { + $0.snp.makeConstraints { + $0.trailing.equalTo(self.coinTotalPriceLabel.snp.leading).offset(-24) + $0.centerY.equalTo(self.containerView.snp.centerY) + } + } + } + func layoutCoinCurrentPriceLabel() { + self.containerView.add(coinCurrentPriceLabel) { + $0.snp.makeConstraints { + $0.trailing.equalTo(self.coinFluctuationDegreeLabel.snp.leading).offset(-24) + $0.centerY.equalTo(self.containerView.snp.centerY) + } + } + } + func dataBind(coinLogoImageName: String, coinEnglishTitle: String, coinKoreanTitle: String, coinCurrentPrice: Float, riseOrDescent: String, percentage: Float, coinTotalPrice: Float) { + let formatter = NumberFormatter().then { + $0.numberStyle = .decimal + } + self.coinTitleLogoImageView.image = UIImage(named: coinLogoImageName) + self.coinTitleEnglishLabel.setLabel(text: coinEnglishTitle, textColor: .black, font: .notoSansKRBoldFont(fontSize: 14)) + self.coinTitleKoreanLabel.setLabel(text: coinKoreanTitle, textColor: .coinGray, font: .notoSansKRMediumFont(fontSize: 10)) + if riseOrDescent == "+" { + self.coinCurrentPriceLabel.setLabel(text: "\(formatter.string(from: NSNumber(value: coinCurrentPrice))!)", textColor: .textRed, font: .boldSystemFont(ofSize: 14)) + self.coinFluctuationDegreeLabel.setLabel(text: "\(riseOrDescent)\(percentage)%", textColor: .textRed, font: .systemFont(ofSize: 14, weight: .regular)) + } + else { + self.coinCurrentPriceLabel.setLabel(text: "\(formatter.string(from: NSNumber(value: coinCurrentPrice))!)", textColor: .mainBlue, font: .boldSystemFont(ofSize: 14)) + self.coinFluctuationDegreeLabel.setLabel(text: "\(riseOrDescent)\(percentage)%", textColor: .mainBlue, font: .systemFont(ofSize: 14, weight: .regular)) + } + self.coinTotalPriceLabel.setLabel(text: "\(formatter.string(from: NSNumber(value:coinTotalPrice))!)억", textColor: .coinGray, font: .systemFont(ofSize: 14, weight: .regular)) + } +} diff --git a/Coinone-iOS/Coinone-iOS/Source/Cells/FilterCollectionViewCell.swift b/Coinone-iOS/Coinone-iOS/Source/Cells/FilterCollectionViewCell.swift new file mode 100644 index 0000000..bf4a580 --- /dev/null +++ b/Coinone-iOS/Coinone-iOS/Source/Cells/FilterCollectionViewCell.swift @@ -0,0 +1,58 @@ +// +// FilterCollectionViewCell.swift +// Coinone-iOS +// +// Created by 노한솔 on 2021/05/20. +// +import SnapKit +import Then +import UIKit + +// MARK: - FilterCollectionViewCell +class FilterCollectionViewCell: UICollectionViewCell { + + // MARK: - Identifier + let identifier = "FilterCollectionViewCell" + + // MARK: - LifeCycles + override func awakeFromNib() { + super.awakeFromNib() + layout() + } + + // MARK: - Components + let filterTitleLabel = UILabel() + let filterButton = UIButton() +} +// MARK: - Extensions +extension FilterCollectionViewCell { + // MARK: - Helpers + func layout() { + self.contentView.layer.borderWidth = 1 + self.contentView.layer.borderColor = CGColor(red: 240/255, green: 240/255, blue: 240/255, alpha: 1) + layoutFilterLabel() + layoutFilterButton() + } + func layoutFilterLabel() { + self.contentView.add(filterTitleLabel) { + $0.snp.makeConstraints { + $0.leading.equalTo(self.contentView.snp.leading).offset(8) + $0.centerY.equalTo(self.contentView.snp.centerY) + } + } + } + func layoutFilterButton() { + self.contentView.add(filterButton) { + $0.setBackgroundImage(UIImage(named: "switch"), for: .normal) + $0.setBackgroundImage(UIImage(named: "switchDown"), for: .selected) + $0.snp.makeConstraints { + $0.trailing.equalTo(self.contentView.snp.trailing).offset(-6) + $0.centerY.equalTo(self.contentView.snp.centerY) + $0.top.equalTo(self.filterTitleLabel.snp.top) + } + } + } + func dataBind(title: String) { + self.filterTitleLabel.setLabel(text: title, textColor: .coinGray, font: .notoSansKRBoldFont(fontSize: 12)) + } +} diff --git a/Coinone-iOS/Coinone-iOS/Source/Models/CoinListModel.swift b/Coinone-iOS/Coinone-iOS/Source/Models/CoinListModel.swift new file mode 100644 index 0000000..c8792d9 --- /dev/null +++ b/Coinone-iOS/Coinone-iOS/Source/Models/CoinListModel.swift @@ -0,0 +1,19 @@ +// +// CoinListModel.swift +// Coinone-iOS +// +// Created by 노한솔 on 2021/05/20. +// + +import Foundation +import UIKit + +struct CoinListModel { + var coinLogoImageName: String + var coinEnglishTitle: String + var coinKoreanTitle: String + var coinCurrentPrice: Float + var riseOrDescent: String + var percentage: Float + var coinTotalPrice: Float +} diff --git a/Coinone-iOS/Coinone-iOS/Source/ReusableViews/CoinListCollectionReusableView.swift b/Coinone-iOS/Coinone-iOS/Source/ReusableViews/CoinListCollectionReusableView.swift new file mode 100644 index 0000000..11fb50f --- /dev/null +++ b/Coinone-iOS/Coinone-iOS/Source/ReusableViews/CoinListCollectionReusableView.swift @@ -0,0 +1,93 @@ +// +// CoinListCollectionReusableView.swift +// Coinone-iOS +// +// Created by 노한솔 on 2021/05/20. +// +import SnapKit +import Then +import UIKit + +// MARK: - CoinListCollectionReusableView +class CoinListCollectionReusableView: UICollectionReusableView { + + // MARK: - Identifier + let identifier = "CoinListCollectionReusableView" + + // MARK: - LifeCycles + override func awakeFromNib() { + super.awakeFromNib() + register() + layout() + self.coinListTableView.delegate = self + self.coinListTableView.dataSource = self + } + + // MARK: - Components + let coinListTableView = UITableView() + var coinModel: [CoinListModel] = [CoinListModel(coinLogoImageName: "coinLogo", + coinEnglishTitle: "XRP", + coinKoreanTitle: "리플", + coinCurrentPrice: 1625, + riseOrDescent: "-", + percentage: 0.37, + coinTotalPrice: 2059), + CoinListModel(coinLogoImageName: "coinLogo", + coinEnglishTitle: "XRP", + coinKoreanTitle: "리플", + coinCurrentPrice: 1625, + riseOrDescent: "-", + percentage: 0.37, + coinTotalPrice: 2059)] +} + +// MARK: - Extensions +extension CoinListCollectionReusableView { + func register() { + self.coinListTableView.register(CoinListTableViewCell.self, forCellReuseIdentifier: CoinListTableViewCell.identifier) + } + func layout() { + self.backgroundColor = .clear + layoutCoinListTableView() + } + func layoutCoinListTableView() { + self.add(coinListTableView) { + $0.estimatedRowHeight = 75 + $0.rowHeight = UITableView.automaticDimension + $0.backgroundColor = .tableViewGray + $0.separatorStyle = .none + $0.snp.makeConstraints { + $0.edges.equalToSuperview() + } + } + } +} + +extension CoinListCollectionReusableView: UITableViewDelegate { + func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { + return 75 + } +} + +extension CoinListCollectionReusableView: UITableViewDataSource { + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return self.coinModel.count + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + guard let coinListCell = tableView.dequeueReusableCell(withIdentifier: CoinListTableViewCell.identifier, for: indexPath) as? CoinListTableViewCell else { + return UITableViewCell() + } + coinListCell.dataBind(coinLogoImageName: self.coinModel[indexPath.row].coinLogoImageName, + coinEnglishTitle: self.coinModel[indexPath.row].coinEnglishTitle, + coinKoreanTitle: self.coinModel[indexPath.row].coinKoreanTitle, + coinCurrentPrice: self.coinModel[indexPath.row].coinCurrentPrice, + riseOrDescent: self.coinModel[indexPath.row].riseOrDescent, + percentage: self.coinModel[indexPath.row].percentage, + coinTotalPrice: self.coinModel[indexPath.row].coinTotalPrice) + coinListCell.awakeFromNib() + return coinListCell + } + + +} diff --git a/Coinone-iOS/Coinone-iOS/Source/ReusableViews/TitleCollectionReusableView.swift b/Coinone-iOS/Coinone-iOS/Source/ReusableViews/TitleCollectionReusableView.swift new file mode 100644 index 0000000..f1d5f78 --- /dev/null +++ b/Coinone-iOS/Coinone-iOS/Source/ReusableViews/TitleCollectionReusableView.swift @@ -0,0 +1,57 @@ +// +// TitleCollectionReusableView.swift +// Coinone-iOS +// +// Created by 노한솔 on 2021/05/20. +// +import SnapKit +import Then +import UIKit + +// MARK: - TitleCollectionReusableView +class TitleCollectionReusableView: UICollectionReusableView { + + // MARK: - Identifier + let identifier = "TitleCollectionReusableView" + + // MARK: - LifeCycles + override func awakeFromNib() { + super.awakeFromNib() + layout() + } + + // MARK: - Components + let logoImageView = UIImageView() + let searchButton = UIButton() +} + +// MARK: - Extensions +extension TitleCollectionReusableView { + + // MARK: - Helpers + func layout() { + layoutLogoImageView() + layoutSearchButton() + } + func layoutLogoImageView() { + self.add(logoImageView) { + $0.image = UIImage(named: "logoOnwhite") + $0.snp.makeConstraints { + $0.leading.equalTo(self.snp.leading).offset(20) + $0.centerY.equalTo(self.snp.centerY) + $0.width.equalTo(self.frame.width*98/375) + $0.height.equalTo(self.frame.width*19/375) + } + } + } + func layoutSearchButton() { + self.add(searchButton) { + $0.setBackgroundImage(UIImage(named: "searchOnwhite"), for: .normal) + $0.snp.makeConstraints { + $0.trailing.equalTo(self.snp.trailing).offset(-20) + $0.centerY.equalTo(self.snp.centerY) + $0.width.height.equalTo(self.frame.width*16/375) + } + } + } +} diff --git a/Coinone-iOS/Coinone-iOS/Source/ViewControllers/HomeViewController.swift b/Coinone-iOS/Coinone-iOS/Source/ViewControllers/HomeViewController.swift index 51a76a1..d08d449 100644 --- a/Coinone-iOS/Coinone-iOS/Source/ViewControllers/HomeViewController.swift +++ b/Coinone-iOS/Coinone-iOS/Source/ViewControllers/HomeViewController.swift @@ -81,6 +81,7 @@ class HomeViewController: UIViewController { graphImageName: "graph")] } + // MARK: - Extensions extension HomeViewController { // MARK: - Helpers @@ -339,7 +340,7 @@ extension HomeViewController: UITableViewDelegate { self.layoutFavoriteTableHeaderInputViews() return self.favoriteTableHeaderView } - + } // MARK: - UITableViewDataSource diff --git a/Coinone-iOS/Coinone-iOS/Source/ViewControllers/TransactionViewController.swift b/Coinone-iOS/Coinone-iOS/Source/ViewControllers/TransactionViewController.swift index b079e8d..8f19ef0 100644 --- a/Coinone-iOS/Coinone-iOS/Source/ViewControllers/TransactionViewController.swift +++ b/Coinone-iOS/Coinone-iOS/Source/ViewControllers/TransactionViewController.swift @@ -4,26 +4,182 @@ // // Created by 노한솔 on 2021/05/17. // - +import SnapKit +import Then import UIKit +// MARK: - TransactionViewController class TransactionViewController: UIViewController { + // MARK: - LifeCycles override func viewDidLoad() { super.viewDidLoad() + register() + layout() + self.contentCollectionView.delegate = self + self.contentCollectionView.dataSource = self + } + + // MARK: - Components + lazy var contentCollectionView: UICollectionView = { + let layout = UICollectionViewFlowLayout() + layout.scrollDirection = .vertical - // Do any additional setup after loading the view. + let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout) + collectionView.isScrollEnabled = true + collectionView.translatesAutoresizingMaskIntoConstraints = false + return collectionView + }() + + var menuTitles: [String] = ["마이", "거래소", "간편구매", "정보"] + var filterTitles: [String] = ["코인명", "현재가", "등락률", "거래대금"] +} + +// MARK: - Extensions +extension TransactionViewController { + + // MARK: - Helpers + func register() { + self.contentCollectionView.register(TopMenuCollectionViewCell.self, forCellWithReuseIdentifier: TopMenuCollectionViewCell.identifier) + self.contentCollectionView.register(FilterCollectionViewCell.self, forCellWithReuseIdentifier: FilterCollectionViewCell.identifier) + self.contentCollectionView.register(TitleCollectionReusableView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: TitleCollectionReusableView.identifier) + self.contentCollectionView.register(CoinListCollectionReusableView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionFooter, withReuseIdentifier: CoinListCollectionReusableView.identifier) + } + func layout() { + layoutConentCollectionView() + } + func layoutConentCollectionView() { + self.view.add(contentCollectionView) { + $0.backgroundColor = .white + $0.snp.makeConstraints { + $0.edges.equalToSuperview() + } + } + } +} +// MARK: - UICollectionViewDelegateFlowLayout +extension TransactionViewController: UICollectionViewDelegateFlowLayout { + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { + if indexPath.section == 0 { + let width: CGFloat + switch indexPath.item { + case 1: + width = 45 + case 2: + width = 60 + default: + width = 30 + } + return CGSize(width: width+self.view.frame.width*10/375, height: 30) + } + else { + let width: CGFloat + switch indexPath.item { + case 0: + width = 94 + case 1: + width = 94 + case 2: + width = 66 + default: + width = 70 + } + return CGSize(width: (self.view.frame.width-52)*width/323, height: 30) + } + } + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize { + if section == 0 { + return CGSize(width: self.view.frame.width, height: 40) + } + else { + return CGSize() + } + } + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize { + if section == 1 { + return CGSize(width: self.view.frame.width, height: 1000) + } + return CGSize() } + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { + if section == 1 { + return 4 + } + else { + return 8 + } + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { + return 8 + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { + return UIEdgeInsets(top: 0, left: 20, bottom: 16, right: 0) + } +} + +// MARK: - UICollectionViewDataSource +extension TransactionViewController: UICollectionViewDataSource { + func numberOfSections(in collectionView: UICollectionView) -> Int { + return 2 + } + + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + if section == 0 { + return self.menuTitles.count + } + else if section == 1 { + return self.filterTitles.count + } + else { + return 0 + } + } - /* - // MARK: - Navigation - - // In a storyboard-based application, you will often want to do a little preparation before navigation - override func prepare(for segue: UIStoryboardSegue, sender: Any?) { - // Get the new view controller using segue.destination. - // Pass the selected object to the new view controller. - } - */ + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + if indexPath.section == 0 { + guard let topMenuCell = collectionView.dequeueReusableCell(withReuseIdentifier: TopMenuCollectionViewCell.identifier, for: indexPath) as? TopMenuCollectionViewCell else { + return UICollectionViewCell() + } + topMenuCell.titleLabel.setLabel(text: self.menuTitles[indexPath.item], textColor: .textGray, font: .notoSansKRBoldFont(fontSize: 16)) + topMenuCell.awakeFromNib() + return topMenuCell + } + else if indexPath.section == 1 { + guard let filterCell = collectionView.dequeueReusableCell(withReuseIdentifier: FilterCollectionViewCell.identifier, for: indexPath) as? FilterCollectionViewCell else { + return UICollectionViewCell() + } + filterCell.dataBind(title: self.filterTitles[indexPath.item]) + filterCell.awakeFromNib() + return filterCell + } + else { + return UICollectionViewCell() + } + } + func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { + var reusableView = UICollectionReusableView() + if (kind == UICollectionView.elementKindSectionHeader) { + if indexPath.section == 0 { + guard let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: TitleCollectionReusableView.identifier, for: indexPath) as? TitleCollectionReusableView else { + return UICollectionReusableView() + } + headerView.awakeFromNib() + reusableView = headerView + } + } + else if (kind == UICollectionView.elementKindSectionFooter) { + if indexPath.section == 1 { + guard let footerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: CoinListCollectionReusableView.identifier, for: indexPath) as? CoinListCollectionReusableView else { + return UICollectionReusableView() + } + footerView.awakeFromNib() + reusableView = footerView + } + } + return reusableView + } } From 0bd7d97b489818eeb8bccf400dc9a96f92f770a4 Mon Sep 17 00:00:00 2001 From: pcsoyeon Date: Thu, 20 May 2021 23:59:50 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[FIX]=20=ED=95=84=ED=84=B0=EB=B2=84?= =?UTF-8?q?=ED=8A=BC=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Source/ViewControllers/GeoraesoVC.swift | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/Coinone-iOS/Coinone-iOS/Source/ViewControllers/GeoraesoVC.swift b/Coinone-iOS/Coinone-iOS/Source/ViewControllers/GeoraesoVC.swift index 0d47c04..beb8622 100644 --- a/Coinone-iOS/Coinone-iOS/Source/ViewControllers/GeoraesoVC.swift +++ b/Coinone-iOS/Coinone-iOS/Source/ViewControllers/GeoraesoVC.swift @@ -212,7 +212,6 @@ class GeoraesoVC: UIViewController { weight: .light, scale: .large), forImageIn: .normal) - button.addTarget(self, action: #selector(touchUpFilterButton), for: .touchUpInside) return button }() @@ -410,15 +409,6 @@ extension GeoraesoVC { } -// MARK: - Action -extension GeoraesoVC { - @objc func touchUpFilterButton() { - print("touchUp transPrice Filter Button") - self.stockList = self.stockList.sorted(by: { $0.transPrice > $1.transPrice }) - self.tableView.reloadData() - } -} - // MARK: - TableViewDelegate extension GeoraesoVC: UITableViewDelegate { func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {