-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
224 additions
and
0 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
CheoMooRac/CheoMooRac/Sources/Cells/TextFieldTableViewCell.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// | ||
// TextFieldTableViewCell.swift | ||
// CheoMooRac | ||
// | ||
// Created by 김윤서 on 2021/09/14. | ||
// | ||
|
||
import UIKit | ||
|
||
class TextFieldTableViewCell: UITableViewCell,Reusable { | ||
|
||
private let textField = UITextField().then { | ||
$0.borderStyle = .none | ||
$0.textColor = .systemRed | ||
} | ||
|
||
|
||
private let seperatorView = UIView().then { | ||
$0.backgroundColor = .systemGray5 | ||
} | ||
|
||
public var placeholder: String? { | ||
didSet{ | ||
textField.placeholder = placeholder | ||
} | ||
} | ||
|
||
public var delegate: UITextFieldDelegate? { | ||
didSet{ | ||
textField.delegate = delegate | ||
} | ||
} | ||
|
||
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { | ||
super.init(style: style, reuseIdentifier: reuseIdentifier) | ||
setLayouts() | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
private func setLayouts() { | ||
setViewHierarchy() | ||
setConstraints() | ||
} | ||
|
||
private func setViewHierarchy() { | ||
contentView.addSubviews(textField, seperatorView) | ||
} | ||
|
||
private func setConstraints() { | ||
textField.snp.makeConstraints { | ||
$0.leading.trailing.equalToSuperview().inset(20) | ||
$0.top.bottom.equalToSuperview() | ||
} | ||
|
||
seperatorView.snp.makeConstraints { | ||
$0.height.equalTo(1) | ||
$0.leading.equalToSuperview().inset(20) | ||
$0.trailing.equalToSuperview() | ||
$0.bottom.equalToSuperview() | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
CheoMooRac/CheoMooRac/Sources/Headers/ProfileHeaderView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// | ||
// ProfileHeaderView.swift | ||
// CheoMooRac | ||
// | ||
// Created by 김윤서 on 2021/09/14. | ||
// | ||
|
||
import UIKit | ||
|
||
class ProfileHeaderView: UITableViewHeaderFooterView, Reusable { | ||
|
||
private let profileButton = UIButton().then { | ||
$0.setBackgroundColor(.black, for: .normal) | ||
$0.clipsToBounds = true | ||
} | ||
|
||
override init(reuseIdentifier: String?) { | ||
super.init(reuseIdentifier: reuseIdentifier) | ||
setLayouts() | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("coder doesn't exist") | ||
} | ||
|
||
private func setLayouts() { | ||
setViewHierarchy() | ||
setConstraints() | ||
} | ||
|
||
private func setViewHierarchy() { | ||
contentView.addSubview(profileButton) | ||
} | ||
|
||
private func setConstraints() { | ||
|
||
profileButton.snp.makeConstraints { | ||
$0.width.height.equalTo(100) | ||
$0.centerX.equalToSuperview() | ||
$0.centerY.equalToSuperview() | ||
} | ||
|
||
profileButton.layer.cornerRadius = 50 | ||
|
||
|
||
} | ||
|
||
} |
111 changes: 111 additions & 0 deletions
111
CheoMooRac/CheoMooRac/Sources/ViewControllers/CreateViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
// | ||
// CreateViewController.swift | ||
// CheoMooRac | ||
// | ||
// Created by 김윤서 on 2021/09/14. | ||
// | ||
|
||
import UIKit | ||
|
||
class CreateViewController: UIViewController { | ||
|
||
private let tableView = UITableView().then { | ||
$0.sectionHeaderHeight = 140 | ||
$0.rowHeight = 40 | ||
$0.separatorStyle = .none | ||
} | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
setNavigationBar() | ||
setTableView() | ||
|
||
setLayouts() | ||
} | ||
|
||
override func viewDidLayoutSubviews() { | ||
super.viewDidLayoutSubviews() | ||
navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default) | ||
navigationController?.navigationBar.shadowImage = UIImage() | ||
navigationController?.navigationBar.backgroundColor = .systemGray5 | ||
} | ||
|
||
private func setTableView() { | ||
tableView.delegate = self | ||
tableView.dataSource = self | ||
|
||
tableView.registerReusableHeaderFooterView(ProfileHeaderView.self) | ||
tableView.registerReusableCell(TextFieldTableViewCell.self) | ||
} | ||
|
||
|
||
private func setNavigationBar() { | ||
title = "새로운 연락처" | ||
|
||
navigationItem.leftBarButtonItem = UIBarButtonItem(title: "취소", style: .plain, target: self, action: #selector(cancelButtonDidTapped)) | ||
navigationItem.rightBarButtonItem = UIBarButtonItem(title: "완료", style: .plain, target: self, action: #selector(completeButtonDidTapped)) | ||
} | ||
|
||
private func setLayouts() { | ||
setViewHierarchy() | ||
setConstraints() | ||
} | ||
|
||
private func setViewHierarchy() { | ||
view.addSubview(tableView) | ||
} | ||
|
||
private func setConstraints() { | ||
tableView.snp.makeConstraints { | ||
$0.edges.equalToSuperview() | ||
} | ||
} | ||
} | ||
|
||
extension CreateViewController { | ||
@objc | ||
func cancelButtonDidTapped(){ | ||
dismiss(animated: true, completion: nil) | ||
} | ||
|
||
@objc | ||
func completeButtonDidTapped(){ | ||
dismiss(animated: true, completion: nil) | ||
} | ||
} | ||
|
||
extension CreateViewController: UITableViewDelegate { | ||
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { | ||
switch section { | ||
case 0: | ||
let header = tableView.dequeueReusableHeaderFooterView() as ProfileHeaderView | ||
return header | ||
default: | ||
return nil | ||
} | ||
} | ||
} | ||
|
||
extension CreateViewController: UITableViewDataSource { | ||
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | ||
return 3 | ||
} | ||
|
||
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | ||
switch indexPath.section { | ||
case 0: | ||
let cell = tableView.dequeueReusableCell(indexPath: indexPath) as TextFieldTableViewCell | ||
cell.placeholder = "성" | ||
cell.delegate = self | ||
return cell | ||
default: | ||
return UITableViewCell() | ||
} | ||
} | ||
|
||
} | ||
|
||
extension CreateViewController: UITextFieldDelegate { | ||
|
||
} |