From 9432a006b51ebd93f8fe80c2f6025d3299a8c248 Mon Sep 17 00:00:00 2001 From: hyesuuou <68391767+hyesuuou@users.noreply.github.com> Date: Tue, 14 Sep 2021 17:56:33 +0900 Subject: [PATCH] =?UTF-8?q?[#2]DetailVC=20=ED=95=98=EB=8B=A8=20tableview?= =?UTF-8?q?=20UI=EA=B5=AC=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AppleContacts.xcodeproj/project.pbxproj | 40 ++++ .../Source/Detail/Cell/DetailButtonTVC.swift | 30 +++ .../Detail/Cell/DetailFacetimeTVC.swift | 25 +++ .../Source/Detail/Cell/DetailMemoTVC.swift | 25 +++ .../Source/Detail/Cell/DetailNumberTVC.swift | 25 +++ .../Source/Detail/Detail.storyboard | 195 ++++++++++++++++++ .../Source/Detail/DetailVC.swift | 93 +++++++++ .../Source/Main/Base.lproj/Main.storyboard | 21 +- .../AppleContacts/Source/Main/MainVC.swift | 5 + 9 files changed, 458 insertions(+), 1 deletion(-) create mode 100644 AppleContacts/AppleContacts/Source/Detail/Cell/DetailButtonTVC.swift create mode 100644 AppleContacts/AppleContacts/Source/Detail/Cell/DetailFacetimeTVC.swift create mode 100644 AppleContacts/AppleContacts/Source/Detail/Cell/DetailMemoTVC.swift create mode 100644 AppleContacts/AppleContacts/Source/Detail/Cell/DetailNumberTVC.swift create mode 100644 AppleContacts/AppleContacts/Source/Detail/Detail.storyboard create mode 100644 AppleContacts/AppleContacts/Source/Detail/DetailVC.swift diff --git a/AppleContacts/AppleContacts.xcodeproj/project.pbxproj b/AppleContacts/AppleContacts.xcodeproj/project.pbxproj index 2226fff..83cd6a3 100644 --- a/AppleContacts/AppleContacts.xcodeproj/project.pbxproj +++ b/AppleContacts/AppleContacts.xcodeproj/project.pbxproj @@ -7,6 +7,12 @@ objects = { /* Begin PBXBuildFile section */ + 15744FAE26F08ABB00B44B4E /* Detail.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 15744FAD26F08ABB00B44B4E /* Detail.storyboard */; }; + 15744FB026F08AC900B44B4E /* DetailVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15744FAF26F08AC900B44B4E /* DetailVC.swift */; }; + 15744FB326F0918D00B44B4E /* DetailButtonTVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15744FB226F0918D00B44B4E /* DetailButtonTVC.swift */; }; + 15744FB526F096F200B44B4E /* DetailNumberTVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15744FB426F096F200B44B4E /* DetailNumberTVC.swift */; }; + 15744FB726F0986F00B44B4E /* DetailFacetimeTVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15744FB626F0986F00B44B4E /* DetailFacetimeTVC.swift */; }; + 15744FB926F09A6D00B44B4E /* DetailMemoTVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15744FB826F09A6D00B44B4E /* DetailMemoTVC.swift */; }; 15A3B50526EE147B00A57ADD /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15A3B50426EE147B00A57ADD /* AppDelegate.swift */; }; 15A3B50726EE147B00A57ADD /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15A3B50626EE147B00A57ADD /* SceneDelegate.swift */; }; 15A3B50C26EE147B00A57ADD /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 15A3B50A26EE147B00A57ADD /* Main.storyboard */; }; @@ -25,6 +31,12 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 15744FAD26F08ABB00B44B4E /* Detail.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Detail.storyboard; sourceTree = ""; }; + 15744FAF26F08AC900B44B4E /* DetailVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailVC.swift; sourceTree = ""; }; + 15744FB226F0918D00B44B4E /* DetailButtonTVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailButtonTVC.swift; sourceTree = ""; }; + 15744FB426F096F200B44B4E /* DetailNumberTVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailNumberTVC.swift; sourceTree = ""; }; + 15744FB626F0986F00B44B4E /* DetailFacetimeTVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailFacetimeTVC.swift; sourceTree = ""; }; + 15744FB826F09A6D00B44B4E /* DetailMemoTVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailMemoTVC.swift; sourceTree = ""; }; 15A3B50126EE147B00A57ADD /* AppleContacts.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AppleContacts.app; sourceTree = BUILT_PRODUCTS_DIR; }; 15A3B50426EE147B00A57ADD /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 15A3B50626EE147B00A57ADD /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; @@ -55,6 +67,27 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 15744FAC26F08AA800B44B4E /* Detail */ = { + isa = PBXGroup; + children = ( + 15744FB126F0917500B44B4E /* Cell */, + 15744FAD26F08ABB00B44B4E /* Detail.storyboard */, + 15744FAF26F08AC900B44B4E /* DetailVC.swift */, + ); + path = Detail; + sourceTree = ""; + }; + 15744FB126F0917500B44B4E /* Cell */ = { + isa = PBXGroup; + children = ( + 15744FB226F0918D00B44B4E /* DetailButtonTVC.swift */, + 15744FB426F096F200B44B4E /* DetailNumberTVC.swift */, + 15744FB626F0986F00B44B4E /* DetailFacetimeTVC.swift */, + 15744FB826F09A6D00B44B4E /* DetailMemoTVC.swift */, + ); + path = Cell; + sourceTree = ""; + }; 15A3B4F826EE147A00A57ADD = { isa = PBXGroup; children = ( @@ -97,6 +130,7 @@ isa = PBXGroup; children = ( 15A3B51D26EE149800A57ADD /* Main */, + 15744FAC26F08AA800B44B4E /* Detail */, 15A3B52326EE1E9900A57ADD /* AddContact */, 15A3B52D26EF197000A57ADD /* Group */, ); @@ -220,6 +254,7 @@ 15A3B51126EE147B00A57ADD /* Assets.xcassets in Resources */, 15A3B50C26EE147B00A57ADD /* Main.storyboard in Resources */, 15A3B52F26EF198500A57ADD /* Group.storyboard in Resources */, + 15744FAE26F08ABB00B44B4E /* Detail.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -230,15 +265,20 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 15744FB326F0918D00B44B4E /* DetailButtonTVC.swift in Sources */, 15A3B50526EE147B00A57ADD /* AppDelegate.swift in Sources */, 15A3B52726EE1ECE00A57ADD /* AddContactVC.swift in Sources */, + 15744FB026F08AC900B44B4E /* DetailVC.swift in Sources */, 15A3B52C26EF16DF00A57ADD /* AddInputTVC.swift in Sources */, + 15744FB526F096F200B44B4E /* DetailNumberTVC.swift in Sources */, 15A3B53426EF1C1000A57ADD /* GroupTVC.swift in Sources */, 15A3B53126EF199500A57ADD /* GroupVC.swift in Sources */, + 15744FB726F0986F00B44B4E /* DetailFacetimeTVC.swift in Sources */, 15A3B52A26EE55E100A57ADD /* AddPhotoTVC.swift in Sources */, 15A3B51F26EE16B900A57ADD /* MainVC.swift in Sources */, 15A3B52226EE19F000A57ADD /* MainNameTVC.swift in Sources */, 15A3B50726EE147B00A57ADD /* SceneDelegate.swift in Sources */, + 15744FB926F09A6D00B44B4E /* DetailMemoTVC.swift in Sources */, 15A3B50F26EE147B00A57ADD /* AppleContacts.xcdatamodeld in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/AppleContacts/AppleContacts/Source/Detail/Cell/DetailButtonTVC.swift b/AppleContacts/AppleContacts/Source/Detail/Cell/DetailButtonTVC.swift new file mode 100644 index 0000000..32b0a47 --- /dev/null +++ b/AppleContacts/AppleContacts/Source/Detail/Cell/DetailButtonTVC.swift @@ -0,0 +1,30 @@ +// +// DetailButtonTVC.swift +// AppleContacts +// +// Created by 김혜수 on 2021/09/14. +// + +import UIKit + +class DetailButtonTVC: UITableViewCell { + + public static let identifier = "DetailButtonTVC" + + @IBOutlet weak var label: UILabel! + override func awakeFromNib() { + super.awakeFromNib() + // Initialization code + } + + override func setSelected(_ selected: Bool, animated: Bool) { + super.setSelected(selected, animated: animated) + + // Configure the view for the selected state + } + + func setData(title: String){ + label.text = title + } + +} diff --git a/AppleContacts/AppleContacts/Source/Detail/Cell/DetailFacetimeTVC.swift b/AppleContacts/AppleContacts/Source/Detail/Cell/DetailFacetimeTVC.swift new file mode 100644 index 0000000..0ec15cb --- /dev/null +++ b/AppleContacts/AppleContacts/Source/Detail/Cell/DetailFacetimeTVC.swift @@ -0,0 +1,25 @@ +// +// DetailFacetimeTVC.swift +// AppleContacts +// +// Created by 김혜수 on 2021/09/14. +// + +import UIKit + +class DetailFacetimeTVC: UITableViewCell { + + public static let identifier = "DetailFacetimeTVC" + + override func awakeFromNib() { + super.awakeFromNib() + // Initialization code + } + + override func setSelected(_ selected: Bool, animated: Bool) { + super.setSelected(selected, animated: animated) + + // Configure the view for the selected state + } + +} diff --git a/AppleContacts/AppleContacts/Source/Detail/Cell/DetailMemoTVC.swift b/AppleContacts/AppleContacts/Source/Detail/Cell/DetailMemoTVC.swift new file mode 100644 index 0000000..91e998c --- /dev/null +++ b/AppleContacts/AppleContacts/Source/Detail/Cell/DetailMemoTVC.swift @@ -0,0 +1,25 @@ +// +// DetailMemoTVC.swift +// AppleContacts +// +// Created by 김혜수 on 2021/09/14. +// + +import UIKit + +class DetailMemoTVC: UITableViewCell { + + public static let identifier = "DetailMemoTVC" + + override func awakeFromNib() { + super.awakeFromNib() + // Initialization code + } + + override func setSelected(_ selected: Bool, animated: Bool) { + super.setSelected(selected, animated: animated) + + // Configure the view for the selected state + } + +} diff --git a/AppleContacts/AppleContacts/Source/Detail/Cell/DetailNumberTVC.swift b/AppleContacts/AppleContacts/Source/Detail/Cell/DetailNumberTVC.swift new file mode 100644 index 0000000..f253716 --- /dev/null +++ b/AppleContacts/AppleContacts/Source/Detail/Cell/DetailNumberTVC.swift @@ -0,0 +1,25 @@ +// +// DetailNumberTVC.swift +// AppleContacts +// +// Created by 김혜수 on 2021/09/14. +// + +import UIKit + +class DetailNumberTVC: UITableViewCell { + + public static let identifier = "DetailNumberTVC" + + override func awakeFromNib() { + super.awakeFromNib() + // Initialization code + } + + override func setSelected(_ selected: Bool, animated: Bool) { + super.setSelected(selected, animated: animated) + + // Configure the view for the selected state + } + +} diff --git a/AppleContacts/AppleContacts/Source/Detail/Detail.storyboard b/AppleContacts/AppleContacts/Source/Detail/Detail.storyboard new file mode 100644 index 0000000..c35af42 --- /dev/null +++ b/AppleContacts/AppleContacts/Source/Detail/Detail.storyboard @@ -0,0 +1,195 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AppleContacts/AppleContacts/Source/Detail/DetailVC.swift b/AppleContacts/AppleContacts/Source/Detail/DetailVC.swift new file mode 100644 index 0000000..fcd7302 --- /dev/null +++ b/AppleContacts/AppleContacts/Source/Detail/DetailVC.swift @@ -0,0 +1,93 @@ +// +// DetailVC.swift +// AppleContacts +// +// Created by 김혜수 on 2021/09/14. +// + +import UIKit + +class DetailVC: UIViewController { + + @IBOutlet weak var tableview: UITableView! + + override func viewDidLoad() { + super.viewDidLoad() + setTableview() + // Do any additional setup after loading the view. + } + + // MARK: - setTableview + func setTableview(){ + tableview.delegate = self + tableview.dataSource = self + } + + + + +} + +extension DetailVC: UITableViewDelegate { + +} + +extension DetailVC: UITableViewDataSource { + + func numberOfSections(in tableView: UITableView) -> Int { + return 5 + } + + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + switch section { + case 0, 1, 4, 2: + return 1 + case 3: + return 3 + default: + return 0 + } + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + switch indexPath.section { + case 0: + guard let cell = tableView.dequeueReusableCell(withIdentifier: DetailNumberTVC.identifier) as? DetailNumberTVC else { return UITableViewCell()} + return cell + + case 1: + guard let cell = tableView.dequeueReusableCell(withIdentifier: DetailFacetimeTVC.identifier) as? DetailFacetimeTVC else { return UITableViewCell()} + return cell + + case 2: + guard let cell = tableView.dequeueReusableCell(withIdentifier: DetailMemoTVC.identifier) as? DetailMemoTVC else { return UITableViewCell() } + return cell + + case 3: + let data = ["메시지 보내기", "연락처 공유", "즐겨찾기에 추가"] + guard let cell = tableView.dequeueReusableCell(withIdentifier: DetailButtonTVC.identifier) as? DetailButtonTVC else { return UITableViewCell() } + cell.setData(title: data[indexPath.row]) + return cell + case 4: + guard let cell = tableView.dequeueReusableCell(withIdentifier: DetailButtonTVC.identifier) as? DetailButtonTVC else { return UITableViewCell() } + cell.setData(title: "긴급 연락처에 추가") + return cell + default: + return UITableViewCell() + } + } + + func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { + switch indexPath.section { + case 0,1: + return 60 + case 2: + return 70 + case 3,4 : + return 40 + default: + return 100 + } + } + +} diff --git a/AppleContacts/AppleContacts/Source/Main/Base.lproj/Main.storyboard b/AppleContacts/AppleContacts/Source/Main/Base.lproj/Main.storyboard index 189239b..4bdabea 100644 --- a/AppleContacts/AppleContacts/Source/Main/Base.lproj/Main.storyboard +++ b/AppleContacts/AppleContacts/Source/Main/Base.lproj/Main.storyboard @@ -1,5 +1,5 @@ - + @@ -137,6 +137,7 @@ + @@ -145,6 +146,24 @@ + + + + + + + + + + + + + + + + + + diff --git a/AppleContacts/AppleContacts/Source/Main/MainVC.swift b/AppleContacts/AppleContacts/Source/Main/MainVC.swift index 95a3a86..9d0af8f 100644 --- a/AppleContacts/AppleContacts/Source/Main/MainVC.swift +++ b/AppleContacts/AppleContacts/Source/Main/MainVC.swift @@ -61,6 +61,11 @@ extension MainVC: UITableViewDelegate { func sectionIndexTitles(for tableView: UITableView) -> [String]? { return sectionList } + + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + guard let detailVC = UIStoryboard(name: "Detail", bundle: nil).instantiateViewController(withIdentifier: "DetailVC") as? DetailVC else { return } + self.navigationController?.pushViewController(detailVC, animated: true) + } } extension MainVC: UITableViewDataSource {