Skip to content

Commit

Permalink
[feat] 유효성 검사 유사성 테이블뷰 구현 (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaewift committed Nov 7, 2024
1 parent 0d32924 commit f5f8aaf
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 25 deletions.
2 changes: 1 addition & 1 deletion PLUV/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
class SceneDelegate: UIResponder, UIWindowSceneDelegate {

var window: UIWindow?
var LoginVC = UINavigationController(rootViewController: LoginViewController())
var LoginVC = UINavigationController(rootViewController: ValidationSimilarViewController())
lazy var SpotifyVC = TransferCheckViewController()

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
Expand Down
14 changes: 6 additions & 8 deletions PLUV/Validation/Cell/MoreButtonTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class MoreButtonTableViewCell: UITableViewCell {
$0.backgroundColor = .clear
$0.layer.borderColor = UIColor.gray200.cgColor
$0.layer.borderWidth = 1.0
$0.layer.cornerRadius = 8
}
private let moreLabel = UILabel().then {
$0.text = "항목 더보기"
Expand All @@ -26,22 +27,19 @@ class MoreButtonTableViewCell: UITableViewCell {
}

override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
super.init(style: style, reuseIdentifier: reuseIdentifier)
setUI()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override func layoutSubviews() {
setUI()
fatalError("init(coder:) has not been implemented")
}

private func setUI() {
self.contentView.addSubview(barView)
barView.snp.makeConstraints { make in
make.top.equalToSuperview().offset(8)
make.leading.trailing.equalToSuperview().offset(24)
make.leading.trailing.equalToSuperview().inset(24)
make.centerX.equalToSuperview()
make.height.equalTo(38)
}
Expand Down
18 changes: 9 additions & 9 deletions PLUV/Validation/Cell/SimilarSongsTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@ class SimilarSongsTableViewCell: UITableViewCell {
$0.backgroundColor = .gray200
}
private let thumbnailImageView = UIImageView().then {
$0.image = UIImage(named: "applemusic_icon")
$0.layer.cornerRadius = 8
$0.clipsToBounds = true
}
private let songTitleLabel = UILabel().then {
$0.text = "원곡"
$0.textColor = .gray800
$0.font = .systemFont(ofSize: 16, weight: .medium)
}
private let singerLabel = UILabel().then {
$0.text = "원곡"
$0.textColor = .gray600
$0.font = .systemFont(ofSize: 14, weight: .regular)
}
Expand All @@ -31,15 +34,12 @@ class SimilarSongsTableViewCell: UITableViewCell {
}

override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
super.init(style: style, reuseIdentifier: reuseIdentifier)
setUI()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override func layoutSubviews() {
setUI()
fatalError("init(coder:) has not been implemented")
}

private func setUI() {
Expand All @@ -55,7 +55,7 @@ class SimilarSongsTableViewCell: UITableViewCell {
thumbnailImageView.snp.makeConstraints { make in
make.leading.equalTo(barView.snp.trailing).offset(8)
make.centerY.equalToSuperview()
make.width.height.equalTo(50)
make.width.height.equalTo(38)
}

self.contentView.addSubview(songTitleLabel)
Expand All @@ -74,7 +74,7 @@ class SimilarSongsTableViewCell: UITableViewCell {

self.contentView.addSubview(checkIcon)
checkIcon.snp.makeConstraints { make in
make.trailing.equalToSuperview().offset(24)
make.trailing.equalToSuperview().inset(24)
make.centerY.equalToSuperview()
make.height.width.equalTo(16)
}
Expand Down
10 changes: 5 additions & 5 deletions PLUV/Validation/Cell/ValidationSimilarTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class ValidationSimilarTableViewCell: UITableViewCell {
static let identifier = String(describing: ValidationSimilarTableViewCell.self)

private let thumbnailImageView = UIImageView().then {
$0.image = UIImage(named: "applemusic_icon")
$0.layer.cornerRadius = 8
$0.clipsToBounds = true
}
Expand All @@ -34,26 +35,25 @@ class ValidationSimilarTableViewCell: UITableViewCell {
$0.textColor = .white
}
private let songTitleLabel = UILabel().then {
$0.text = "원곡"
$0.textColor = .gray800
$0.font = .systemFont(ofSize: 16, weight: .medium)
}
private let singerLabel = UILabel().then {
$0.text = "원곡"
$0.textColor = .gray600
$0.font = .systemFont(ofSize: 14, weight: .regular)
}

override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setUI()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override func layoutSubviews() {
setUI()
}

private func setUI() {
self.contentView.addSubview(thumbnailImageView)
thumbnailImageView.snp.makeConstraints { make in
Expand Down
29 changes: 27 additions & 2 deletions PLUV/Validation/ValidationSimilarViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ class ValidationSimilarViewController: UIViewController {
super.viewDidLoad()

setUI()

similarMusicTableView.delegate = self
similarMusicTableView.dataSource = self
}

private func setUI() {
Expand Down Expand Up @@ -159,11 +162,33 @@ class ValidationSimilarViewController: UIViewController {
}
}

extension ValidationSimilarViewController: UITableViewDelegate {
extension ValidationSimilarViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 3
return 9
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
switch indexPath.row % 3 { // 셀을 3개의 유형으로 나눠서 사용
case 0:
guard let cell = tableView.dequeueReusableCell(withIdentifier: ValidationSimilarTableViewCell.identifier, for: indexPath) as? ValidationSimilarTableViewCell else {
return UITableViewCell()
}
return cell

case 1:
guard let cell = tableView.dequeueReusableCell(withIdentifier: SimilarSongsTableViewCell.identifier, for: indexPath) as? SimilarSongsTableViewCell else {
return UITableViewCell()
}
return cell

default:
guard let cell = tableView.dequeueReusableCell(withIdentifier: MoreButtonTableViewCell.identifier, for: indexPath) as? MoreButtonTableViewCell else {
return UITableViewCell()
}
return cell
}
}

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
switch indexPath.row % 3 {
case 0:
Expand Down

0 comments on commit f5f8aaf

Please sign in to comment.