From 92808fad5135be0f190c9b36d5eea02aa3840fb7 Mon Sep 17 00:00:00 2001 From: hryeong66 Date: Tue, 26 Jul 2022 01:17:02 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8[FIX]=20=20#285=20-=20=EA=B2=80?= =?UTF-8?q?=EC=83=89=EC=97=90=20=EC=82=AC=EC=9A=A9=EB=90=9C=20tag=EB=B7=B0?= =?UTF-8?q?=20=EC=83=81=EB=8B=A8=EC=97=90=20=EA=B3=A0=EC=A0=95=EB=90=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VCs/PostDetailScene/PostDetailVC.swift | 5 + .../VCs/PostSearchScene/SearchResultVC.swift | 144 ++++++++++-------- .../Source/Views/VCs/SignScene/LoginVC.swift | 7 +- 3 files changed, 90 insertions(+), 66 deletions(-) diff --git a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/PostDetailScene/PostDetailVC.swift b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/PostDetailScene/PostDetailVC.swift index 80890073..780c7d74 100644 --- a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/PostDetailScene/PostDetailVC.swift +++ b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/PostDetailScene/PostDetailVC.swift @@ -336,6 +336,11 @@ extension PostDetailVC: UITableViewDataSource { userName: postData.author, date: "\(additionalData.year)년 \(additionalData.month)월 \(additionalData.day)일", imageName: postData.profileImage) + //TODO: - user 이미지 + 텍스트 눌렀을 때 해당 유저 마이페이지로 이동 + // let otherVC = OtherMyPageVC() + // otherVC.setOtherUserID(userID: follow.userEmail) + // otherVC.modalPresentationStyle = .overFullScreen + // self?.present(otherVC, animated: true) return cell case 1: diff --git a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/PostSearchScene/SearchResultVC.swift b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/PostSearchScene/SearchResultVC.swift index d9b93783..14554356 100644 --- a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/PostSearchScene/SearchResultVC.swift +++ b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/PostSearchScene/SearchResultVC.swift @@ -6,10 +6,11 @@ // import UIKit + import SnapKit import Then -class SearchResultVC: UIViewController { +final class SearchResultVC: UIViewController { //MARK: Result Data public var lastPostId: Int = 0 @@ -31,10 +32,10 @@ class SearchResultVC: UIViewController { private let separateLineView = UIView().then { $0.backgroundColor = .gray20 } - private var collectionView: UICollectionView = { + + private lazy var collectionView: UICollectionView = { let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) - collectionView.isPagingEnabled = true collectionView.backgroundColor = .clear collectionView.showsHorizontalScrollIndicator = false @@ -45,14 +46,15 @@ class SearchResultVC: UIViewController { layout.minimumInteritemSpacing = 0 layout.scrollDirection = .vertical collectionView.setCollectionViewLayout(layout, animated: true) - - collectionView.registerCustomXib(xibName: PostResultHeaderCVC.identifier) + collectionView.delegate = self + collectionView.dataSource = self collectionView.registerCustomXib(xibName: CommonCVC.identifier) - + collectionView.registerCustomXib(xibName: HomePostDetailCVC.identifier) return collectionView }() - private let closeButton = UIButton().then { + + private lazy var closeButton = UIButton().then { $0.setTitle("닫기", for: .normal) $0.titleLabel?.font = .notoSansMediumFont(ofSize: 17) $0.setTitleColor(.mainBlue, for: .normal) @@ -70,7 +72,7 @@ class SearchResultVC: UIViewController { $0.textColor = .gray50 } - private let searchButton = UIButton().then { + private lazy var searchButton = UIButton().then { $0.setTitle("드라이브 코스 작성하기", for: .normal) $0.setTitleColor(.white, for: .normal) $0.titleLabel?.font = .notoSansBoldFont(ofSize: 16) @@ -83,8 +85,12 @@ class SearchResultVC: UIViewController { super.viewDidLoad() postSearchPost(type: "like") setupConstraint() + configureUI() setFilterViewCompletion() - configureCollectionView() + } + + private func configureUI() { + view.backgroundColor = .white } public func setFilterTagList(list: [String]) { @@ -106,20 +112,7 @@ class SearchResultVC: UIViewController { } } - func configureCollectionView() { - collectionView.register(UINib(nibName: PostResultHeaderCVC.identifier, bundle: nil), - forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, - withReuseIdentifier: PostResultHeaderCVC.identifier) - - collectionView.registerCustomXib(xibName: CommonCVC.identifier) - collectionView.registerCustomXib(xibName: HomePostDetailCVC.identifier) - - collectionView.delegate = self - collectionView.dataSource = self - collectionView.isPagingEnabled = false - } - - func setFilterViewLayout() { + private func setFilterViewLayout() { self.view.addSubview(filterView) filterView.isHidden = true filterView.snp.makeConstraints{ @@ -130,9 +123,9 @@ class SearchResultVC: UIViewController { } } - func setFilterViewCompletion(){ + private func setFilterViewCompletion() { filterView.touchCellCompletion = { index in - switch index{ + switch index { case 0: self.currentState = "인기순" self.postSearchPost(type: "new") @@ -171,7 +164,7 @@ extension SearchResultVC: UICollectionViewDataSource { nextVC.setPostId(id: postid) self.navigationController?.pushViewController(nextVC, animated: true) } - if indexPath.row == 0{ + if indexPath.row == 0 { if myCellIsFirstLoaded { myCellIsFirstLoaded = false topCVCCell = dropDownCell @@ -189,38 +182,14 @@ extension SearchResultVC: UICollectionViewDataSource { postID: post.postID) return cell! } - - - func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { - - guard let header = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: PostResultHeaderCVC.identifier, for: indexPath) as? PostResultHeaderCVC else { - return UICollectionReusableView() - } - header.setStackViewData(list: filterResultList) - header.addSubview(separateLineView) - separateLineView.snp.makeConstraints{ - $0.leading.trailing.equalTo(view.safeAreaLayoutGuide) - $0.bottom.equalToSuperview() - $0.height.equalTo(1) - } - return header - } } -extension SearchResultVC: UICollectionViewDelegateFlowLayout { - - func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize { - return CGSize(width: UIScreen.getDeviceWidth(), height: 40) - } +extension SearchResultVC: UICollectionViewDelegateFlowLayout { func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { - - if indexPath.row == 0 { - return CGSize(width: collectionView.frame.size.width-40, height: 57) - } - - return CGSize(width: collectionView.frame.size.width-40, height: 260) + let height = indexPath.row == 0 ? 57 : 260 + return CGSize(width: UIScreen.getDeviceWidth() - 40, height: height) } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { @@ -246,18 +215,18 @@ extension SearchResultVC { } navigationView.addSubviews([backButton,navigationTitleLabel,closeButton]) - backButton.snp.makeConstraints{ + backButton.snp.makeConstraints { $0.top.equalToSuperview().offset(1) $0.leading.equalToSuperview() $0.bottom.equalToSuperview().offset(-9) } - navigationTitleLabel.snp.makeConstraints{ + navigationTitleLabel.snp.makeConstraints { $0.centerX.equalToSuperview() $0.centerY.equalTo(backButton.snp.centerY) } - closeButton.snp.makeConstraints{ + closeButton.snp.makeConstraints { $0.trailing.equalToSuperview().offset(-20) $0.centerY.equalTo(backButton.snp.centerY) } @@ -294,18 +263,73 @@ extension SearchResultVC { $0.leading.trailing.bottom.equalTo(view.safeAreaLayoutGuide).inset(20) $0.height.equalTo(48) } - } private func setResultViewConstraint() { - view.addSubview(collectionView) + let tagHeaderView = initTagHearderView() + view.addSubviews([collectionView, separateLineView, tagHeaderView]) + tagHeaderView.snp.makeConstraints { + $0.top.equalTo(navigationView.snp.bottom) + $0.leading.trailing.equalToSuperview() + $0.height.equalTo(65) + } + + separateLineView.snp.makeConstraints { + $0.top.equalTo(tagHeaderView.snp.bottom) + $0.leading.trailing.equalToSuperview() + $0.height.equalTo(1) + } + collectionView.snp.makeConstraints{ - $0.top.equalTo(self.navigationView.snp.bottom).offset(15) + $0.top.equalTo(separateLineView.snp.bottom) $0.leading.trailing.bottom.equalToSuperview() } } } +// MARK: - 상단 tag header view +extension SearchResultVC { + private func initTagHearderView() -> UIView { + let view = UIView(frame: CGRect(x: 0, y: 0, + width: UIScreen.getDeviceWidth(), + height: 65)) + view.backgroundColor = .white + + let stackView = UIStackView(arrangedSubviews: makeTagLabelList()) + stackView.axis = .horizontal + stackView.alignment = .leading + stackView.distribution = .fill + stackView.spacing = 4 + + view.addSubview(stackView) + stackView.snp.makeConstraints{ + $0.leading.equalTo(view.snp.leading).offset(20) + $0.centerY.equalToSuperview() + $0.height.equalTo(34) + } + return view + } + + private func makeTagLabelList() -> [UIButton] { + var list: [UIButton] = [] + for index in 0..