From 301d9c15e08ebdfc5e37990ec405f67827a56ab9 Mon Sep 17 00:00:00 2001 From: 0gonge Date: Fri, 18 Oct 2024 20:34:08 +0900 Subject: [PATCH 1/7] =?UTF-8?q?style:=20segmentView=EC=88=98=EC=A0=95,=20?= =?UTF-8?q?=EB=B6=88=ED=95=84=EC=9A=94=20=ED=8C=8C=EC=9D=BC=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0(#159)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/ProfileViewController.swift | 11 +- .../View/ProfileSegmentControllView.swift | 11 +- .../MyProfile/View/TasteDataView.swift | 70 ------------ .../Sources/MyProfile/View/TasteView.swift | 103 ------------------ 4 files changed, 11 insertions(+), 184 deletions(-) delete mode 100644 Presentation/Sources/MyProfile/View/TasteDataView.swift delete mode 100644 Presentation/Sources/MyProfile/View/TasteView.swift diff --git a/Presentation/Sources/MyProfile/Controller/ProfileViewController.swift b/Presentation/Sources/MyProfile/Controller/ProfileViewController.swift index d649c84..26ccf6b 100644 --- a/Presentation/Sources/MyProfile/Controller/ProfileViewController.swift +++ b/Presentation/Sources/MyProfile/Controller/ProfileViewController.swift @@ -93,9 +93,14 @@ public class ProfileViewController: UIViewController { } segmentControlView.snp.makeConstraints { - $0.top.equalTo(profileInfoView.snp.bottom).offset(35.adaptiveHeight) - $0.horizontalEdges.equalToSuperview() - $0.height.equalTo(40.adaptiveHeight) +// $0.top.equalTo(profileInfoView.snp.bottom).offset(35.adaptiveHeight) +// $0.horizontalEdges.equalToSuperview() +// $0.height.equalTo(40.adaptiveHeight) + + $0.top.equalTo(profileInfoView.snp.bottom).offset(32) + $0.horizontalEdges.equalToSuperview().inset(20) +// $0.trailing.equalToSuperview().inset(20) + $0.height.equalTo(34) } myRecordView.snp.makeConstraints { diff --git a/Presentation/Sources/MyProfile/View/ProfileSegmentControllView.swift b/Presentation/Sources/MyProfile/View/ProfileSegmentControllView.swift index 378156b..00071f9 100644 --- a/Presentation/Sources/MyProfile/View/ProfileSegmentControllView.swift +++ b/Presentation/Sources/MyProfile/View/ProfileSegmentControllView.swift @@ -21,7 +21,6 @@ public final class ProfileSegmentControllView: UIView { private var selectedTab: ControlType = .record { didSet { setStyle() - setTabUI() } } weak var delegate: ControlTypeDelegate? @@ -64,8 +63,8 @@ public final class ProfileSegmentControllView: UIView { private func setStyle() { barStack.do { $0.axis = .horizontal - $0.spacing = 50.adaptiveWidth - $0.distribution = .equalSpacing + $0.spacing = 11.adaptiveWidth + $0.distribution = .fillEqually } recordButton.do { @@ -86,7 +85,7 @@ public final class ProfileSegmentControllView: UIView { private func setAutoLayout() { barStack.snp.makeConstraints { $0.centerX.equalToSuperview() - $0.verticalEdges.equalToSuperview() + $0.horizontalEdges.equalToSuperview() } } @@ -95,10 +94,6 @@ public final class ProfileSegmentControllView: UIView { bookmarkButton.addAction(tapAction, for: .touchUpInside) } - private func setTabUI() { - // 선택된 탭에 따라 다른 뷰를 표시 - } - private func applySelectUI(to button: UIButton, type: ControlType) { guard let text = button.titleLabel?.text else { return } diff --git a/Presentation/Sources/MyProfile/View/TasteDataView.swift b/Presentation/Sources/MyProfile/View/TasteDataView.swift deleted file mode 100644 index d9dc58d..0000000 --- a/Presentation/Sources/MyProfile/View/TasteDataView.swift +++ /dev/null @@ -1,70 +0,0 @@ -//// -//// TasteDataView.swift -//// Presentation -//// -//// Created by 송여경 on 7/15/24. -//// Copyright © 2024 com.recordy. All rights reserved. -//// setStyle() -> setUI() -> setAutolayout() -// -//import UIKit -//import SnapKit -// -//import Core -//import Common -// -//class TasteDataView: UIView { -// -// private let titleLabel = UILabel() -// private let percentageLabel = UILabel() -// private let tasteData: TasteData -// -// public init( -// frame: CGRect = .zero, -// tasteData: TasteData -// ) { -// self.tasteData = tasteData -// super.init( -// frame: frame -// ) -// configure(with: tasteData) -// setUI() -// setStyle() -// setAutolayout() -// } -// -// required init?(coder: NSCoder) { -// fatalError("init(coder:) has not been implemented") -// } -// -// private func setUI() { -// addSubview(titleLabel) -// addSubview(percentageLabel) -// } -// -// private func setStyle() { -// titleLabel.font = tasteData.type.title -// titleLabel.textColor = .white -// titleLabel.textAlignment = .center -// -// percentageLabel.font = tasteData.type.subtitle -// percentageLabel.textColor = .white -// percentageLabel.textAlignment = .center -// } -// -// private func setAutolayout() { -// titleLabel.snp.makeConstraints { -// $0.centerX.equalToSuperview() -// $0.centerY.equalToSuperview().offset(-10) -// } -// -// percentageLabel.snp.makeConstraints { -// $0.centerX.equalToSuperview() -// $0.top.equalTo(titleLabel.snp.bottom).offset(4) -// } -// } -// -// func configure(with data: TasteData) { -// titleLabel.text = data.title -// percentageLabel.text = "\(data.percentage)%" -// } -//} diff --git a/Presentation/Sources/MyProfile/View/TasteView.swift b/Presentation/Sources/MyProfile/View/TasteView.swift deleted file mode 100644 index fd5b7d9..0000000 --- a/Presentation/Sources/MyProfile/View/TasteView.swift +++ /dev/null @@ -1,103 +0,0 @@ -//// -//// TasteView.swift -//// Presentation -//// -//// Created by 송여경 on 7/15/24. -//// Copyright © 2024 com.recordy. All rights reserved. -//// setStyle() -> setUI() -> setAutoLayout() -// -//import UIKit -//import SnapKit -//import Then -// -//import Common -//import Core -// -//class TasteView: UIView { -// -// private let gradientImageView = UIImageView() -// private let dataView = UIView() -// private let backgroundImageView = UIImageView() -// -// override init(frame: CGRect) { -// super.init(frame: frame) -// setStyle() -// setUI() -// setAutoLayout() -// } -// -// required init?(coder: NSCoder) { -// fatalError("init(coder:) has not been implemented") -// } -// -// private func setStyle() { -// self.backgroundColor = .black -// gradientImageView.do { -// $0.image = CommonAsset.gradientImage.image -// $0.contentMode = .scaleAspectFit -// } -// backgroundImageView.do { -// $0.image = CommonAsset.bubbleBackImg.image -// $0.contentMode = .scaleAspectFit -// } -// } -// -// private func setUI() { -// self.addSubview(gradientImageView) -// self.addSubview(backgroundImageView) -// } -// -// private func setAutoLayout() { -// gradientImageView.snp.makeConstraints { -// $0.edges.equalTo(self.safeAreaLayoutGuide) -// } -// -// backgroundImageView.snp.makeConstraints { -// $0.top.horizontalEdges.equalToSuperview() -// $0.bottom.equalToSuperview().inset(140) -// } -// } -// -// func updateDataViews(_ tasteData: [TasteData]) { -// for view in backgroundImageView.subviews { -// view.removeFromSuperview() -// } -// -// if tasteData.count >= 3 { -// let firstDataView = TasteDataView(tasteData: tasteData[0]) -// let secondDataView = TasteDataView(tasteData: tasteData[1]) -// let thirdDataView = TasteDataView(tasteData: tasteData[2]) -// -// backgroundImageView.addSubview(firstDataView) -// backgroundImageView.addSubview(secondDataView) -// backgroundImageView.addSubview(thirdDataView) -// -// let bubbleCenters = [ -// CGPoint(x: 0.4, y: 0.6), -// CGPoint(x: 0.8, y: 0.4), -// CGPoint(x: 0.5, y: 0.8) -// ] -// -// firstDataView.snp.makeConstraints { -// $0.centerX.equalToSuperview().multipliedBy(bubbleCenters[0].x * 2) -// $0.centerY.equalToSuperview().multipliedBy(bubbleCenters[0].y * 1.47) -// $0.width.equalTo(200) -// $0.height.equalTo(200) -// } -// -// secondDataView.snp.makeConstraints { -// $0.centerX.equalToSuperview().multipliedBy(bubbleCenters[1].x * 1.74) -// $0.centerY.equalToSuperview().multipliedBy(bubbleCenters[1].y * 1.29) -// $0.width.equalTo(150) -// $0.height.equalTo(150) -// } -// -// thirdDataView.snp.makeConstraints { -// $0.centerX.equalToSuperview().multipliedBy(bubbleCenters[2].x * 2.574) -// $0.centerY.equalToSuperview().multipliedBy(bubbleCenters[2].y * 1.83) -// $0.width.equalTo(100) -// $0.height.equalTo(100) -// } -// } -// } -//} From fdc2a5662894578fa7b7f94154e70672d3d5f704 Mon Sep 17 00:00:00 2001 From: 0gonge Date: Sat, 19 Oct 2024 00:46:31 +0900 Subject: [PATCH 2/7] =?UTF-8?q?feat:=20VisketYellowButton=EC=BB=B4?= =?UTF-8?q?=ED=8F=AC=EB=84=8C=ED=8A=B8=20=EA=B5=AC=ED=98=84(#159)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/ViskitYellowButton.swift | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Common/Sources/Components/ViskitYellowButton.swift diff --git a/Common/Sources/Components/ViskitYellowButton.swift b/Common/Sources/Components/ViskitYellowButton.swift new file mode 100644 index 0000000..21a4e84 --- /dev/null +++ b/Common/Sources/Components/ViskitYellowButton.swift @@ -0,0 +1,29 @@ +// +// ViskitYellowButton.swift +// Common +// +// Created by 송여경 on 10/19/24. +// Copyright © 2024 com.recordy. All rights reserved. +// + +import UIKit + +class ViskitYellowButton: UIButton { + + override init(frame: CGRect) { + super.init(frame: frame) + setUI() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + private func setUI() { + backgroundColor = CommonAsset.viskitYellow400.color + layer.cornerRadius = 30 + titleLabel?.font = ViskitFont.body2Bold.font + setTitleColor(.black, for: .normal) + } + +} From 2f2898215d8e8eb481ae32bad7d43fe3c46d16af Mon Sep 17 00:00:00 2001 From: 0gonge Date: Sat, 19 Oct 2024 01:15:46 +0900 Subject: [PATCH 3/7] =?UTF-8?q?feat:=20MyRecordEmptyView=EA=B5=AC=ED=98=84?= =?UTF-8?q?(#159)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LedyEmpty.imageset/Contents.json | 21 +++++ .../LedyEmpty.imageset/LedyEmpty.svg | 14 +++ .../Components/ViskitYellowButton.swift | 4 +- .../MyProfile/View/MyRecordEmptyView.swift | 88 +++++++++++++++++++ 4 files changed, 125 insertions(+), 2 deletions(-) create mode 100644 Common/Resources/Asset.xcassets/LedyEmpty.imageset/Contents.json create mode 100644 Common/Resources/Asset.xcassets/LedyEmpty.imageset/LedyEmpty.svg create mode 100644 Presentation/Sources/MyProfile/View/MyRecordEmptyView.swift diff --git a/Common/Resources/Asset.xcassets/LedyEmpty.imageset/Contents.json b/Common/Resources/Asset.xcassets/LedyEmpty.imageset/Contents.json new file mode 100644 index 0000000..81c3e62 --- /dev/null +++ b/Common/Resources/Asset.xcassets/LedyEmpty.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "LedyEmpty.svg", + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Common/Resources/Asset.xcassets/LedyEmpty.imageset/LedyEmpty.svg b/Common/Resources/Asset.xcassets/LedyEmpty.imageset/LedyEmpty.svg new file mode 100644 index 0000000..31107df --- /dev/null +++ b/Common/Resources/Asset.xcassets/LedyEmpty.imageset/LedyEmpty.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/Common/Sources/Components/ViskitYellowButton.swift b/Common/Sources/Components/ViskitYellowButton.swift index 21a4e84..075c438 100644 --- a/Common/Sources/Components/ViskitYellowButton.swift +++ b/Common/Sources/Components/ViskitYellowButton.swift @@ -8,9 +8,9 @@ import UIKit -class ViskitYellowButton: UIButton { +public class ViskitYellowButton: UIButton { - override init(frame: CGRect) { + public override init(frame: CGRect) { super.init(frame: frame) setUI() } diff --git a/Presentation/Sources/MyProfile/View/MyRecordEmptyView.swift b/Presentation/Sources/MyProfile/View/MyRecordEmptyView.swift new file mode 100644 index 0000000..3d7089e --- /dev/null +++ b/Presentation/Sources/MyProfile/View/MyRecordEmptyView.swift @@ -0,0 +1,88 @@ +// +// MyRecordEmptyView.swift +// Presentation +// +// Created by 송여경 on 10/19/24. +// Copyright © 2024 com.recordy. All rights reserved. +// + +import UIKit +import SnapKit +import Then + +import Common + +class MyRecordEmptyView: UIView { + private let imageView = UIImageView() + private let textLabel = UILabel() + private let goRecordButton = ViskitYellowButton() + + var onRecordButtonTapped: (() -> Void)? + + override init(frame: CGRect) { + super.init(frame: frame) + setStyle() + setUI() + setAutoLayout() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + private func setStyle() { + backgroundColor = .black + + imageView.do { + $0.image = CommonAsset.ledyEmpty.image + $0.contentMode = .scaleAspectFit + } + + textLabel.do { + $0.text = "직접 방문한 공간 영상을\n공유해 보세요!" + $0.numberOfLines = 2 + $0.textAlignment = .center + $0.textColor = CommonAsset.viskitGray02.color + $0.font = ViskitFont.title2.font + } + + goRecordButton.do { + $0.setTitle("영상 업로드하기", for: .normal) + $0.addTarget(self, action: #selector(goRecordButtonTapped), for: .touchUpInside) + } + } + + private func setUI() { + [ + imageView, + textLabel, + goRecordButton + ].forEach{ addSubview($0)} + } + + private func setAutoLayout() { + imageView.snp.makeConstraints { + $0.top.equalToSuperview().offset(77) + $0.centerX.equalToSuperview() + $0.width.equalTo(110.adaptiveWidth) + $0.height.equalTo(97.adaptiveHeight) + } + + textLabel.snp.makeConstraints { + $0.top.equalTo(imageView.snp.bottom).offset(14) + $0.centerX.equalToSuperview() + $0.leading.trailing.equalToSuperview().inset(94) + } + + goRecordButton.snp.makeConstraints { + $0.top.equalTo(textLabel.snp.bottom).offset(24) + $0.centerX.equalToSuperview() + $0.width.equalTo(125.adaptiveWidth) + $0.height.equalTo(44.adaptiveHeight) + } + } + + @objc private func goRecordButtonTapped() { + onRecordButtonTapped?() + } +} From 0f965d02ff7e5d6bb1fd6026319d752443cf28c8 Mon Sep 17 00:00:00 2001 From: 0gonge Date: Sat, 19 Oct 2024 01:53:06 +0900 Subject: [PATCH 4/7] =?UTF-8?q?fix:=20EmptyViewUI=20=EC=84=B8=EB=B6=80?= =?UTF-8?q?=EC=82=AC=ED=95=AD=20=EC=88=98=EC=A0=95(#159)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/ViskitYellowButton.swift | 7 +- .../Controller/ProfileViewController.swift | 36 ++--- .../Sources/MyProfile/View/MyRecordView.swift | 153 ++++++------------ 3 files changed, 71 insertions(+), 125 deletions(-) diff --git a/Common/Sources/Components/ViskitYellowButton.swift b/Common/Sources/Components/ViskitYellowButton.swift index 075c438..f7c0395 100644 --- a/Common/Sources/Components/ViskitYellowButton.swift +++ b/Common/Sources/Components/ViskitYellowButton.swift @@ -21,9 +21,14 @@ public class ViskitYellowButton: UIButton { private func setUI() { backgroundColor = CommonAsset.viskitYellow400.color - layer.cornerRadius = 30 + layer.cornerRadius = 40 titleLabel?.font = ViskitFont.body2Bold.font setTitleColor(.black, for: .normal) + clipsToBounds = true } + public override func layoutSubviews() { + super.layoutSubviews() + layer.cornerRadius = bounds.height / 2 + } } diff --git a/Presentation/Sources/MyProfile/Controller/ProfileViewController.swift b/Presentation/Sources/MyProfile/Controller/ProfileViewController.swift index 26ccf6b..5103fd6 100644 --- a/Presentation/Sources/MyProfile/Controller/ProfileViewController.swift +++ b/Presentation/Sources/MyProfile/Controller/ProfileViewController.swift @@ -93,13 +93,8 @@ public class ProfileViewController: UIViewController { } segmentControlView.snp.makeConstraints { -// $0.top.equalTo(profileInfoView.snp.bottom).offset(35.adaptiveHeight) -// $0.horizontalEdges.equalToSuperview() -// $0.height.equalTo(40.adaptiveHeight) - $0.top.equalTo(profileInfoView.snp.bottom).offset(32) $0.horizontalEdges.equalToSuperview().inset(20) -// $0.trailing.equalToSuperview().inset(20) $0.height.equalTo(34) } @@ -127,10 +122,10 @@ public class ProfileViewController: UIViewController { private func setUserProfile() { guard let user = user else { return } - let followerAttributedText = NSMutableAttributedString(string: "\(user.follower.count)", attributes: [.font: RecordyFont.body2.font]) + let followerAttributedText = NSMutableAttributedString(string: "\(user.followerCount)", attributes: [.font: RecordyFont.body2.font]) followerAttributedText.append(NSAttributedString(string: " 명의 팔로워", attributes: [.font: RecordyFont.body2.font, .foregroundColor: CommonAsset.recordyGrey03.color])) self.profileInfoView.followerButton.setAttributedTitle(followerAttributedText, for: .normal) - let followingAttributedText = NSMutableAttributedString(string: "\(user.following?.count ?? 0)", attributes: [.font: RecordyFont.body2.font]) + let followingAttributedText = NSMutableAttributedString(string: "\(user.followingCount)", attributes: [.font: RecordyFont.body2.font]) followingAttributedText.append(NSAttributedString(string: " 명의 팔로잉", attributes: [.font: RecordyFont.body2.font, .foregroundColor: CommonAsset.recordyGrey03.color])) self.profileInfoView.followingButton.setAttributedTitle(followingAttributedText, for: .normal) self.profileInfoView.userName.text = user.nickname @@ -197,10 +192,9 @@ public class ProfileViewController: UIViewController { thumbnailLink: content.recordInfo.fileUrl.thumbnailUrl, isMine: content.recordInfo.isMine) } - DispatchQueue.main.async { [weak self] in - guard let self = self else { return } - self.myRecordView.getMyRecordList(feeds: feeds) + DispatchQueue.main.async { self.user?.feeds = feeds + self.myRecordView.getMyRecordList(feeds: feeds) self.setUserProfile() } case .failure(let failure): @@ -212,16 +206,6 @@ public class ProfileViewController: UIViewController { } } - private func getPlaceFeature(from location: String) -> PlaceFeature { - if location.lowercased().contains("free") { - return .free - } else if location.lowercased().contains("closing soon") { - return .closingSoon - } else { - return .all - } - } - func getBookmarkedRecordList() { let apiProvider = APIProvider() let request = DTO.GetBookmarkedListRequest(cursorId: 0, size: 100) @@ -247,8 +231,8 @@ public class ProfileViewController: UIViewController { isMine: false) } DispatchQueue.main.async { - self.bookmarkView.getBookmarkList(feeds: feeds) self.user?.bookmarkedFeeds = feeds + self.bookmarkView.getBookmarkList(feeds: feeds) } case .failure(let failure): print(failure) @@ -256,6 +240,16 @@ public class ProfileViewController: UIViewController { } } + private func getPlaceFeature(from location: String) -> PlaceFeature { + if location.lowercased().contains("free") { + return .free + } else if location.lowercased().contains("closing soon") { + return .closingSoon + } else { + return .all + } + } + @objc private func showFollowers() { let followerViewController = FollowViewController(followType: .follower) self.navigationController?.pushViewController(followerViewController, animated: true) diff --git a/Presentation/Sources/MyProfile/View/MyRecordView.swift b/Presentation/Sources/MyProfile/View/MyRecordView.swift index 8a64d75..02daa97 100644 --- a/Presentation/Sources/MyProfile/View/MyRecordView.swift +++ b/Presentation/Sources/MyProfile/View/MyRecordView.swift @@ -1,10 +1,3 @@ -// -// MyRecordView.swift -// Presentation -// -// Created by 송여경 on 7/17/24. -// Copyright © 2024 com.recordy. All rights reserved. -// import UIKit import SnapKit import Then @@ -18,99 +11,72 @@ protocol UserRecordDelegate: AnyObject { } @available(iOS 16.0, *) -public class MyRecordView: UIView, UICollectionViewDataSource, UICollectionViewDelegate { - private let videoEmptyView = UIView() - private let videoEmptyImageView = UIImageView() - private let videoEmptyTextView = UIImageView() - private let goActionButton = UIButton() +public class MyRecordView: UIView { + private let emptyView = MyRecordEmptyView() private let countLabel = UILabel() - private var collectionView: UICollectionView! - private var feeds: [Feed] = [] + private lazy var collectionView: UICollectionView = { + let layout = UICollectionViewFlowLayout() + layout.itemSize = CGSize(width: 170, height: 288) + layout.minimumLineSpacing = 10 + layout.minimumInteritemSpacing = 10 + layout.sectionInset = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20) + + let cv = UICollectionView(frame: .zero, collectionViewLayout: layout) + cv.backgroundColor = .clear + cv.dataSource = self + cv.delegate = self + cv.register(ThumbnailCollectionViewCell.self, forCellWithReuseIdentifier: ThumbnailCollectionViewCell.cellIdentifier) + return cv + }() + + private var feeds: [Feed] = [] { + didSet { updateViewState() } + } + weak var delegate: UserRecordDelegate? - + override init(frame: CGRect) { super.init(frame: frame) - setUpCollectionView() setStyle() setUI() setAutoLayout() - checkDataEmpty() } required init?(coder: NSCoder) { - fatalError("init(coder:)가 구현되지 않았습니다.") + fatalError("init(coder:) has not been implemented") } private func setStyle() { - self.backgroundColor = .black - - videoEmptyImageView.do { - $0.image = CommonAsset.mypageCamera.image - $0.contentMode = .scaleAspectFit - } - - videoEmptyTextView.do { - $0.image = CommonAsset.myRecordText.image - } - - goActionButton.do { - $0.addTarget(self, action: #selector(didTapActionButton), for: .touchUpInside) - $0.setImage(CommonAsset.gorecord.image, for: .normal) - $0.imageView?.contentMode = .scaleAspectFit - } + backgroundColor = .black countLabel.do { - $0.text = "0 개의 기록" $0.textColor = .white - $0.font = RecordyFont.caption1.font + $0.font = ViskitFont.caption1Regular.font $0.numberOfLines = 1 $0.textAlignment = .right } - collectionView.do { - $0.backgroundColor = .clear + emptyView.onRecordButtonTapped = { [weak self] in + self?.delegate?.uploadFeedTapped() } } private func setUI() { - self.addSubview(videoEmptyView) - self.addSubview(countLabel) - self.addSubview(collectionView) - - videoEmptyView.addSubview(videoEmptyImageView) - videoEmptyView.addSubview(videoEmptyTextView) - videoEmptyView.addSubview(goActionButton) + [ + emptyView, + countLabel, + collectionView + ].forEach { addSubview($0) } } private func setAutoLayout() { - videoEmptyImageView.snp.makeConstraints { - $0.top.equalToSuperview().offset(78) - $0.leading.equalTo(138) - $0.centerX.equalToSuperview() - $0.width.height.equalTo(100.adaptiveHeight.adaptiveWidth) - } - - videoEmptyTextView.snp.makeConstraints { - $0.top.equalTo(videoEmptyImageView.snp.bottom).offset(18) - $0.leading.equalToSuperview().offset(105) - } - - goActionButton.snp.makeConstraints { - $0.top.equalTo(videoEmptyTextView.snp.bottom).offset(31) - $0.leading.equalToSuperview().offset(130) - $0.centerX.equalToSuperview() - $0.width.equalTo(116.adaptiveWidth) - $0.height.equalTo(42.adaptiveHeight) - } - - videoEmptyView.snp.makeConstraints { + emptyView.snp.makeConstraints { $0.edges.equalToSuperview() } countLabel.snp.makeConstraints { $0.top.equalToSuperview().offset(-18) - $0.leading.equalToSuperview().offset(194) - $0.width.equalTo(161.adaptiveWidth) + $0.trailing.equalToSuperview().inset(20) $0.height.equalTo(18.adaptiveHeight) } @@ -120,50 +86,34 @@ public class MyRecordView: UIView, UICollectionViewDataSource, UICollectionViewD } } - private func setUpCollectionView() { - let layout = UICollectionViewFlowLayout() - layout.itemSize = CGSize(width: 170, height: 288) - layout.minimumLineSpacing = 10 - layout.minimumInteritemSpacing = 10 - layout.sectionInset = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20) + private func updateViewState() { + let isEmpty = feeds.isEmpty + emptyView.isHidden = !isEmpty + collectionView.isHidden = isEmpty - collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout) - collectionView.dataSource = self - collectionView.delegate = self - collectionView.register(ThumbnailCollectionViewCell.self, forCellWithReuseIdentifier: ThumbnailCollectionViewCell.cellIdentifier) - } - - @objc private func didTapActionButton() { - delegate?.uploadFeedTapped() - } - - private func checkDataEmpty() { - if feeds.isEmpty { - videoEmptyView.isHidden = false - countLabel.isHidden = true - collectionView.isHidden = true - } else { - videoEmptyView.isHidden = true - countLabel.isHidden = false - collectionView.isHidden = false + setCountLabelText() + + if !isEmpty { setCountLabelText() + collectionView.reloadData() } } private func setCountLabelText() { let whiteText = "• \(feeds.count)" let greyText = " 개의 기록" - let attributedText = NSMutableAttributedString(string: whiteText, attributes: [NSAttributedString.Key.foregroundColor: UIColor.white]) - attributedText.append(NSAttributedString(string: greyText, attributes: [NSAttributedString.Key.foregroundColor: CommonAsset.recordyGrey03.color])) + let attributedText = NSMutableAttributedString(string: whiteText, attributes: [.foregroundColor: UIColor.white]) + attributedText.append(NSAttributedString(string: greyText, attributes: [.foregroundColor: CommonAsset.viskitGray03.color])) countLabel.attributedText = attributedText } func getMyRecordList(feeds: [Feed]) { self.feeds = feeds - self.collectionView.reloadData() - checkDataEmpty() } - +} + +@available(iOS 16.0, *) +extension MyRecordView: UICollectionViewDataSource, UICollectionViewDelegate { public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return feeds.count } @@ -178,11 +128,8 @@ public class MyRecordView: UIView, UICollectionViewDataSource, UICollectionViewD cell.configure(feed: feeds[indexPath.row]) return cell } - - public func collectionView( - _ collectionView: UICollectionView, - didSelectItemAt indexPath: IndexPath - ) { + + public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { delegate?.userRecordFeedTapped(feed: feeds[indexPath.row]) } } From 64bd1269f3d09b6b57ed5100f2a4d6d1f891c9a1 Mon Sep 17 00:00:00 2001 From: 0gonge Date: Sat, 19 Oct 2024 02:15:21 +0900 Subject: [PATCH 5/7] =?UTF-8?q?feat:=20BookMarkEmptyView=EA=B5=AC=ED=98=84?= =?UTF-8?q?(#159)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyProfile/View/BookMarkEmptyView.swift | 92 ++++++++++++++++ .../MyProfile/View/MyPlaceEmptyView.swift | 102 ------------------ .../MyProfile/View/MyRecordEmptyView.swift | 2 +- 3 files changed, 93 insertions(+), 103 deletions(-) create mode 100644 Presentation/Sources/MyProfile/View/BookMarkEmptyView.swift delete mode 100644 Presentation/Sources/MyProfile/View/MyPlaceEmptyView.swift diff --git a/Presentation/Sources/MyProfile/View/BookMarkEmptyView.swift b/Presentation/Sources/MyProfile/View/BookMarkEmptyView.swift new file mode 100644 index 0000000..824deb0 --- /dev/null +++ b/Presentation/Sources/MyProfile/View/BookMarkEmptyView.swift @@ -0,0 +1,92 @@ +// +// BookMarkEmptyView.swift +// Presentation +// +// Created by 송여경 on 10/19/24. +// Copyright © 2024 com.recordy. All rights reserved. +// + +import UIKit +import SnapKit +import Then + +import Common + +class BookMarkEmptyView: UIView { + private let imageView = UIImageView() + private let titleLabel = UILabel() + private let goAroundButton = ViskitYellowButton() + + override init(frame: CGRect) { + super.init(frame: frame) + setStyle() + setUI() + setAutoLayout() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + private func setStyle() { + backgroundColor = .black + + imageView.do { + $0.image = CommonAsset.ledyEmpty.image + $0.contentMode = .scaleAspectFit + } + + titleLabel.do { + $0.text = "북마크한 영상이 없어요.\n영상을 둘러보고 저장해 보세요!" + $0.numberOfLines = 2 + $0.textAlignment = .center + $0.textColor = CommonAsset.viskitGray02.color + $0.font = ViskitFont.title2.font + } + + goAroundButton.do { + $0.setTitle("영상 둘러보기", for: .normal) + } + } + + private func setUI() { + [ + imageView, + titleLabel, + goAroundButton + ].forEach{ addSubview($0)} + } + + private func setAutoLayout() { + imageView.snp.makeConstraints { + $0.top.equalToSuperview().offset(111) + $0.centerX.equalToSuperview() + $0.width.equalTo(110.adaptiveWidth) + $0.height.equalTo(97.adaptiveHeight) + } + + titleLabel.snp.makeConstraints { + $0.top.equalTo(imageView.snp.bottom).offset(14) + $0.centerX.equalToSuperview() + $0.leading.trailing.equalToSuperview().inset(65) + } + + goAroundButton.snp.makeConstraints { + $0.top.equalTo(titleLabel.snp.bottom).offset(24) + $0.centerX.equalToSuperview() + $0.width.equalTo(113.adaptiveWidth) + $0.height.equalTo(44.adaptiveHeight) + } + } + + func setActionButtonHandler(_ handler: @escaping () -> Void) { + goAroundButton.addTarget(self, action: #selector(actionButtonTapped), for: .touchUpInside) + self.actionButtonHandler = handler + } + + private var actionButtonHandler: (() -> Void)? + + @objc private func actionButtonTapped() { + actionButtonHandler?() + } +} diff --git a/Presentation/Sources/MyProfile/View/MyPlaceEmptyView.swift b/Presentation/Sources/MyProfile/View/MyPlaceEmptyView.swift deleted file mode 100644 index 026ea73..0000000 --- a/Presentation/Sources/MyProfile/View/MyPlaceEmptyView.swift +++ /dev/null @@ -1,102 +0,0 @@ -// -// TasteEmptyView.swift -// Presentation -// -// Created by 한지석 on 7/20/24. -// Copyright © 2024 com.recordy. All rights reserved. -// - -import UIKit - -import Core -import Common - -import SnapKit -import Then - -protocol TasteViewDelegate: AnyObject { - func tasteViewUploadFeedTapped() -} - -class MyPlaceEmptyView: UIView { - - let emptyImageView = UIImageView() - let emptyLabel = UIImageView() - let recordButton = UIButton() - let bottomMessage = UILabel() - weak var delegate: TasteViewDelegate? - - override init(frame: CGRect) { - super.init(frame: frame) - setStyle() - setUI() - setAutoLayout() - } - - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - private func setStyle() { - emptyImageView.do { - $0.image = CommonAsset.mypagebubble.image - $0.contentMode = .scaleAspectFit - } - - emptyLabel.do { - $0.image = CommonAsset.mypageEmptyViewText.image - } - - recordButton.do { - $0.setImage(CommonAsset.gorecord.image, for: .normal) - $0.imageView?.contentMode = .scaleAspectFit - $0.addTarget(self, action: #selector(uploadButtonTapped), for: .touchUpInside) - } - - bottomMessage.do { - $0.text = "서로 다른 키워드 3개를 입력하면 그래프가 보여요" - $0.font = RecordyFont.caption2.font - $0.textColor = CommonAsset.recordyGrey03.color - } - } - - private func setUI() { - self.addSubviews( - emptyImageView, - emptyLabel, - recordButton, - bottomMessage - ) - } - - private func setAutoLayout() { - emptyImageView.snp.makeConstraints { - $0.top.equalToSuperview().offset(78) - $0.centerX.equalToSuperview() - $0.leading.equalToSuperview().offset(138) - $0.width.height.equalTo(100) - } - - emptyLabel.snp.makeConstraints { - $0.top.equalTo(emptyImageView.snp.bottom).offset(18) - $0.leading.equalTo(79) - } - - recordButton.snp.makeConstraints { - $0.top.equalTo(emptyLabel.snp.bottom).offset(31) - $0.centerX.equalToSuperview() - $0.width.equalTo(116.adaptiveWidth) - $0.height.equalTo(42.adaptiveHeight) - } - - bottomMessage.snp.makeConstraints { - $0.bottom.equalTo(self.safeAreaLayoutGuide).inset(24.adaptiveHeight) - $0.height.equalTo(20.adaptiveHeight) - $0.centerX.equalToSuperview() - } - } - - @objc func uploadButtonTapped() { - delegate?.tasteViewUploadFeedTapped() - } -} diff --git a/Presentation/Sources/MyProfile/View/MyRecordEmptyView.swift b/Presentation/Sources/MyProfile/View/MyRecordEmptyView.swift index 3d7089e..4455b79 100644 --- a/Presentation/Sources/MyProfile/View/MyRecordEmptyView.swift +++ b/Presentation/Sources/MyProfile/View/MyRecordEmptyView.swift @@ -62,7 +62,7 @@ class MyRecordEmptyView: UIView { private func setAutoLayout() { imageView.snp.makeConstraints { - $0.top.equalToSuperview().offset(77) + $0.top.equalToSuperview().offset(111) $0.centerX.equalToSuperview() $0.width.equalTo(110.adaptiveWidth) $0.height.equalTo(97.adaptiveHeight) From 3bba1612dae7ed61a4ad5abe9eaa353c3b8e9b94 Mon Sep 17 00:00:00 2001 From: 0gonge Date: Sat, 19 Oct 2024 02:39:10 +0900 Subject: [PATCH 6/7] =?UTF-8?q?feat:=20BookMarkView=EC=97=90=20EmptyView?= =?UTF-8?q?=20=EC=88=98=EC=A0=95=EB=B0=98=EC=98=81(#159)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyProfile/View/BookMarkEmptyView.swift | 27 +++- .../Sources/MyProfile/View/BookMarkView.swift | 143 +++++++----------- .../MyProfile/View/MyRecordEmptyView.swift | 23 ++- 3 files changed, 93 insertions(+), 100 deletions(-) diff --git a/Presentation/Sources/MyProfile/View/BookMarkEmptyView.swift b/Presentation/Sources/MyProfile/View/BookMarkEmptyView.swift index 824deb0..39de1b6 100644 --- a/Presentation/Sources/MyProfile/View/BookMarkEmptyView.swift +++ b/Presentation/Sources/MyProfile/View/BookMarkEmptyView.swift @@ -5,7 +5,6 @@ // Created by 송여경 on 10/19/24. // Copyright © 2024 com.recordy. All rights reserved. // - import UIKit import SnapKit import Then @@ -17,6 +16,8 @@ class BookMarkEmptyView: UIView { private let titleLabel = UILabel() private let goAroundButton = ViskitYellowButton() + private var actionButtonHandler: (() -> Void)? + override init(frame: CGRect) { super.init(frame: frame) setStyle() @@ -37,11 +38,25 @@ class BookMarkEmptyView: UIView { } titleLabel.do { - $0.text = "북마크한 영상이 없어요.\n영상을 둘러보고 저장해 보세요!" - $0.numberOfLines = 2 - $0.textAlignment = .center + let text = "북마크한 영상이 없어요.\n영상을 둘러보고 저장해 보세요!" + $0.numberOfLines = 0 $0.textColor = CommonAsset.viskitGray02.color $0.font = ViskitFont.title2.font + + let paragraphStyle = NSMutableParagraphStyle() + paragraphStyle.lineSpacing = 30 - $0.font.lineHeight + paragraphStyle.alignment = .center + + let attributedString = NSAttributedString( + string: text, + attributes: [ + .paragraphStyle: paragraphStyle, + .font: ViskitFont.title2.font, + .foregroundColor: CommonAsset.viskitGray02.color + ] + ) + $0.attributedText = attributedString + $0.textAlignment = .center } goAroundButton.do { @@ -54,7 +69,7 @@ class BookMarkEmptyView: UIView { imageView, titleLabel, goAroundButton - ].forEach{ addSubview($0)} + ].forEach { addSubview($0) } } private func setAutoLayout() { @@ -84,8 +99,6 @@ class BookMarkEmptyView: UIView { self.actionButtonHandler = handler } - private var actionButtonHandler: (() -> Void)? - @objc private func actionButtonTapped() { actionButtonHandler?() } diff --git a/Presentation/Sources/MyProfile/View/BookMarkView.swift b/Presentation/Sources/MyProfile/View/BookMarkView.swift index b24eab8..c01d144 100644 --- a/Presentation/Sources/MyProfile/View/BookMarkView.swift +++ b/Presentation/Sources/MyProfile/View/BookMarkView.swift @@ -19,84 +19,70 @@ protocol BookmarkDelegate: AnyObject { func bookmarkButtonTapped(feed: Feed) } -class BookmarkView: UIView, UICollectionViewDataSource, UICollectionViewDelegate { - private let bookmarkEmptyView = UIView() - private let bookmarkDataView = UIView() - let bookmarkEmptyImageView = UIImageView() - let bookmarkEmptyTextVIew = UIImageView() +class BookmarkView: UIView { + private let bookmarkEmptyView = BookMarkEmptyView() private let countLabel = UILabel() - private var collectionView: UICollectionView! - - private var feeds: [Feed] = [] + private lazy var collectionView: UICollectionView = { + let layout = UICollectionViewFlowLayout() + layout.itemSize = CGSize(width: 170, height: 288) + layout.minimumLineSpacing = 10 + layout.minimumInteritemSpacing = 10 + layout.sectionInset = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20) + + let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout) + collectionView.dataSource = self + collectionView.delegate = self + collectionView.backgroundColor = .clear + collectionView.register(ThumbnailCollectionViewCell.self, forCellWithReuseIdentifier: ThumbnailCollectionViewCell.cellIdentifier) + return collectionView + }() + + private var feeds: [Feed] = [] { + didSet { + updateViewState() + } + } weak var delegate: BookmarkDelegate? - + override init(frame: CGRect) { super.init(frame: frame) - setUpCollectionView() + setupViews() setStyle() - setUI() - setAutoLayout() - checkDataEmpty() + setLayout() + updateViewState() // 초기 상태 설정 } required init?(coder: NSCoder) { - fatalError("init(coder:)가 구현되지 않았습니다.") + fatalError("init(coder:) has not been implemented") } - private func setStyle() { - self.backgroundColor = .black - bookmarkEmptyImageView.do { - $0.image = CommonAsset.mypagebookmark.image - $0.contentMode = .scaleAspectFit - } - bookmarkEmptyTextVIew.do { - $0.image = CommonAsset.bookmarkText.image + private func setupViews() { + addSubview(bookmarkEmptyView) + addSubview(countLabel) + addSubview(collectionView) + + bookmarkEmptyView.setActionButtonHandler { [weak self] in + print("영상 둘러보기 눌림") } + } + + private func setStyle() { + backgroundColor = .black countLabel.do { - $0.text = "0 개의 기록" $0.textColor = .white $0.font = RecordyFont.caption1.font $0.numberOfLines = 1 $0.textAlignment = .right } - - collectionView.do { - $0.backgroundColor = .clear - } } - private func setUI() { - self.addSubview(bookmarkEmptyView) - self.addSubview(bookmarkDataView) - self.addSubview(countLabel) - self.addSubview(collectionView) - - bookmarkEmptyView.addSubview(bookmarkEmptyImageView) - bookmarkEmptyView.addSubview(bookmarkEmptyTextVIew) - } - - private func setAutoLayout() { - bookmarkEmptyImageView.snp.makeConstraints { - $0.top.equalToSuperview().offset(115) - $0.leading.equalTo(143) - $0.width.equalTo(100.adaptiveWidth) - $0.height.equalTo(100.adaptiveHeight) - } - - bookmarkEmptyTextVIew.snp.makeConstraints { - $0.top.equalTo(bookmarkEmptyImageView.snp.bottom).offset(18) - $0.leading.equalTo(70) - } - - bookmarkEmptyView.snp.makeConstraints { - $0.edges.equalToSuperview() - } + private func setLayout() { + bookmarkEmptyView.snp.makeConstraints { $0.edges.equalToSuperview() } countLabel.snp.makeConstraints { $0.top.equalToSuperview().offset(-18) - $0.leading.equalToSuperview().offset(194) - $0.width.equalTo(161.adaptiveWidth) + $0.trailing.equalToSuperview().inset(20) $0.height.equalTo(18.adaptiveHeight) } @@ -106,46 +92,30 @@ class BookmarkView: UIView, UICollectionViewDataSource, UICollectionViewDelegate } } - private func setUpCollectionView() { - let layout = UICollectionViewFlowLayout() - layout.itemSize = CGSize(width: 170, height: 288) - layout.minimumLineSpacing = 10 - layout.minimumInteritemSpacing = 10 - layout.sectionInset = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20) - - collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout) - collectionView.dataSource = self - collectionView.delegate = self - collectionView.register(ThumbnailCollectionViewCell.self, forCellWithReuseIdentifier: ThumbnailCollectionViewCell.cellIdentifier) - } - - private func checkDataEmpty() { - if feeds.isEmpty { - bookmarkEmptyView.isHidden = false - countLabel.isHidden = true - collectionView.isHidden = true - } else { - bookmarkEmptyView.isHidden = true - countLabel.isHidden = false - collectionView.isHidden = false - setCountLabelText() + private func updateViewState() { + let isEmpty = feeds.isEmpty + bookmarkEmptyView.isHidden = !isEmpty + collectionView.isHidden = isEmpty + setCountLabelText() + if !isEmpty { + collectionView.reloadData() } } private func setCountLabelText() { let whiteText = "• \(feeds.count)" let greyText = " 개의 기록" - let attributedText = NSMutableAttributedString(string: whiteText, attributes: [NSAttributedString.Key.foregroundColor: UIColor.white]) - attributedText.append(NSAttributedString(string: greyText, attributes: [NSAttributedString.Key.foregroundColor: CommonAsset.recordyGrey03.color])) + let attributedText = NSMutableAttributedString(string: whiteText, attributes: [.foregroundColor: UIColor.white]) + attributedText.append(NSAttributedString(string: greyText, attributes: [.foregroundColor: CommonAsset.recordyGrey03.color])) countLabel.attributedText = attributedText } - + func getBookmarkList(feeds: [Feed]) { self.feeds = feeds - self.collectionView.reloadData() - checkDataEmpty() } +} +extension BookmarkView: UICollectionViewDataSource, UICollectionViewDelegate { func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return feeds.count } @@ -166,11 +136,8 @@ class BookmarkView: UIView, UICollectionViewDataSource, UICollectionViewDelegate } return cell } - - func collectionView( - _ collectionView: UICollectionView, - didSelectItemAt indexPath: IndexPath - ) { + + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { delegate?.bookmarkFeedTapped(feed: feeds[indexPath.row]) } } diff --git a/Presentation/Sources/MyProfile/View/MyRecordEmptyView.swift b/Presentation/Sources/MyProfile/View/MyRecordEmptyView.swift index 4455b79..d4e3ddb 100644 --- a/Presentation/Sources/MyProfile/View/MyRecordEmptyView.swift +++ b/Presentation/Sources/MyProfile/View/MyRecordEmptyView.swift @@ -5,7 +5,6 @@ // Created by 송여경 on 10/19/24. // Copyright © 2024 com.recordy. All rights reserved. // - import UIKit import SnapKit import Then @@ -39,11 +38,25 @@ class MyRecordEmptyView: UIView { } textLabel.do { - $0.text = "직접 방문한 공간 영상을\n공유해 보세요!" - $0.numberOfLines = 2 - $0.textAlignment = .center + let text = "직접 방문한 공간 영상을\n공유해 보세요!" + $0.numberOfLines = 0 $0.textColor = CommonAsset.viskitGray02.color $0.font = ViskitFont.title2.font + + let paragraphStyle = NSMutableParagraphStyle() + paragraphStyle.lineSpacing = 30 - $0.font.lineHeight + paragraphStyle.alignment = .center + + let attributedString = NSAttributedString( + string: text, + attributes: [ + .paragraphStyle: paragraphStyle, + .font: ViskitFont.title2.font, + .foregroundColor: CommonAsset.viskitGray02.color + ] + ) + $0.attributedText = attributedString + $0.textAlignment = .center } goRecordButton.do { @@ -57,7 +70,7 @@ class MyRecordEmptyView: UIView { imageView, textLabel, goRecordButton - ].forEach{ addSubview($0)} + ].forEach { addSubview($0) } } private func setAutoLayout() { From e55897c80897ee4c0bc96e6e7cfd96d47a608429 Mon Sep 17 00:00:00 2001 From: 0gonge Date: Sat, 19 Oct 2024 03:03:16 +0900 Subject: [PATCH 7/7] =?UTF-8?q?fix:=20BookMarkView=20convention=20?= =?UTF-8?q?=EB=A7=9E=EC=B6=B0=20=EC=88=98=EC=A0=95(#159)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/MyProfile/View/BookMarkView.swift | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/Presentation/Sources/MyProfile/View/BookMarkView.swift b/Presentation/Sources/MyProfile/View/BookMarkView.swift index c01d144..83da5c4 100644 --- a/Presentation/Sources/MyProfile/View/BookMarkView.swift +++ b/Presentation/Sources/MyProfile/View/BookMarkView.swift @@ -6,13 +6,10 @@ // Copyright © 2024 com.recordy. All rights reserved. // import UIKit - import Common import Core - import SnapKit import Then -import Kingfisher protocol BookmarkDelegate: AnyObject { func bookmarkFeedTapped(feed: Feed) @@ -22,7 +19,7 @@ protocol BookmarkDelegate: AnyObject { class BookmarkView: UIView { private let bookmarkEmptyView = BookMarkEmptyView() private let countLabel = UILabel() - private lazy var collectionView: UICollectionView = { + lazy var collectionView: UICollectionView = { let layout = UICollectionViewFlowLayout() layout.itemSize = CGSize(width: 170, height: 288) layout.minimumLineSpacing = 10 @@ -46,20 +43,22 @@ class BookmarkView: UIView { override init(frame: CGRect) { super.init(frame: frame) - setupViews() + setUI() setStyle() setLayout() - updateViewState() // 초기 상태 설정 + updateViewState() } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } - private func setupViews() { - addSubview(bookmarkEmptyView) - addSubview(countLabel) - addSubview(collectionView) + private func setUI() { + [ + bookmarkEmptyView, + countLabel, + collectionView + ].forEach { addSubview($0) } bookmarkEmptyView.setActionButtonHandler { [weak self] in print("영상 둘러보기 눌림") @@ -115,7 +114,7 @@ class BookmarkView: UIView { } } -extension BookmarkView: UICollectionViewDataSource, UICollectionViewDelegate { +extension BookmarkView: UICollectionViewDataSource { func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return feeds.count } @@ -136,7 +135,9 @@ extension BookmarkView: UICollectionViewDataSource, UICollectionViewDelegate { } return cell } - +} + +extension BookmarkView: UICollectionViewDelegate { func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { delegate?.bookmarkFeedTapped(feed: feeds[indexPath.row]) }