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
new file mode 100644
index 0000000..f7c0395
--- /dev/null
+++ b/Common/Sources/Components/ViskitYellowButton.swift
@@ -0,0 +1,34 @@
+//
+// ViskitYellowButton.swift
+// Common
+//
+// Created by 송여경 on 10/19/24.
+// Copyright © 2024 com.recordy. All rights reserved.
+//
+
+import UIKit
+
+public class ViskitYellowButton: UIButton {
+
+ public 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 = 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 d649c84..5103fd6 100644
--- a/Presentation/Sources/MyProfile/Controller/ProfileViewController.swift
+++ b/Presentation/Sources/MyProfile/Controller/ProfileViewController.swift
@@ -93,9 +93,9 @@ 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.height.equalTo(34)
}
myRecordView.snp.makeConstraints {
@@ -122,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
@@ -192,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):
@@ -207,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)
@@ -242,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)
@@ -251,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/BookMarkEmptyView.swift b/Presentation/Sources/MyProfile/View/BookMarkEmptyView.swift
new file mode 100644
index 0000000..39de1b6
--- /dev/null
+++ b/Presentation/Sources/MyProfile/View/BookMarkEmptyView.swift
@@ -0,0 +1,105 @@
+//
+// 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()
+
+ private var actionButtonHandler: (() -> 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
+ }
+
+ titleLabel.do {
+ 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 {
+ $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
+ }
+
+ @objc private func actionButtonTapped() {
+ actionButtonHandler?()
+ }
+}
diff --git a/Presentation/Sources/MyProfile/View/BookMarkView.swift b/Presentation/Sources/MyProfile/View/BookMarkView.swift
index b24eab8..83da5c4 100644
--- a/Presentation/Sources/MyProfile/View/BookMarkView.swift
+++ b/Presentation/Sources/MyProfile/View/BookMarkView.swift
@@ -6,97 +6,82 @@
// 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)
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] = []
+ 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()
- setStyle()
setUI()
- setAutoLayout()
- checkDataEmpty()
+ setStyle()
+ 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 setUI() {
+ [
+ bookmarkEmptyView,
+ countLabel,
+ collectionView
+ ].forEach { addSubview($0) }
+
+ 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 +91,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 {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return feeds.count
}
@@ -166,11 +135,10 @@ class BookmarkView: UIView, UICollectionViewDataSource, UICollectionViewDelegate
}
return cell
}
+}
- func collectionView(
- _ collectionView: UICollectionView,
- didSelectItemAt indexPath: IndexPath
- ) {
+extension BookmarkView: UICollectionViewDelegate {
+ func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
delegate?.bookmarkFeedTapped(feed: feeds[indexPath.row])
}
}
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
new file mode 100644
index 0000000..d4e3ddb
--- /dev/null
+++ b/Presentation/Sources/MyProfile/View/MyRecordEmptyView.swift
@@ -0,0 +1,101 @@
+//
+// 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 {
+ 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 {
+ $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(111)
+ $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?()
+ }
+}
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])
}
}
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)
-// }
-// }
-// }
-//}