From 199cae60b302e9fd61461c84420ceb39e0b99b93 Mon Sep 17 00:00:00 2001 From: Jeon Seoung Hun Date: Mon, 4 Mar 2024 01:24:27 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[Feat]:=20Place=20List=20UI=20=EC=84=A4?= =?UTF-8?q?=EA=B3=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AVIRO.xcodeproj/project.pbxproj | 24 ++ AVIRO/Model/HomeViewModel/MarkerModel.swift | 13 + .../MyBookmarkListViewController.swift | 6 + .../MyCommentListViewController.swift | 6 + .../MyPlaceListViewController.swift | 47 +++- .../PlaceListTable/MyPlaceListModel.swift | 22 ++ .../MyPlaceListTableViewCell.swift | 223 ++++++++++++++++++ .../ChallengeViewController.swift | 9 +- 8 files changed, 347 insertions(+), 3 deletions(-) create mode 100644 AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/PlaceListTable/MyPlaceListModel.swift create mode 100644 AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/PlaceListTable/MyPlaceListTableViewCell.swift diff --git a/AVIRO.xcodeproj/project.pbxproj b/AVIRO.xcodeproj/project.pbxproj index 9f7e2919..6def1d7f 100644 --- a/AVIRO.xcodeproj/project.pbxproj +++ b/AVIRO.xcodeproj/project.pbxproj @@ -16,6 +16,8 @@ C505C1E22B3ACEC00058F115 /* Reactive+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C505C1E12B3ACEC00058F115 /* Reactive+Extension.swift */; }; C505EB162ACC048E0057A4F8 /* Berry2.json in Resources */ = {isa = PBXBuildFile; fileRef = C505EB152ACC048E0057A4F8 /* Berry2.json */; }; C505EB182ACC5AC50057A4F8 /* LaunchScreenViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C505EB172ACC5AC50057A4F8 /* LaunchScreenViewController.swift */; }; + C50B18CB2B94D147005DECDC /* MyPlaceListTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C50B18CA2B94D147005DECDC /* MyPlaceListTableViewCell.swift */; }; + C50B18CD2B94D696005DECDC /* MyPlaceListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C50B18CC2B94D696005DECDC /* MyPlaceListModel.swift */; }; C50DB7422A99DCDA0078B501 /* PlaceListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C50DB7402A99DCDA0078B501 /* PlaceListCell.swift */; }; C50DB7432A99DCDA0078B501 /* SearchPlaceViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C50DB7412A99DCDA0078B501 /* SearchPlaceViewController.swift */; }; C50DB74E2A9B2A8C0078B501 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C50DB74D2A9B2A8C0078B501 /* WebKit.framework */; }; @@ -274,6 +276,8 @@ C505C1E12B3ACEC00058F115 /* Reactive+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Reactive+Extension.swift"; sourceTree = ""; }; C505EB152ACC048E0057A4F8 /* Berry2.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = Berry2.json; sourceTree = ""; }; C505EB172ACC5AC50057A4F8 /* LaunchScreenViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LaunchScreenViewController.swift; sourceTree = ""; }; + C50B18CA2B94D147005DECDC /* MyPlaceListTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPlaceListTableViewCell.swift; sourceTree = ""; }; + C50B18CC2B94D696005DECDC /* MyPlaceListModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPlaceListModel.swift; sourceTree = ""; }; C50DB7402A99DCDA0078B501 /* PlaceListCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlaceListCell.swift; sourceTree = ""; }; C50DB7412A99DCDA0078B501 /* SearchPlaceViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchPlaceViewController.swift; sourceTree = ""; }; C50DB74D2A9B2A8C0078B501 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; }; @@ -620,6 +624,22 @@ path = Custom; sourceTree = ""; }; + C50B18C82B94D11D005DECDC /* New Group */ = { + isa = PBXGroup; + children = ( + ); + path = "New Group"; + sourceTree = ""; + }; + C50B18C92B94D132005DECDC /* PlaceListTable */ = { + isa = PBXGroup; + children = ( + C50B18CA2B94D147005DECDC /* MyPlaceListTableViewCell.swift */, + C50B18CC2B94D696005DECDC /* MyPlaceListModel.swift */, + ); + path = PlaceListTable; + sourceTree = ""; + }; C50DB7372A99D4C80078B501 /* SearchPlaceView */ = { isa = PBXGroup; children = ( @@ -1792,6 +1812,7 @@ C5DCBC942B91D9C9003502BA /* ViewController */ = { isa = PBXGroup; children = ( + C50B18C92B94D132005DECDC /* PlaceListTable */, C5DCBC9C2B91D9F5003502BA /* MyPlaceListViewController.swift */, ); path = ViewController; @@ -1800,6 +1821,7 @@ C5DCBC952B91D9CF003502BA /* ViewController */ = { isa = PBXGroup; children = ( + C50B18C82B94D11D005DECDC /* New Group */, C5DCBCA02B91DA13003502BA /* MyCommentListViewController.swift */, ); path = ViewController; @@ -2185,6 +2207,7 @@ C5C20BAC2AD504D500855BBB /* AmplitudeUtility.swift in Sources */, C513854C2AAB3B52001AB827 /* NickNameChangeblePresenter.swift in Sources */, C5D93DA12A581F5A00629C39 /* FirstRegistrationPresenter.swift in Sources */, + C50B18CD2B94D696005DECDC /* MyPlaceListModel.swift in Sources */, C567C1502A56611500D4B426 /* TopCell.swift in Sources */, C58FBF842AC26D3E00AB6EFC /* APIManagerProtocol.swift in Sources */, C50F6B042A6BCD6900E942F5 /* CategoryButton.swift in Sources */, @@ -2359,6 +2382,7 @@ C593B64B2A4AEA9800D224CE /* AVIROReview+DTO.swift in Sources */, C5C90EB52AA6D80300AB3668 /* EditOperatingHourView.swift in Sources */, C5C90EAF2AA5B7F300AB3668 /* AVIROEditMenuModel+DTO.swift in Sources */, + C50B18CB2B94D147005DECDC /* MyPlaceListTableViewCell.swift in Sources */, C5A201C12A98A5DD00A54381 /* EditLocationTopView.swift in Sources */, C593B64F2A4C490600D224CE /* SettingViewPresenter.swift in Sources */, C5FF13572A42C8970026981D /* AVIROPlaceReviews+DTO.swift in Sources */, diff --git a/AVIRO/Model/HomeViewModel/MarkerModel.swift b/AVIRO/Model/HomeViewModel/MarkerModel.swift index d9a4f366..3ed665d6 100644 --- a/AVIRO/Model/HomeViewModel/MarkerModel.swift +++ b/AVIRO/Model/HomeViewModel/MarkerModel.swift @@ -32,6 +32,19 @@ enum CategoryType { default: return nil } } + + var title: String { + switch self { + case .Bar: + "술집" + case .Bread: + "빵집" + case .Coffee: + "카페" + case .Restaurant: + "식당" + } + } } // MARK: - Map Icon diff --git a/AVIRO/Scene/Feature/Challenge/MyBookmarkList/ViewController/MyBookmarkListViewController.swift b/AVIRO/Scene/Feature/Challenge/MyBookmarkList/ViewController/MyBookmarkListViewController.swift index 0b702c56..f94c2759 100644 --- a/AVIRO/Scene/Feature/Challenge/MyBookmarkList/ViewController/MyBookmarkListViewController.swift +++ b/AVIRO/Scene/Feature/Challenge/MyBookmarkList/ViewController/MyBookmarkListViewController.swift @@ -57,6 +57,12 @@ final class MyBookmarkListViewController: UIViewController { setupAttribute() } + override func viewWillDisappear(_ animated: Bool) { + super.viewWillDisappear(animated) + + self.tabBarDelegate?.isHidden = (false, true) + } + private func setupLayout() { [ bookmarkTableView diff --git a/AVIRO/Scene/Feature/Challenge/MyCommentList/ViewController/MyCommentListViewController.swift b/AVIRO/Scene/Feature/Challenge/MyCommentList/ViewController/MyCommentListViewController.swift index 345d16ce..91baef11 100644 --- a/AVIRO/Scene/Feature/Challenge/MyCommentList/ViewController/MyCommentListViewController.swift +++ b/AVIRO/Scene/Feature/Challenge/MyCommentList/ViewController/MyCommentListViewController.swift @@ -57,6 +57,12 @@ final class MyCommentListViewController: UIViewController { setupAttribute() } + override func viewWillDisappear(_ animated: Bool) { + super.viewWillDisappear(animated) + + self.tabBarDelegate?.isHidden = (false, true) + } + private func setupLayout() { [ commentTableView diff --git a/AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/MyPlaceListViewController.swift b/AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/MyPlaceListViewController.swift index a0a42220..4623aa83 100644 --- a/AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/MyPlaceListViewController.swift +++ b/AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/MyPlaceListViewController.swift @@ -20,6 +20,14 @@ final class MyPlaceListViewController: UIViewController { let view = UITableView() view.backgroundColor = .gray6 + view.separatorStyle = .none + view.showsVerticalScrollIndicator = false + view.dataSource = self + view.delegate = self + view.register( + MyPlaceListTableViewCell.self, + forCellReuseIdentifier: MyPlaceListTableViewCell.identifier + ) return view }() @@ -57,6 +65,12 @@ final class MyPlaceListViewController: UIViewController { setupAttribute() } + override func viewWillDisappear(_ animated: Bool) { + super.viewWillDisappear(animated) + + self.tabBarDelegate?.isHidden = (false, true) + } + private func setupLayout() { [ placeTableView @@ -66,7 +80,7 @@ final class MyPlaceListViewController: UIViewController { } NSLayoutConstraint.activate([ - placeTableView.topAnchor.constraint(equalTo: self.view.topAnchor), + placeTableView.topAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.topAnchor), placeTableView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor), placeTableView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor), placeTableView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor) @@ -87,3 +101,34 @@ final class MyPlaceListViewController: UIViewController { setupBack(true) } } + +extension MyPlaceListViewController: UITableViewDataSource { + func tableView( + _ tableView: UITableView, + numberOfRowsInSection section: Int + ) -> Int { + 6 + } + + func tableView( + _ tableView: UITableView, + cellForRowAt indexPath: IndexPath + ) -> UITableViewCell { + guard let cell = tableView.dequeueReusableCell(withIdentifier: MyPlaceListTableViewCell.identifier, for: indexPath) as? MyPlaceListTableViewCell else { + return UITableViewCell() + } + + let model = MyPlaceListModel(category: .Bar, all: true, some: false, request: false, title: "테스트", address: "테스트주소입니다", menu: "테스트메뉴테스트메뉴테스트메뉴테스트메뉴테스트메뉴", menuCount: "3", time: "5일 전") + cell.configuration(with: model) + + cell.selectionStyle = .none + + return cell + } +} + +extension MyPlaceListViewController: UITableViewDelegate { + func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { + 142 + } +} diff --git a/AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/PlaceListTable/MyPlaceListModel.swift b/AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/PlaceListTable/MyPlaceListModel.swift new file mode 100644 index 00000000..22e2c99d --- /dev/null +++ b/AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/PlaceListTable/MyPlaceListModel.swift @@ -0,0 +1,22 @@ +// +// MyPlaceListModel.swift +// AVIRO +// +// Created by 전성훈 on 2024/03/04. +// + +// Clean Architecture 적용 시 Domain으로 옮길 예정 + +import Foundation + +struct MyPlaceListModel { + let category: CategoryType + let all: Bool + let some: Bool + let request: Bool + let title: String + let address: String + let menu: String + let menuCount: String + let time: String +} diff --git a/AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/PlaceListTable/MyPlaceListTableViewCell.swift b/AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/PlaceListTable/MyPlaceListTableViewCell.swift new file mode 100644 index 00000000..0bd86d8e --- /dev/null +++ b/AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/PlaceListTable/MyPlaceListTableViewCell.swift @@ -0,0 +1,223 @@ +// +// MyPlaceListTableViewCell.swift +// AVIRO +// +// Created by 전성훈 on 2024/03/04. +// + +import UIKit + +final class MyPlaceListTableViewCell: UITableViewCell { + static let identifier = MyPlaceListTableViewCell.description() + + private lazy var iconImageView: UIImageView = { + let view = UIImageView() + + view.backgroundColor = .gray5 + view.layer.cornerRadius = 10.3 + view.clipsToBounds = true + + return view + }() + + private lazy var categoryLabel: UILabel = { + let lbl = UILabel() + + lbl.textAlignment = .center + lbl.font = .pretendard(size: 14, weight: .bold) + lbl.numberOfLines = 1 + lbl.layer.cornerRadius = 7.5 + lbl.backgroundColor = .gray5 + lbl.textColor = .white + lbl.clipsToBounds = true + + return lbl + }() + + private lazy var titleLabel: UILabel = { + let lbl = UILabel() + + lbl.textAlignment = .left + lbl.font = .pretendard(size: 20, weight: .bold) + lbl.numberOfLines = 1 + lbl.textColor = .gray0 + + return lbl + }() + + private lazy var addressLabel: UILabel = { + let lbl = UILabel() + + lbl.textAlignment = .left + lbl.font = .pretendard(size: 16, weight: .medium) + lbl.numberOfLines = 1 + lbl.textColor = .gray0 + + return lbl + }() + + private lazy var menuLabel: UILabel = { + let lbl = UILabel() + + lbl.textAlignment = .left + lbl.font = .pretendard(size: 16, weight: .regular) + lbl.numberOfLines = 1 + lbl.lineBreakMode = .byTruncatingTail + lbl.textColor = .gray3 + + return lbl + }() + + private lazy var menuCountLabel: UILabel = { + let lbl = UILabel() + + lbl.textAlignment = .left + lbl.font = .pretendard(size: 16, weight: .regular) + lbl.numberOfLines = 1 + lbl.textColor = .gray3 + + return lbl + }() + + private lazy var enrollTimeLabel: UILabel = { + let lbl = UILabel() + + lbl.textAlignment = .left + lbl.font = .pretendard(size: 14, weight: .regular) + lbl.numberOfLines = 1 + lbl.textColor = .gray3 + + return lbl + }() + + private lazy var mainView: UIView = { + let view = UIView() + + view.backgroundColor = .gray7 + view.layer.cornerRadius = 15 + + return view + }() + + private lazy var separatorView: UIView = { + let view = UIView() + + view.backgroundColor = .gray6 + + return view + }() + + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + super.init(style: style, reuseIdentifier: reuseIdentifier) + + setupLayout() + setupAttribute() + } + + required init?(coder: NSCoder) { + fatalError() + } + + override func prepareForReuse() { + super.prepareForReuse() + + initConfiguration() + } + + private func setupLayout() { + [ + mainView, + separatorView + ].forEach { + $0.translatesAutoresizingMaskIntoConstraints = false + self.contentView.addSubview($0) + } + + NSLayoutConstraint.activate([ + mainView.topAnchor.constraint(equalTo: self.contentView.topAnchor), + mainView.leadingAnchor.constraint(equalTo: self.contentView.leadingAnchor, constant: 16), + mainView.trailingAnchor.constraint(equalTo: self.contentView.trailingAnchor, constant: -16), + mainView.heightAnchor.constraint(equalToConstant: 130), + + separatorView.topAnchor.constraint(equalTo: mainView.bottomAnchor), + separatorView.leadingAnchor.constraint(equalTo: mainView.leadingAnchor), + separatorView.trailingAnchor.constraint(equalTo: mainView.trailingAnchor), + separatorView.heightAnchor.constraint(equalToConstant: 12) + ]) + + [ + iconImageView, + categoryLabel, + titleLabel, + addressLabel, + menuLabel, + menuCountLabel, + enrollTimeLabel + ].forEach { + $0.translatesAutoresizingMaskIntoConstraints = false + mainView.addSubview($0) + } + + NSLayoutConstraint.activate([ + iconImageView.topAnchor.constraint(equalTo: mainView.topAnchor, constant: 20), + iconImageView.leadingAnchor.constraint(equalTo: mainView.leadingAnchor, constant: 16), + iconImageView.widthAnchor.constraint(equalToConstant: 59), + iconImageView.heightAnchor.constraint(equalToConstant: 59), + + categoryLabel.topAnchor.constraint(equalTo: iconImageView.bottomAnchor, constant: 4.5), + categoryLabel.leadingAnchor.constraint(equalTo: iconImageView.leadingAnchor), + categoryLabel.heightAnchor.constraint(equalToConstant: 26.5), + categoryLabel.widthAnchor.constraint(equalToConstant: 59), + + titleLabel.topAnchor.constraint(equalTo: iconImageView.topAnchor), + titleLabel.leadingAnchor.constraint(equalTo: iconImageView.trailingAnchor, constant: 14), + titleLabel.trailingAnchor.constraint(equalTo: mainView.trailingAnchor, constant: -14), + + addressLabel.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: 3), + addressLabel.leadingAnchor.constraint(equalTo: titleLabel.leadingAnchor), + addressLabel.trailingAnchor.constraint(equalTo: titleLabel.trailingAnchor), + + menuLabel.topAnchor.constraint(equalTo: addressLabel.bottomAnchor, constant: 3), + menuLabel.leadingAnchor.constraint(equalTo: titleLabel.leadingAnchor), + menuLabel.trailingAnchor.constraint(equalTo: menuCountLabel.leadingAnchor, constant: -4), + + menuCountLabel.topAnchor.constraint(equalTo: menuLabel.topAnchor), + menuCountLabel.trailingAnchor.constraint( + lessThanOrEqualTo: mainView.trailingAnchor, + constant: -14), + menuCountLabel.widthAnchor.constraint(equalToConstant: 78), + + enrollTimeLabel.topAnchor.constraint(equalTo: menuLabel.bottomAnchor, constant: 3), + enrollTimeLabel.leadingAnchor.constraint(equalTo: titleLabel.leadingAnchor), + enrollTimeLabel.trailingAnchor.constraint(equalTo: titleLabel.trailingAnchor) + ]) + } + + private func setupAttribute() { + self.backgroundColor = .clear + } + + private func initConfiguration() { + iconImageView.image = nil + categoryLabel.text = "" + categoryLabel.backgroundColor = .clear + titleLabel.text = "" + addressLabel.text = "" + menuLabel.text = "" + menuCountLabel.text = "" + enrollTimeLabel.text = "" + } + + // TODO: - 변경 예정 + func configuration(with model: MyPlaceListModel) { + iconImageView.image = .allBoxBar + categoryLabel.text = model.category.title + categoryLabel.backgroundColor = .all + + titleLabel.text = model.title + addressLabel.text = model.address + menuLabel.text = model.menu + menuCountLabel.text = "외 " + model.menuCount + "개 메뉴" + enrollTimeLabel.text = model.time + } +} diff --git a/AVIRO/Scene/Feature/Challenge/ViewController/ChallengeViewController.swift b/AVIRO/Scene/Feature/Challenge/ViewController/ChallengeViewController.swift index e0113d12..62cba2b6 100644 --- a/AVIRO/Scene/Feature/Challenge/ViewController/ChallengeViewController.swift +++ b/AVIRO/Scene/Feature/Challenge/ViewController/ChallengeViewController.swift @@ -276,21 +276,26 @@ final class ChallengeViewController: UIViewController { } private func pushMyInfo(with myInfoType: MyInfoType) { + self.tabBarDelegate?.isHidden = (true, true) + switch myInfoType { case .place: let viewModel = MyPlaceListViewModel() let vc = MyPlaceListViewController.create(with: viewModel) + vc.tabBarDelegate = self.tabBarDelegate navigationController?.pushViewController(vc, animated: true) case .review: let viewModel = MyCommentListViewModel() let vc = MyCommentListViewController.create(with: viewModel) - + vc.tabBarDelegate = self.tabBarDelegate + navigationController?.pushViewController(vc, animated: true) case .bookmark: let viewModel = MyBookmarkListViewModel() let vc = MyBookmarkListViewController.create(with: viewModel) - + vc.tabBarDelegate = self.tabBarDelegate + navigationController?.pushViewController(vc, animated: true) } } From 00260296338880079767dbb615281f3a262ca0bb Mon Sep 17 00:00:00 2001 From: Jeon Seoung Hun Date: Mon, 4 Mar 2024 23:12:10 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[Feat]:=20Bookmark,=20Comment=20UI=20?= =?UTF-8?q?=EC=84=A4=EA=B3=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AVIRO.xcodeproj/project.pbxproj | 48 +++- .../Extension/UITextView+Extension.swift | 18 ++ .../MyBookmarkListViewController.swift | 47 +++- .../MyBookmarkTable/MyBookmarkCellModel.swift | 21 ++ .../MyBookmarkListTableViewCell.swift | 250 ++++++++++++++++++ .../MyCommentCellModel.swift | 19 ++ .../MyCommentListTableViewCell.swift | 248 +++++++++++++++++ .../MyCommentListViewController.swift | 48 ++++ .../MyPlaceCellModel.swift} | 4 +- .../MyPlaceListTableViewCell.swift | 2 +- .../MyPlaceListViewController.swift | 2 +- 11 files changed, 692 insertions(+), 15 deletions(-) create mode 100644 AVIRO/Custom/Extension/UITextView+Extension.swift create mode 100644 AVIRO/Scene/Feature/Challenge/MyBookmarkList/ViewController/MyBookmarkTable/MyBookmarkCellModel.swift create mode 100644 AVIRO/Scene/Feature/Challenge/MyBookmarkList/ViewController/MyBookmarkTable/MyBookmarkListTableViewCell.swift create mode 100644 AVIRO/Scene/Feature/Challenge/MyCommentList/ViewController/MyCommentListTable/MyCommentCellModel.swift create mode 100644 AVIRO/Scene/Feature/Challenge/MyCommentList/ViewController/MyCommentListTable/MyCommentListTableViewCell.swift rename AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/{PlaceListTable/MyPlaceListModel.swift => MyPlaceListTable/MyPlaceCellModel.swift} (86%) rename AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/{PlaceListTable => MyPlaceListTable}/MyPlaceListTableViewCell.swift (99%) diff --git a/AVIRO.xcodeproj/project.pbxproj b/AVIRO.xcodeproj/project.pbxproj index 6def1d7f..3f2044db 100644 --- a/AVIRO.xcodeproj/project.pbxproj +++ b/AVIRO.xcodeproj/project.pbxproj @@ -17,7 +17,7 @@ C505EB162ACC048E0057A4F8 /* Berry2.json in Resources */ = {isa = PBXBuildFile; fileRef = C505EB152ACC048E0057A4F8 /* Berry2.json */; }; C505EB182ACC5AC50057A4F8 /* LaunchScreenViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C505EB172ACC5AC50057A4F8 /* LaunchScreenViewController.swift */; }; C50B18CB2B94D147005DECDC /* MyPlaceListTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C50B18CA2B94D147005DECDC /* MyPlaceListTableViewCell.swift */; }; - C50B18CD2B94D696005DECDC /* MyPlaceListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C50B18CC2B94D696005DECDC /* MyPlaceListModel.swift */; }; + C50B18CD2B94D696005DECDC /* MyPlaceCellModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C50B18CC2B94D696005DECDC /* MyPlaceCellModel.swift */; }; C50DB7422A99DCDA0078B501 /* PlaceListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C50DB7402A99DCDA0078B501 /* PlaceListCell.swift */; }; C50DB7432A99DCDA0078B501 /* SearchPlaceViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C50DB7412A99DCDA0078B501 /* SearchPlaceViewController.swift */; }; C50DB74E2A9B2A8C0078B501 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C50DB74D2A9B2A8C0078B501 /* WebKit.framework */; }; @@ -116,6 +116,11 @@ C5476B792B314F6F00F5FC6E /* LicensesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5476B782B314F6F00F5FC6E /* LicensesViewController.swift */; }; C5476B7B2B31516000F5FC6E /* LicenseDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5476B7A2B31516000F5FC6E /* LicenseDetailViewController.swift */; }; C547A8BA2A17D8D4004D1339 /* KakaoAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = C547A8B92A17D8D4004D1339 /* KakaoAPI.swift */; }; + C54B59172B95F3D000C0B190 /* MyBookmarkListTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C54B59162B95F3D000C0B190 /* MyBookmarkListTableViewCell.swift */; }; + C54B59192B95F3DA00C0B190 /* MyBookmarkCellModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C54B59182B95F3DA00C0B190 /* MyBookmarkCellModel.swift */; }; + C54B591B2B95F61200C0B190 /* MyCommentCellModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C54B591A2B95F61200C0B190 /* MyCommentCellModel.swift */; }; + C54B591D2B95F61F00C0B190 /* MyCommentListTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C54B591C2B95F61F00C0B190 /* MyCommentListTableViewCell.swift */; }; + C54B591F2B9606C500C0B190 /* UITextView+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C54B591E2B9606C500C0B190 /* UITextView+Extension.swift */; }; C54B76612B88B2D10095E110 /* FranchiseToggleButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = C54B76602B88B2D10095E110 /* FranchiseToggleButton.swift */; }; C54BC0DB2A2C2D0D00B65439 /* UIColor+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C54BC0DA2A2C2D0D00B65439 /* UIColor+Extension.swift */; }; C552D5342ABE8CA500933D8A /* AVIRODeleteAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = C552D5332ABE8CA500933D8A /* AVIRODeleteAPI.swift */; }; @@ -277,7 +282,7 @@ C505EB152ACC048E0057A4F8 /* Berry2.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = Berry2.json; sourceTree = ""; }; C505EB172ACC5AC50057A4F8 /* LaunchScreenViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LaunchScreenViewController.swift; sourceTree = ""; }; C50B18CA2B94D147005DECDC /* MyPlaceListTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPlaceListTableViewCell.swift; sourceTree = ""; }; - C50B18CC2B94D696005DECDC /* MyPlaceListModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPlaceListModel.swift; sourceTree = ""; }; + C50B18CC2B94D696005DECDC /* MyPlaceCellModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPlaceCellModel.swift; sourceTree = ""; }; C50DB7402A99DCDA0078B501 /* PlaceListCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlaceListCell.swift; sourceTree = ""; }; C50DB7412A99DCDA0078B501 /* SearchPlaceViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchPlaceViewController.swift; sourceTree = ""; }; C50DB74D2A9B2A8C0078B501 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; }; @@ -380,6 +385,11 @@ C5476B782B314F6F00F5FC6E /* LicensesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LicensesViewController.swift; sourceTree = ""; }; C5476B7A2B31516000F5FC6E /* LicenseDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LicenseDetailViewController.swift; sourceTree = ""; }; C547A8B92A17D8D4004D1339 /* KakaoAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KakaoAPI.swift; sourceTree = ""; }; + C54B59162B95F3D000C0B190 /* MyBookmarkListTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyBookmarkListTableViewCell.swift; sourceTree = ""; }; + C54B59182B95F3DA00C0B190 /* MyBookmarkCellModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyBookmarkCellModel.swift; sourceTree = ""; }; + C54B591A2B95F61200C0B190 /* MyCommentCellModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyCommentCellModel.swift; sourceTree = ""; }; + C54B591C2B95F61F00C0B190 /* MyCommentListTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyCommentListTableViewCell.swift; sourceTree = ""; }; + C54B591E2B9606C500C0B190 /* UITextView+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITextView+Extension.swift"; sourceTree = ""; }; C54B76602B88B2D10095E110 /* FranchiseToggleButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FranchiseToggleButton.swift; sourceTree = ""; }; C54BC0DA2A2C2D0D00B65439 /* UIColor+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+Extension.swift"; sourceTree = ""; }; C552D5332ABE8CA500933D8A /* AVIRODeleteAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AVIRODeleteAPI.swift; sourceTree = ""; }; @@ -624,20 +634,22 @@ path = Custom; sourceTree = ""; }; - C50B18C82B94D11D005DECDC /* New Group */ = { + C50B18C82B94D11D005DECDC /* MyCommentListTable */ = { isa = PBXGroup; children = ( + C54B591C2B95F61F00C0B190 /* MyCommentListTableViewCell.swift */, + C54B591A2B95F61200C0B190 /* MyCommentCellModel.swift */, ); - path = "New Group"; + path = MyCommentListTable; sourceTree = ""; }; - C50B18C92B94D132005DECDC /* PlaceListTable */ = { + C50B18C92B94D132005DECDC /* MyPlaceListTable */ = { isa = PBXGroup; children = ( C50B18CA2B94D147005DECDC /* MyPlaceListTableViewCell.swift */, - C50B18CC2B94D696005DECDC /* MyPlaceListModel.swift */, + C50B18CC2B94D696005DECDC /* MyPlaceCellModel.swift */, ); - path = PlaceListTable; + path = MyPlaceListTable; sourceTree = ""; }; C50DB7372A99D4C80078B501 /* SearchPlaceView */ = { @@ -730,6 +742,7 @@ C59491D22AB0336100880B4B /* UIView+Extension.swift */, C51AED222A8B7B000015FBC2 /* UIViewController+Extension.swift */, C51B09BB2A82397800916BBD /* Marker+Extension.swift */, + C54B591E2B9606C500C0B190 /* UITextView+Extension.swift */, ); path = Extension; sourceTree = ""; @@ -1254,6 +1267,15 @@ path = LicenseView; sourceTree = ""; }; + C54B59152B95F39900C0B190 /* MyBookmarkTable */ = { + isa = PBXGroup; + children = ( + C54B59162B95F3D000C0B190 /* MyBookmarkListTableViewCell.swift */, + C54B59182B95F3DA00C0B190 /* MyBookmarkCellModel.swift */, + ); + path = MyBookmarkTable; + sourceTree = ""; + }; C54BC0D82A2C2CEE00B65439 /* UIButton */ = { isa = PBXGroup; children = ( @@ -1812,7 +1834,7 @@ C5DCBC942B91D9C9003502BA /* ViewController */ = { isa = PBXGroup; children = ( - C50B18C92B94D132005DECDC /* PlaceListTable */, + C50B18C92B94D132005DECDC /* MyPlaceListTable */, C5DCBC9C2B91D9F5003502BA /* MyPlaceListViewController.swift */, ); path = ViewController; @@ -1821,7 +1843,7 @@ C5DCBC952B91D9CF003502BA /* ViewController */ = { isa = PBXGroup; children = ( - C50B18C82B94D11D005DECDC /* New Group */, + C50B18C82B94D11D005DECDC /* MyCommentListTable */, C5DCBCA02B91DA13003502BA /* MyCommentListViewController.swift */, ); path = ViewController; @@ -1838,6 +1860,7 @@ C5DCBC972B91D9D7003502BA /* ViewController */ = { isa = PBXGroup; children = ( + C54B59152B95F39900C0B190 /* MyBookmarkTable */, C5DCBCA42B91DA36003502BA /* MyBookmarkListViewController.swift */, ); path = ViewController; @@ -2194,6 +2217,7 @@ files = ( C5476B792B314F6F00F5FC6E /* LicensesViewController.swift in Sources */, C5C2907E2A85E69B00ED5DCE /* UnderlineSegmentedControl.swift in Sources */, + C54B591B2B95F61200C0B190 /* MyCommentCellModel.swift in Sources */, C5A3C3C42A39658A0050AB3D /* LoginViewController.swift in Sources */, C58EC7CC2AB171C000401FF7 /* UIButton+Extension.swift in Sources */, C5732C732A41778A00CDC499 /* AVIROPostAPI.swift in Sources */, @@ -2207,7 +2231,7 @@ C5C20BAC2AD504D500855BBB /* AmplitudeUtility.swift in Sources */, C513854C2AAB3B52001AB827 /* NickNameChangeblePresenter.swift in Sources */, C5D93DA12A581F5A00629C39 /* FirstRegistrationPresenter.swift in Sources */, - C50B18CD2B94D696005DECDC /* MyPlaceListModel.swift in Sources */, + C50B18CD2B94D696005DECDC /* MyPlaceCellModel.swift in Sources */, C567C1502A56611500D4B426 /* TopCell.swift in Sources */, C58FBF842AC26D3E00AB6EFC /* APIManagerProtocol.swift in Sources */, C50F6B042A6BCD6900E942F5 /* CategoryButton.swift in Sources */, @@ -2226,6 +2250,7 @@ C52066292A7CD5FC0038ECCD /* HistoryTableModel.swift in Sources */, C5FD92EB2A9C786600CF4673 /* PublicAPIRequestComponents.swift in Sources */, C58C49C82AC9B67600DE04B7 /* AppleUserLoginModel.swift in Sources */, + C54B591F2B9606C500C0B190 /* UITextView+Extension.swift in Sources */, C58FBF902AC2B83A00AB6EFC /* AVIROAPIManagerProtocol.swift in Sources */, C5DCBC9F2B91D9FE003502BA /* MyCommentListViewModel.swift in Sources */, C50F6AF52A68FD6300E942F5 /* EnrollPlacePresenter.swift in Sources */, @@ -2271,6 +2296,7 @@ C5D93DA32A58718300629C39 /* NextPageButton.swift in Sources */, C50DB7512A9B83550078B501 /* ChangeableAddressViewController.swift in Sources */, C5A989992A959E040021B7C3 /* AVIROBookmark+DTO.swift in Sources */, + C54B591D2B95F61F00C0B190 /* MyCommentListTableViewCell.swift in Sources */, C5476B6E2B30760000F5FC6E /* ChallengeLevelView.swift in Sources */, C51000582AB939A200F65C1F /* NoResultLabel.swift in Sources */, C5D802722B3C6E5E00136D0E /* LevelUpAlertView.swift in Sources */, @@ -2321,6 +2347,7 @@ C510005E2ABAA3C700F65C1F /* Enum+.swift in Sources */, C58FBF942AC2DB6D00AB6EFC /* KakaoKeywordResultDTO.swift in Sources */, C51B09B82A82155200916BBD /* MarkerModelCache.swift in Sources */, + C54B59172B95F3D000C0B190 /* MyBookmarkListTableViewCell.swift in Sources */, C5A9899B2A95A6B50021B7C3 /* BookmarkCache.swift in Sources */, C52651DE2B7FB8B0002038CF /* CategoryCollectionViewCell.swift in Sources */, C520662D2A7CE1CC0038ECCD /* SearchHistoryManager.swift in Sources */, @@ -2376,6 +2403,7 @@ C52066312A7E4A580038ECCD /* AVIROMainSearchCompare+DTO.swift in Sources */, C5C9619F2A8DEB230016E2F8 /* ReviewWriteButton.swift in Sources */, C5DCBC9A2B91D9E9003502BA /* MyPlaceListViewModel.swift in Sources */, + C54B59192B95F3DA00C0B190 /* MyBookmarkCellModel.swift in Sources */, C5E143A72AB43B8F007AC8C9 /* AVIROResult+DTO.swift in Sources */, C505C1E02B3ACCEC0058F115 /* AVIROMyChallengeLevelResult+DTO.swift in Sources */, C5E430B52A5DAE9800CB67EC /* SecondRegistrationViewController.swift in Sources */, diff --git a/AVIRO/Custom/Extension/UITextView+Extension.swift b/AVIRO/Custom/Extension/UITextView+Extension.swift new file mode 100644 index 00000000..cbb48632 --- /dev/null +++ b/AVIRO/Custom/Extension/UITextView+Extension.swift @@ -0,0 +1,18 @@ +// +// UITextView+Extension.swift +// AVIRO +// +// Created by 전성훈 on 2024/03/04. +// + +import UIKit + +extension UITextView { + func numberOfLine() -> Int { + + let size = CGSize(width: frame.width, height: .infinity) + let estimatedSize = sizeThatFits(size) + + return Int(estimatedSize.height / (self.font!.lineHeight)) + } +} diff --git a/AVIRO/Scene/Feature/Challenge/MyBookmarkList/ViewController/MyBookmarkListViewController.swift b/AVIRO/Scene/Feature/Challenge/MyBookmarkList/ViewController/MyBookmarkListViewController.swift index f94c2759..4a610c9f 100644 --- a/AVIRO/Scene/Feature/Challenge/MyBookmarkList/ViewController/MyBookmarkListViewController.swift +++ b/AVIRO/Scene/Feature/Challenge/MyBookmarkList/ViewController/MyBookmarkListViewController.swift @@ -20,6 +20,14 @@ final class MyBookmarkListViewController: UIViewController { let view = UITableView() view.backgroundColor = .gray6 + view.separatorStyle = .none + view.showsVerticalScrollIndicator = false + view.dataSource = self + view.delegate = self + view.register( + MyBookmarkListTableViewCell.self, + forCellReuseIdentifier: MyBookmarkListTableViewCell.identifier + ) return view }() @@ -72,7 +80,7 @@ final class MyBookmarkListViewController: UIViewController { } NSLayoutConstraint.activate([ - bookmarkTableView.topAnchor.constraint(equalTo: self.view.topAnchor), + bookmarkTableView.topAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.topAnchor), bookmarkTableView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor), bookmarkTableView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor), bookmarkTableView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor) @@ -93,3 +101,40 @@ final class MyBookmarkListViewController: UIViewController { setupBack(true) } } + +extension MyBookmarkListViewController: UITableViewDataSource { + func tableView( + _ tableView: UITableView, + numberOfRowsInSection section: Int + ) -> Int { + 6 + } + + func tableView( + _ tableView: UITableView, + cellForRowAt indexPath: IndexPath + ) -> UITableViewCell { + guard let cell = tableView.dequeueReusableCell( + withIdentifier: MyBookmarkListTableViewCell.identifier, + for: indexPath + ) as? MyBookmarkListTableViewCell else { + return UITableViewCell() + } + + let model = MyBookmarkCellModel( + category: .Bar, all: true, some: false, request: false, title: "테스트", address: "테스트주소입니다", menu: "테스트메뉴테스트메뉴테스트메뉴테스트메뉴테스트메뉴", menuCount: "3", time: "5일 전", isStar: true + ) + + cell.configuration(with: model) + + cell.selectionStyle = .none + + return cell + } +} + +extension MyBookmarkListViewController: UITableViewDelegate { + func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { + 142 + } +} diff --git a/AVIRO/Scene/Feature/Challenge/MyBookmarkList/ViewController/MyBookmarkTable/MyBookmarkCellModel.swift b/AVIRO/Scene/Feature/Challenge/MyBookmarkList/ViewController/MyBookmarkTable/MyBookmarkCellModel.swift new file mode 100644 index 00000000..6faab9a6 --- /dev/null +++ b/AVIRO/Scene/Feature/Challenge/MyBookmarkList/ViewController/MyBookmarkTable/MyBookmarkCellModel.swift @@ -0,0 +1,21 @@ +// +// MyBookmarkCellModel.swift +// AVIRO +// +// Created by 전성훈 on 2024/03/04. +// + +import Foundation + +struct MyBookmarkCellModel { + let category: CategoryType + let all: Bool + let some: Bool + let request: Bool + let title: String + let address: String + let menu: String + let menuCount: String + let time: String + let isStar: Bool +} diff --git a/AVIRO/Scene/Feature/Challenge/MyBookmarkList/ViewController/MyBookmarkTable/MyBookmarkListTableViewCell.swift b/AVIRO/Scene/Feature/Challenge/MyBookmarkList/ViewController/MyBookmarkTable/MyBookmarkListTableViewCell.swift new file mode 100644 index 00000000..3ea493c8 --- /dev/null +++ b/AVIRO/Scene/Feature/Challenge/MyBookmarkList/ViewController/MyBookmarkTable/MyBookmarkListTableViewCell.swift @@ -0,0 +1,250 @@ +// +// MyBookmarkListTableViewCell.swift +// AVIRO +// +// Created by 전성훈 on 2024/03/04. +// + +import UIKit + +final class MyBookmarkListTableViewCell: UITableViewCell { + static let identifier = MyBookmarkListTableViewCell.description() + + private lazy var iconImageView: UIImageView = { + let view = UIImageView() + + view.backgroundColor = .gray5 + view.layer.cornerRadius = 10.3 + view.clipsToBounds = true + + return view + }() + + private lazy var categoryLabel: UILabel = { + let lbl = UILabel() + + lbl.textAlignment = .center + lbl.font = .pretendard(size: 14, weight: .bold) + lbl.numberOfLines = 1 + lbl.layer.cornerRadius = 7.5 + lbl.backgroundColor = .gray5 + lbl.textColor = .white + lbl.clipsToBounds = true + + return lbl + }() + + private lazy var titleLabel: UILabel = { + let lbl = UILabel() + + lbl.textAlignment = .left + lbl.font = .pretendard(size: 20, weight: .bold) + lbl.numberOfLines = 1 + lbl.textColor = .gray0 + + return lbl + }() + + private lazy var starButton: UIButton = { + let btn = UIButton() + + btn.setImage(.starIconDisable.withTintColor(.gray4), for: .normal) + btn.setImage(.starIconClicked, for: .selected) + btn.addTarget(self, action: #selector(tappedStarButton(_:)), for: .touchUpInside) + + return btn + }() + + private lazy var addressLabel: UILabel = { + let lbl = UILabel() + + lbl.textAlignment = .left + lbl.font = .pretendard(size: 16, weight: .medium) + lbl.numberOfLines = 1 + lbl.textColor = .gray0 + + return lbl + }() + + private lazy var menuLabel: UILabel = { + let lbl = UILabel() + + lbl.textAlignment = .left + lbl.font = .pretendard(size: 16, weight: .regular) + lbl.numberOfLines = 1 + lbl.lineBreakMode = .byTruncatingTail + lbl.textColor = .gray3 + + return lbl + }() + + private lazy var menuCountLabel: UILabel = { + let lbl = UILabel() + + lbl.textAlignment = .left + lbl.font = .pretendard(size: 16, weight: .regular) + lbl.numberOfLines = 1 + lbl.textColor = .gray3 + + return lbl + }() + + private lazy var enrollTimeLabel: UILabel = { + let lbl = UILabel() + + lbl.textAlignment = .left + lbl.font = .pretendard(size: 14, weight: .regular) + lbl.numberOfLines = 1 + lbl.textColor = .gray3 + + return lbl + }() + + private lazy var mainView: UIView = { + let view = UIView() + + view.backgroundColor = .gray7 + view.layer.cornerRadius = 15 + + return view + }() + + private lazy var separatorView: UIView = { + let view = UIView() + + view.backgroundColor = .gray6 + + return view + }() + + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + super.init(style: style, reuseIdentifier: reuseIdentifier) + + setupLayout() + setupAttribute() + } + + required init?(coder: NSCoder) { + fatalError() + } + + override func prepareForReuse() { + super.prepareForReuse() + + initConfiguration() + } + + private func setupLayout() { + [ + mainView, + separatorView + ].forEach { + $0.translatesAutoresizingMaskIntoConstraints = false + self.contentView.addSubview($0) + } + + NSLayoutConstraint.activate([ + mainView.topAnchor.constraint(equalTo: self.contentView.topAnchor), + mainView.leadingAnchor.constraint(equalTo: self.contentView.leadingAnchor, constant: 16), + mainView.trailingAnchor.constraint(equalTo: self.contentView.trailingAnchor, constant: -16), + mainView.heightAnchor.constraint(equalToConstant: 130), + + separatorView.topAnchor.constraint(equalTo: mainView.bottomAnchor), + separatorView.leadingAnchor.constraint(equalTo: mainView.leadingAnchor), + separatorView.trailingAnchor.constraint(equalTo: mainView.trailingAnchor), + separatorView.heightAnchor.constraint(equalToConstant: 12) + ]) + + [ + iconImageView, + categoryLabel, + titleLabel, + starButton, + addressLabel, + menuLabel, + menuCountLabel, + enrollTimeLabel + ].forEach { + $0.translatesAutoresizingMaskIntoConstraints = false + mainView.addSubview($0) + } + + NSLayoutConstraint.activate([ + iconImageView.topAnchor.constraint(equalTo: mainView.topAnchor, constant: 20), + iconImageView.leadingAnchor.constraint(equalTo: mainView.leadingAnchor, constant: 16), + iconImageView.widthAnchor.constraint(equalToConstant: 59), + iconImageView.heightAnchor.constraint(equalToConstant: 59), + + categoryLabel.topAnchor.constraint(equalTo: iconImageView.bottomAnchor, constant: 4.5), + categoryLabel.leadingAnchor.constraint(equalTo: iconImageView.leadingAnchor), + categoryLabel.heightAnchor.constraint(equalToConstant: 26.5), + categoryLabel.widthAnchor.constraint(equalToConstant: 59), + + titleLabel.topAnchor.constraint(equalTo: iconImageView.topAnchor), + titleLabel.leadingAnchor.constraint(equalTo: iconImageView.trailingAnchor, constant: 14), + titleLabel.trailingAnchor.constraint(equalTo: starButton.leadingAnchor, constant: -14), + + starButton.topAnchor.constraint(equalTo: iconImageView.topAnchor), + starButton.trailingAnchor.constraint(equalTo: mainView.trailingAnchor, constant: -16), + starButton.widthAnchor.constraint(equalToConstant: 24), + starButton.heightAnchor.constraint(equalToConstant: 24), + + addressLabel.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: 3), + addressLabel.leadingAnchor.constraint(equalTo: titleLabel.leadingAnchor), + addressLabel.trailingAnchor.constraint(equalTo: titleLabel.trailingAnchor), + + menuLabel.topAnchor.constraint(equalTo: addressLabel.bottomAnchor, constant: 3), + menuLabel.leadingAnchor.constraint(equalTo: titleLabel.leadingAnchor), + menuLabel.trailingAnchor.constraint(equalTo: menuCountLabel.leadingAnchor, constant: -4), + + menuCountLabel.topAnchor.constraint(equalTo: menuLabel.topAnchor), + menuCountLabel.trailingAnchor.constraint( + lessThanOrEqualTo: mainView.trailingAnchor, + constant: -14), + menuCountLabel.widthAnchor.constraint(equalToConstant: 78), + + enrollTimeLabel.topAnchor.constraint(equalTo: menuLabel.bottomAnchor, constant: 3), + enrollTimeLabel.leadingAnchor.constraint(equalTo: titleLabel.leadingAnchor), + enrollTimeLabel.trailingAnchor.constraint(equalTo: titleLabel.trailingAnchor) + ]) + } + + private func setupAttribute() { + self.backgroundColor = .clear + } + + private func initConfiguration() { + iconImageView.image = nil + categoryLabel.text = "" + categoryLabel.backgroundColor = .clear + + titleLabel.text = "" + addressLabel.text = "" + + menuLabel.text = "" + menuCountLabel.text = "" + + enrollTimeLabel.text = "" + starButton.isSelected = true + } + + // TODO: - 변경 예정 + @objc private func tappedStarButton(_ sender: UIButton) { + starButton.isSelected.toggle() + } + + // TODO: - 변경 예정 + func configuration(with model: MyBookmarkCellModel) { + iconImageView.image = .allBoxBar + categoryLabel.text = model.category.title + categoryLabel.backgroundColor = .all + + titleLabel.text = model.title + starButton.isSelected = model.isStar + addressLabel.text = model.address + + menuLabel.text = model.menu + menuCountLabel.text = "외 " + model.menuCount + "개 메뉴" + enrollTimeLabel.text = model.time + } +} diff --git a/AVIRO/Scene/Feature/Challenge/MyCommentList/ViewController/MyCommentListTable/MyCommentCellModel.swift b/AVIRO/Scene/Feature/Challenge/MyCommentList/ViewController/MyCommentListTable/MyCommentCellModel.swift new file mode 100644 index 00000000..370a1bf4 --- /dev/null +++ b/AVIRO/Scene/Feature/Challenge/MyCommentList/ViewController/MyCommentListTable/MyCommentCellModel.swift @@ -0,0 +1,19 @@ +// +// MyCommentCellModel.swift +// AVIRO +// +// Created by 전성훈 on 2024/03/04. +// + +import Foundation + +struct MyCommentCellModel { + let commentId: String + let title: String + let category: String + let allVegan: Bool + let someVegan: Bool + let ifRequestVegan: Bool + let date: String + let content: String +} diff --git a/AVIRO/Scene/Feature/Challenge/MyCommentList/ViewController/MyCommentListTable/MyCommentListTableViewCell.swift b/AVIRO/Scene/Feature/Challenge/MyCommentList/ViewController/MyCommentListTable/MyCommentListTableViewCell.swift new file mode 100644 index 00000000..92ddcefa --- /dev/null +++ b/AVIRO/Scene/Feature/Challenge/MyCommentList/ViewController/MyCommentListTable/MyCommentListTableViewCell.swift @@ -0,0 +1,248 @@ +// +// MyCommentListTableViewCell.swift +// AVIRO +// +// Created by 전성훈 on 2024/03/04. +// + +import UIKit + +final class MyCommentListTableViewCell: UITableViewCell { + static let identifier = MyCommentListTableViewCell.description() + + private lazy var iconImageView: UIImageView = { + let view = UIImageView() + + view.backgroundColor = .gray5 + view.layer.cornerRadius = 10.3 + view.clipsToBounds = true + + return view + }() + + private lazy var titleLabel: UILabel = { + let lbl = UILabel() + + lbl.textAlignment = .left + lbl.font = .pretendard(size: 20, weight: .bold) + lbl.numberOfLines = 1 + lbl.textColor = .gray0 + + return lbl + }() + + private lazy var dotsButton: UIButton = { + let btn = UIButton() + + btn.setImage(.dots, for: .normal) + btn.addTarget(self, action: #selector(tappedDotsButton), for: .touchUpInside) + + return btn + }() + + private lazy var enrollTimeLabel: UILabel = { + let lbl = UILabel() + + lbl.textAlignment = .left + lbl.font = .pretendard(size: 14, weight: .regular) + lbl.numberOfLines = 1 + lbl.textColor = .gray3 + + return lbl + }() + + private lazy var reviewTextView: UITextView = { + let view = UITextView() + + view.textAlignment = .left + view.font = .pretendard(size: 15, weight: .regular) + view.textColor = .gray2 + view.isScrollEnabled = false + view.isEditable = false + + return view + }() + + private lazy var mainView: UIView = { + let view = UIView() + + view.backgroundColor = .gray7 + view.layer.cornerRadius = 15 + + return view + }() + + private lazy var separatorView: UIView = { + let view = UIView() + + view.backgroundColor = .gray6 + + return view + }() + + private var afterViewDidLoad = true + private var mainViewHeight: NSLayoutConstraint? + private var reviewHeight: NSLayoutConstraint? + + private var test1: NSLayoutConstraint? + private var test2: NSLayoutConstraint? + + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + super.init(style: style, reuseIdentifier: reuseIdentifier) + + setupLayout() + setupAttribute() + } + + required init?(coder: NSCoder) { + fatalError() + } + + override func layoutSubviews() { + super.layoutSubviews() + + if afterViewDidLoad { + afterViewDidLoad.toggle() + whenAfterViewDidLoad() + } + } + + override func prepareForReuse() { + super.prepareForReuse() + + initConfiguration() + } + + private func setupLayout() { + [ + mainView, + separatorView + ].forEach { + $0.translatesAutoresizingMaskIntoConstraints = false + self.contentView.addSubview($0) + } + + mainViewHeight = mainView.heightAnchor.constraint(equalToConstant: 225) + mainViewHeight?.isActive = true + + NSLayoutConstraint.activate([ + mainView.topAnchor.constraint(equalTo: self.contentView.topAnchor), + mainView.leadingAnchor.constraint(equalTo: self.contentView.leadingAnchor, constant: 16), + mainView.trailingAnchor.constraint(equalTo: self.contentView.trailingAnchor, constant: -16), +// mainView.heightAnchor.constraint(equalToConstant: 225), + + separatorView.topAnchor.constraint(equalTo: mainView.bottomAnchor), + separatorView.leadingAnchor.constraint(equalTo: mainView.leadingAnchor), + separatorView.trailingAnchor.constraint(equalTo: mainView.trailingAnchor), + separatorView.heightAnchor.constraint(equalToConstant: 12) + ]) + + reviewHeight = reviewTextView.heightAnchor.constraint(equalToConstant: 132) + reviewHeight?.isActive = true + + [ + iconImageView, + titleLabel, + dotsButton, + enrollTimeLabel, + reviewTextView + ].forEach { + $0.translatesAutoresizingMaskIntoConstraints = false + mainView.addSubview($0) + } + + NSLayoutConstraint.activate([ + iconImageView.topAnchor.constraint(equalTo: mainView.topAnchor, constant: 20), + iconImageView.leadingAnchor.constraint(equalTo: mainView.leadingAnchor, constant: 16), + iconImageView.widthAnchor.constraint(equalToConstant: 59), + iconImageView.heightAnchor.constraint(equalToConstant: 59), + + titleLabel.topAnchor.constraint(equalTo: iconImageView.topAnchor), + titleLabel.leadingAnchor.constraint(equalTo: iconImageView.trailingAnchor, constant: 14), + titleLabel.trailingAnchor.constraint(equalTo: dotsButton.leadingAnchor, constant: -14), + + dotsButton.topAnchor.constraint(equalTo: iconImageView.topAnchor), + dotsButton.trailingAnchor.constraint(equalTo: mainView.trailingAnchor, constant: -16), + dotsButton.widthAnchor.constraint(equalToConstant: 24), + dotsButton.heightAnchor.constraint(equalToConstant: 24), + + enrollTimeLabel.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: 6), + enrollTimeLabel.leadingAnchor.constraint(equalTo: titleLabel.leadingAnchor), + enrollTimeLabel.trailingAnchor.constraint(equalTo: titleLabel.trailingAnchor), + + reviewTextView.topAnchor.constraint(equalTo: enrollTimeLabel.bottomAnchor, constant: 2), + reviewTextView.leadingAnchor.constraint(equalTo: titleLabel.leadingAnchor), + reviewTextView.trailingAnchor.constraint(equalTo: dotsButton.trailingAnchor), + reviewTextView.bottomAnchor.constraint(equalTo: mainView.bottomAnchor, constant: -20), +// reviewTextView.heightAnchor.constraint(equalToConstant: 132) + ]) + } + + private func setupAttribute() { + self.backgroundColor = .clear + } + + private func initConfiguration() { + mainViewHeight?.isActive = true + reviewHeight?.isActive = true + + test1?.isActive = false + test2?.isActive = false + + afterViewDidLoad = true + + iconImageView.image = nil + + titleLabel.text = "" + enrollTimeLabel.text = "" + + reviewTextView.text = "" + } + + func whenAfterViewDidLoad() { + layoutIfNeeded() + + print(reviewTextView.numberOfLine()) + let reviewLabelHeight: CGFloat = CGFloat(3 * 24) + print("Test,", reviewLabelHeight) + + reviewHeight?.isActive = false + + test1 = reviewTextView.heightAnchor.constraint(equalToConstant: reviewLabelHeight) + test1?.isActive = true + +// let titleHeight = titleLabel.frame.height +// let enrollTimeHeight = enrollTimeLabel.frame.height + let titleHeight: CGFloat = 24 + let enrollTimeHeight: CGFloat = 17 + + let inset: CGFloat = 20 + 6 + 2 + 20 + + let result: CGFloat = titleHeight + enrollTimeHeight + reviewLabelHeight + inset + + print(titleHeight) + print(result) + + mainViewHeight?.isActive = false + + test2 = mainView.heightAnchor.constraint(equalToConstant: result) + test2?.isActive = true + + } + + @objc private func tappedDotsButton(_ sender: UIButton) { + + } + + func configuration(with model: MyCommentCellModel) { + iconImageView.image = .allBoxBar + + titleLabel.text = model.title + enrollTimeLabel.text = model.date + + reviewTextView.text = model.content + + invalidateIntrinsicContentSize() + + } +} diff --git a/AVIRO/Scene/Feature/Challenge/MyCommentList/ViewController/MyCommentListViewController.swift b/AVIRO/Scene/Feature/Challenge/MyCommentList/ViewController/MyCommentListViewController.swift index 91baef11..bafeab1b 100644 --- a/AVIRO/Scene/Feature/Challenge/MyCommentList/ViewController/MyCommentListViewController.swift +++ b/AVIRO/Scene/Feature/Challenge/MyCommentList/ViewController/MyCommentListViewController.swift @@ -20,6 +20,15 @@ final class MyCommentListViewController: UIViewController { let view = UITableView() view.backgroundColor = .gray6 + view.separatorStyle = .none + view.showsVerticalScrollIndicator = false + view.rowHeight = UITableView.automaticDimension + view.delegate = self + view.dataSource = self + view.register( + MyCommentListTableViewCell.self, + forCellReuseIdentifier: MyCommentListTableViewCell.identifier + ) return view }() @@ -93,3 +102,42 @@ final class MyCommentListViewController: UIViewController { setupBack(true) } } + +extension MyCommentListViewController: UITableViewDataSource { + func tableView( + _ tableView: UITableView, + numberOfRowsInSection section: Int + ) -> Int { + 6 + } + + func tableView( + _ tableView: UITableView, + cellForRowAt indexPath: IndexPath + ) -> UITableViewCell { + guard let cell = tableView.dequeueReusableCell(withIdentifier: MyCommentListTableViewCell.identifier, for: indexPath) as? MyCommentListTableViewCell else { + return UITableViewCell() + } + + let model = MyCommentCellModel( + commentId: "test", + title: "하하하", + category: "test", + allVegan: false, + someVegan: false, + ifRequestVegan: false, + date: "1일 전", + content: "ㅋㅍㅋㄴㅍawfawf안니왜 왜awdawkfawlkf;lakwf;lkaw;lf왜왜왜왜ㅗ애ㅗ애ㅗ애ㅙㄴ" + ) + + cell.configuration(with: model) + + cell.selectionStyle = .none + + return cell + } +} + +extension MyCommentListViewController: UITableViewDelegate { + +} diff --git a/AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/PlaceListTable/MyPlaceListModel.swift b/AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/MyPlaceListTable/MyPlaceCellModel.swift similarity index 86% rename from AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/PlaceListTable/MyPlaceListModel.swift rename to AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/MyPlaceListTable/MyPlaceCellModel.swift index 22e2c99d..173d0915 100644 --- a/AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/PlaceListTable/MyPlaceListModel.swift +++ b/AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/MyPlaceListTable/MyPlaceCellModel.swift @@ -1,5 +1,5 @@ // -// MyPlaceListModel.swift +// MyPlaceCellModel.swift // AVIRO // // Created by 전성훈 on 2024/03/04. @@ -9,7 +9,7 @@ import Foundation -struct MyPlaceListModel { +struct MyPlaceCellModel { let category: CategoryType let all: Bool let some: Bool diff --git a/AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/PlaceListTable/MyPlaceListTableViewCell.swift b/AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/MyPlaceListTable/MyPlaceListTableViewCell.swift similarity index 99% rename from AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/PlaceListTable/MyPlaceListTableViewCell.swift rename to AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/MyPlaceListTable/MyPlaceListTableViewCell.swift index 0bd86d8e..59bacb75 100644 --- a/AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/PlaceListTable/MyPlaceListTableViewCell.swift +++ b/AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/MyPlaceListTable/MyPlaceListTableViewCell.swift @@ -209,7 +209,7 @@ final class MyPlaceListTableViewCell: UITableViewCell { } // TODO: - 변경 예정 - func configuration(with model: MyPlaceListModel) { + func configuration(with model: MyPlaceCellModel) { iconImageView.image = .allBoxBar categoryLabel.text = model.category.title categoryLabel.backgroundColor = .all diff --git a/AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/MyPlaceListViewController.swift b/AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/MyPlaceListViewController.swift index 4623aa83..6ea997f1 100644 --- a/AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/MyPlaceListViewController.swift +++ b/AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/MyPlaceListViewController.swift @@ -118,7 +118,7 @@ extension MyPlaceListViewController: UITableViewDataSource { return UITableViewCell() } - let model = MyPlaceListModel(category: .Bar, all: true, some: false, request: false, title: "테스트", address: "테스트주소입니다", menu: "테스트메뉴테스트메뉴테스트메뉴테스트메뉴테스트메뉴", menuCount: "3", time: "5일 전") + let model = MyPlaceCellModel(category: .Bar, all: true, some: false, request: false, title: "테스트", address: "테스트주소입니다", menu: "테스트메뉴테스트메뉴테스트메뉴테스트메뉴테스트메뉴", menuCount: "3", time: "5일 전") cell.configuration(with: model) cell.selectionStyle = .none From 48b2622feaa6c424fa8cc14feed0713bf28adbf4 Mon Sep 17 00:00:00 2001 From: Jeon Seoung Hun Date: Mon, 4 Mar 2024 23:27:37 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[Chore]:=20CommentListCell=20=EB=86=92?= =?UTF-8?q?=EC=9D=B4=20=EB=AC=B8=EC=A0=9C=20=ED=99=95=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyCommentListTable/MyCommentListTableViewCell.swift | 4 ++++ .../ViewController/MyCommentListViewController.swift | 1 + 2 files changed, 5 insertions(+) diff --git a/AVIRO/Scene/Feature/Challenge/MyCommentList/ViewController/MyCommentListTable/MyCommentListTableViewCell.swift b/AVIRO/Scene/Feature/Challenge/MyCommentList/ViewController/MyCommentListTable/MyCommentListTableViewCell.swift index 92ddcefa..d501d51d 100644 --- a/AVIRO/Scene/Feature/Challenge/MyCommentList/ViewController/MyCommentListTable/MyCommentListTableViewCell.swift +++ b/AVIRO/Scene/Feature/Challenge/MyCommentList/ViewController/MyCommentListTable/MyCommentListTableViewCell.swift @@ -126,6 +126,10 @@ final class MyCommentListTableViewCell: UITableViewCell { mainViewHeight?.isActive = true NSLayoutConstraint.activate([ + // TODO: 전격 수정 필요 + // 해당 constarint 값이 필요함 + // automaticDimension을 적용하려면 cell의 높이값을 알아야함 + self.contentView.heightAnchor.constraint(equalToConstant: 175), mainView.topAnchor.constraint(equalTo: self.contentView.topAnchor), mainView.leadingAnchor.constraint(equalTo: self.contentView.leadingAnchor, constant: 16), mainView.trailingAnchor.constraint(equalTo: self.contentView.trailingAnchor, constant: -16), diff --git a/AVIRO/Scene/Feature/Challenge/MyCommentList/ViewController/MyCommentListViewController.swift b/AVIRO/Scene/Feature/Challenge/MyCommentList/ViewController/MyCommentListViewController.swift index bafeab1b..11b667f1 100644 --- a/AVIRO/Scene/Feature/Challenge/MyCommentList/ViewController/MyCommentListViewController.swift +++ b/AVIRO/Scene/Feature/Challenge/MyCommentList/ViewController/MyCommentListViewController.swift @@ -23,6 +23,7 @@ final class MyCommentListViewController: UIViewController { view.separatorStyle = .none view.showsVerticalScrollIndicator = false view.rowHeight = UITableView.automaticDimension + view.estimatedRowHeight = 100 view.delegate = self view.dataSource = self view.register( From f85ea19feffd6fe27f6d22467bd351296c56723b Mon Sep 17 00:00:00 2001 From: Jeon Seoung Hun Date: Tue, 5 Mar 2024 00:29:39 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[Feat]:=20Header=20View=20UI=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AVIRO.xcodeproj/project.pbxproj | 4 ++ .../MyBookmarkListViewController.swift | 39 +++++++++++++ .../MyCommentListTableViewCell.swift | 10 ++-- .../MyCommentListViewController.swift | 40 ++++++++++++- .../MyInfoListHeaderView.swift | 57 +++++++++++++++++++ .../MyPlaceListViewController.swift | 39 +++++++++++++ 6 files changed, 182 insertions(+), 7 deletions(-) create mode 100644 AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/MyPlaceListTable/MyInfoListHeaderView.swift diff --git a/AVIRO.xcodeproj/project.pbxproj b/AVIRO.xcodeproj/project.pbxproj index 3f2044db..032177ea 100644 --- a/AVIRO.xcodeproj/project.pbxproj +++ b/AVIRO.xcodeproj/project.pbxproj @@ -121,6 +121,7 @@ C54B591B2B95F61200C0B190 /* MyCommentCellModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C54B591A2B95F61200C0B190 /* MyCommentCellModel.swift */; }; C54B591D2B95F61F00C0B190 /* MyCommentListTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C54B591C2B95F61F00C0B190 /* MyCommentListTableViewCell.swift */; }; C54B591F2B9606C500C0B190 /* UITextView+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C54B591E2B9606C500C0B190 /* UITextView+Extension.swift */; }; + C54B59212B961EE000C0B190 /* MyInfoListHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C54B59202B961EE000C0B190 /* MyInfoListHeaderView.swift */; }; C54B76612B88B2D10095E110 /* FranchiseToggleButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = C54B76602B88B2D10095E110 /* FranchiseToggleButton.swift */; }; C54BC0DB2A2C2D0D00B65439 /* UIColor+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C54BC0DA2A2C2D0D00B65439 /* UIColor+Extension.swift */; }; C552D5342ABE8CA500933D8A /* AVIRODeleteAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = C552D5332ABE8CA500933D8A /* AVIRODeleteAPI.swift */; }; @@ -390,6 +391,7 @@ C54B591A2B95F61200C0B190 /* MyCommentCellModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyCommentCellModel.swift; sourceTree = ""; }; C54B591C2B95F61F00C0B190 /* MyCommentListTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyCommentListTableViewCell.swift; sourceTree = ""; }; C54B591E2B9606C500C0B190 /* UITextView+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITextView+Extension.swift"; sourceTree = ""; }; + C54B59202B961EE000C0B190 /* MyInfoListHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyInfoListHeaderView.swift; sourceTree = ""; }; C54B76602B88B2D10095E110 /* FranchiseToggleButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FranchiseToggleButton.swift; sourceTree = ""; }; C54BC0DA2A2C2D0D00B65439 /* UIColor+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+Extension.swift"; sourceTree = ""; }; C552D5332ABE8CA500933D8A /* AVIRODeleteAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AVIRODeleteAPI.swift; sourceTree = ""; }; @@ -648,6 +650,7 @@ children = ( C50B18CA2B94D147005DECDC /* MyPlaceListTableViewCell.swift */, C50B18CC2B94D696005DECDC /* MyPlaceCellModel.swift */, + C54B59202B961EE000C0B190 /* MyInfoListHeaderView.swift */, ); path = MyPlaceListTable; sourceTree = ""; @@ -2318,6 +2321,7 @@ C5E306E72A6FB4ED00C11CF7 /* MenuField.swift in Sources */, C5ED46982AAEEFB600F2DA04 /* OperationHoursView.swift in Sources */, C51AED212A8B2BDB0015FBC2 /* HomeMapReferButton.swift in Sources */, + C54B59212B961EE000C0B190 /* MyInfoListHeaderView.swift in Sources */, C5E430B32A5DADBE00CB67EC /* SecondRegistrationPresenter.swift in Sources */, C5EB510D2A20A4B400B29CC1 /* HomeSearchViewTableViewCell.swift in Sources */, C510005C2AB9C39500F65C1F /* MarkerModelManager.swift in Sources */, diff --git a/AVIRO/Scene/Feature/Challenge/MyBookmarkList/ViewController/MyBookmarkListViewController.swift b/AVIRO/Scene/Feature/Challenge/MyBookmarkList/ViewController/MyBookmarkListViewController.swift index 4a610c9f..69eba91f 100644 --- a/AVIRO/Scene/Feature/Challenge/MyBookmarkList/ViewController/MyBookmarkListViewController.swift +++ b/AVIRO/Scene/Feature/Challenge/MyBookmarkList/ViewController/MyBookmarkListViewController.swift @@ -24,6 +24,7 @@ final class MyBookmarkListViewController: UIViewController { view.showsVerticalScrollIndicator = false view.dataSource = self view.delegate = self + view.sectionHeaderTopPadding = 0 view.register( MyBookmarkListTableViewCell.self, forCellReuseIdentifier: MyBookmarkListTableViewCell.identifier @@ -131,10 +132,48 @@ extension MyBookmarkListViewController: UITableViewDataSource { return cell } + + func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { + let view = UIView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: 48)) + + view.backgroundColor = .gray6 + + let countLabel = UILabel() + countLabel.numberOfLines = 1 + countLabel.font = .pretendard(size: 18, weight: .semibold) + countLabel.text = "총 \(6)개의 가게" + countLabel.textColor = .gray0 + countLabel.translatesAutoresizingMaskIntoConstraints = false + + view.addSubview(countLabel) + + NSLayoutConstraint.activate([ + countLabel.centerYAnchor.constraint(equalTo: view.centerYAnchor), + countLabel.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 16), + countLabel.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -16) + ]) + + return view + } + + func scrollViewDidScroll(_ scrollView: UIScrollView) { + let sectionHeaderHeight: CGFloat = 48 + + if scrollView.contentOffset.y <= sectionHeaderHeight && scrollView.contentOffset.y >= 0 { + scrollView.contentInset = UIEdgeInsets(top: -scrollView.contentOffset.y, left: 0, bottom: 0, right: 0) + } else if scrollView.contentOffset.y >= sectionHeaderHeight { + scrollView.contentInset = UIEdgeInsets(top: -sectionHeaderHeight, left: 0, bottom: 0, right: 0) + } + } + } extension MyBookmarkListViewController: UITableViewDelegate { func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { 142 } + + func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { + 48 + } } diff --git a/AVIRO/Scene/Feature/Challenge/MyCommentList/ViewController/MyCommentListTable/MyCommentListTableViewCell.swift b/AVIRO/Scene/Feature/Challenge/MyCommentList/ViewController/MyCommentListTable/MyCommentListTableViewCell.swift index d501d51d..1cbb827b 100644 --- a/AVIRO/Scene/Feature/Challenge/MyCommentList/ViewController/MyCommentListTable/MyCommentListTableViewCell.swift +++ b/AVIRO/Scene/Feature/Challenge/MyCommentList/ViewController/MyCommentListTable/MyCommentListTableViewCell.swift @@ -51,14 +51,14 @@ final class MyCommentListTableViewCell: UITableViewCell { return lbl }() - private lazy var reviewTextView: UITextView = { - let view = UITextView() + private lazy var reviewTextView: UILabel = { + let view = UILabel() view.textAlignment = .left view.font = .pretendard(size: 15, weight: .regular) view.textColor = .gray2 - view.isScrollEnabled = false - view.isEditable = false + view.numberOfLines = 0 + view.lineBreakMode = .byCharWrapping return view }() @@ -206,7 +206,7 @@ final class MyCommentListTableViewCell: UITableViewCell { func whenAfterViewDidLoad() { layoutIfNeeded() - print(reviewTextView.numberOfLine()) +// print(reviewTextView.numberOfLine()) let reviewLabelHeight: CGFloat = CGFloat(3 * 24) print("Test,", reviewLabelHeight) diff --git a/AVIRO/Scene/Feature/Challenge/MyCommentList/ViewController/MyCommentListViewController.swift b/AVIRO/Scene/Feature/Challenge/MyCommentList/ViewController/MyCommentListViewController.swift index 11b667f1..87ce7bb4 100644 --- a/AVIRO/Scene/Feature/Challenge/MyCommentList/ViewController/MyCommentListViewController.swift +++ b/AVIRO/Scene/Feature/Challenge/MyCommentList/ViewController/MyCommentListViewController.swift @@ -26,6 +26,7 @@ final class MyCommentListViewController: UIViewController { view.estimatedRowHeight = 100 view.delegate = self view.dataSource = self + view.sectionHeaderTopPadding = 0 view.register( MyCommentListTableViewCell.self, forCellReuseIdentifier: MyCommentListTableViewCell.identifier @@ -82,7 +83,7 @@ final class MyCommentListViewController: UIViewController { } NSLayoutConstraint.activate([ - commentTableView.topAnchor.constraint(equalTo: self.view.topAnchor), + commentTableView.topAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.topAnchor), commentTableView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor), commentTableView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor), commentTableView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor) @@ -137,8 +138,43 @@ extension MyCommentListViewController: UITableViewDataSource { return cell } + + func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { + let view = UIView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: 48)) + + view.backgroundColor = .gray6 + + let countLabel = UILabel() + countLabel.numberOfLines = 1 + countLabel.font = .pretendard(size: 18, weight: .semibold) + countLabel.text = "총 \(6)개의 가게" + countLabel.textColor = .gray0 + countLabel.translatesAutoresizingMaskIntoConstraints = false + + view.addSubview(countLabel) + + NSLayoutConstraint.activate([ + countLabel.centerYAnchor.constraint(equalTo: view.centerYAnchor), + countLabel.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 16), + countLabel.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -16) + ]) + + return view + } + + func scrollViewDidScroll(_ scrollView: UIScrollView) { + let sectionHeaderHeight: CGFloat = 48 + + if scrollView.contentOffset.y <= sectionHeaderHeight && scrollView.contentOffset.y >= 0 { + scrollView.contentInset = UIEdgeInsets(top: -scrollView.contentOffset.y, left: 0, bottom: 0, right: 0) + } else if scrollView.contentOffset.y >= sectionHeaderHeight { + scrollView.contentInset = UIEdgeInsets(top: -sectionHeaderHeight, left: 0, bottom: 0, right: 0) + } + } } extension MyCommentListViewController: UITableViewDelegate { - + func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { + 48 + } } diff --git a/AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/MyPlaceListTable/MyInfoListHeaderView.swift b/AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/MyPlaceListTable/MyInfoListHeaderView.swift new file mode 100644 index 00000000..c13033d4 --- /dev/null +++ b/AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/MyPlaceListTable/MyInfoListHeaderView.swift @@ -0,0 +1,57 @@ +// +// MyInfoListHeaderView.swift +// AVIRO +// +// Created by 전성훈 on 2024/03/05. +// + +import UIKit + +final class MyInfoListHeaderView: UITableViewHeaderFooterView { + static let identifier = MyInfoListHeaderView.description() + + private lazy var countLabel: UILabel = { + let lbl = UILabel() + + lbl.numberOfLines = 1 + lbl.font = .pretendard(size: 18, weight: .semibold) + lbl.textColor = .gray0 + + return lbl + }() + + override init(reuseIdentifier: String?) { + super.init(reuseIdentifier: reuseIdentifier) + + setupLayout() + setupAttribute() + } + + required init?(coder: NSCoder) { + fatalError() + } + + private func setupLayout() { + [ + countLabel + ].forEach { + $0.translatesAutoresizingMaskIntoConstraints = false + self.addSubview($0) + } + + NSLayoutConstraint.activate([ + self.heightAnchor.constraint(equalToConstant: 48), + countLabel.centerYAnchor.constraint(equalTo: self.centerYAnchor), + countLabel.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: 16), + countLabel.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: -16) + ]) + } + + private func setupAttribute() { + self.backgroundColor = .clear + } + + func configuration(with count: Int) { + countLabel.text = "총 \(count)개의 가게" + } +} diff --git a/AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/MyPlaceListViewController.swift b/AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/MyPlaceListViewController.swift index 6ea997f1..9bd1e563 100644 --- a/AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/MyPlaceListViewController.swift +++ b/AVIRO/Scene/Feature/Challenge/MyPlaceList/ViewController/MyPlaceListViewController.swift @@ -24,6 +24,7 @@ final class MyPlaceListViewController: UIViewController { view.showsVerticalScrollIndicator = false view.dataSource = self view.delegate = self + view.sectionHeaderTopPadding = 0 view.register( MyPlaceListTableViewCell.self, forCellReuseIdentifier: MyPlaceListTableViewCell.identifier @@ -125,10 +126,48 @@ extension MyPlaceListViewController: UITableViewDataSource { return cell } + + func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { + let view = UIView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: 48)) + + view.backgroundColor = .clear + + let countLabel = UILabel() + countLabel.numberOfLines = 1 + countLabel.font = .pretendard(size: 18, weight: .semibold) + countLabel.text = "총 \(6)개의 가게" + countLabel.textColor = .gray0 + countLabel.translatesAutoresizingMaskIntoConstraints = false + + view.addSubview(countLabel) + + NSLayoutConstraint.activate([ + countLabel.centerYAnchor.constraint(equalTo: view.centerYAnchor), + countLabel.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 16), + countLabel.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -16) + ]) + + return view + } + + func scrollViewDidScroll(_ scrollView: UIScrollView) { + let sectionHeaderHeight: CGFloat = 48 + + if scrollView.contentOffset.y <= sectionHeaderHeight && scrollView.contentOffset.y >= 0 { + scrollView.contentInset = UIEdgeInsets(top: -scrollView.contentOffset.y, left: 0, bottom: 0, right: 0) + } else if scrollView.contentOffset.y >= sectionHeaderHeight { + scrollView.contentInset = UIEdgeInsets(top: -sectionHeaderHeight, left: 0, bottom: 0, right: 0) + } + } } extension MyPlaceListViewController: UITableViewDelegate { func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { 142 } + + func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { + 48 + } + }