diff --git a/ChaRo-iOS/ChaRo-iOS.xcodeproj/project.pbxproj b/ChaRo-iOS/ChaRo-iOS.xcodeproj/project.pbxproj index cb12244f..d2562b12 100644 --- a/ChaRo-iOS/ChaRo-iOS.xcodeproj/project.pbxproj +++ b/ChaRo-iOS/ChaRo-iOS.xcodeproj/project.pbxproj @@ -100,13 +100,11 @@ 3C7A0C5127CE83AE00B78854 /* PostLikeListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C7A0C5027CE83AE00B78854 /* PostLikeListViewModel.swift */; }; 3C7A0C5327CE8E1F00B78854 /* TMapSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C7A0C5227CE8E1F00B78854 /* TMapSDK.framework */; }; 3C7A0C5427CE8E1F00B78854 /* TMapSDK.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3C7A0C5227CE8E1F00B78854 /* TMapSDK.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 3C7DF0ED269A1BED0021939C /* SearchPost.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3C7DF0EC269A1BED0021939C /* SearchPost.storyboard */; }; 3C7DF0EF269A1C1F0021939C /* SearchPostVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C7DF0EE269A1C1F0021939C /* SearchPostVC.swift */; }; 3C7DF0F1269A30380021939C /* XmarkDismissButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C7DF0F0269A30380021939C /* XmarkDismissButton.swift */; }; 3C7DF0F3269A36870021939C /* NavigationTitleLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C7DF0F2269A36870021939C /* NavigationTitleLabel.swift */; }; 3C7DF0F5269ACE8F0021939C /* FilterDatas.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C7DF0F4269ACE8F0021939C /* FilterDatas.swift */; }; 3C7DF0F7269AEE7D0021939C /* SearchResultVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C7DF0F6269AEE7D0021939C /* SearchResultVC.swift */; }; - 3C7DF0F9269AEE910021939C /* SearchResult.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3C7DF0F8269AEE910021939C /* SearchResult.storyboard */; }; 3C7DF0FB269AF14A0021939C /* LeftBackButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C7DF0FA269AF14A0021939C /* LeftBackButton.swift */; }; 3C840BF0269589DF001CAFE5 /* SearchKeywordCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C840BEE269589DF001CAFE5 /* SearchKeywordCell.swift */; }; 3C840BF72696F08F001CAFE5 /* UIScreen+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C840BF62696F08F001CAFE5 /* UIScreen+.swift */; }; @@ -372,13 +370,11 @@ 3C7A0C4E27CE838100B78854 /* PostLikeListVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostLikeListVC.swift; sourceTree = ""; }; 3C7A0C5027CE83AE00B78854 /* PostLikeListViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostLikeListViewModel.swift; sourceTree = ""; }; 3C7A0C5227CE8E1F00B78854 /* TMapSDK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = TMapSDK.framework; sourceTree = ""; }; - 3C7DF0EC269A1BED0021939C /* SearchPost.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = SearchPost.storyboard; sourceTree = ""; }; 3C7DF0EE269A1C1F0021939C /* SearchPostVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchPostVC.swift; sourceTree = ""; }; 3C7DF0F0269A30380021939C /* XmarkDismissButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XmarkDismissButton.swift; sourceTree = ""; }; 3C7DF0F2269A36870021939C /* NavigationTitleLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationTitleLabel.swift; sourceTree = ""; }; 3C7DF0F4269ACE8F0021939C /* FilterDatas.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FilterDatas.swift; sourceTree = ""; }; 3C7DF0F6269AEE7D0021939C /* SearchResultVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchResultVC.swift; sourceTree = ""; }; - 3C7DF0F8269AEE910021939C /* SearchResult.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = SearchResult.storyboard; sourceTree = ""; }; 3C7DF0FA269AF14A0021939C /* LeftBackButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LeftBackButton.swift; sourceTree = ""; }; 3C840BEE269589DF001CAFE5 /* SearchKeywordCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchKeywordCell.swift; sourceTree = ""; }; 3C840BF62696F08F001CAFE5 /* UIScreen+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIScreen+.swift"; sourceTree = ""; }; @@ -811,7 +807,6 @@ 3CAE51BD26C2478300DB8A41 /* HomeScene */, 3CAE51BE26C249FE00DB8A41 /* MyPageScene */, 3CAE51C426C24A6E00DB8A41 /* OnBoardScene */, - 3CAE51C226C24A5100DB8A41 /* PostSearchScene */, 3CAE51C526C24A7B00DB8A41 /* SignScene */, 3CAE51C126C24A3F00DB8A41 /* SplachScene */, 3CAE51C026C24A2B00DB8A41 /* Tabbar */, @@ -1358,15 +1353,6 @@ path = SplachScene; sourceTree = ""; }; - 3CAE51C226C24A5100DB8A41 /* PostSearchScene */ = { - isa = PBXGroup; - children = ( - 3C7DF0F8269AEE910021939C /* SearchResult.storyboard */, - 3C7DF0EC269A1BED0021939C /* SearchPost.storyboard */, - ); - path = PostSearchScene; - sourceTree = ""; - }; 3CAE51C426C24A6E00DB8A41 /* OnBoardScene */ = { isa = PBXGroup; children = ( @@ -1558,7 +1544,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 3C7DF0ED269A1BED0021939C /* SearchPost.storyboard in Resources */, 3C86FAB62694C7C6009370CD /* NotoSansCJKkr-Black.otf in Resources */, 36CACA202698F3CF007E02CA /* ThemePostDetailTVC.xib in Resources */, 3C86FAA32694C7C6009370CD /* CommonCVC.xib in Resources */, @@ -1605,7 +1590,6 @@ 3C86FAA12694C7C6009370CD /* HomeThemeCVC.xib in Resources */, 36B69F832775DC6500FEEAAE /* FollowFollowing.storyboard in Resources */, 3C86FAAC2694C7C6009370CD /* HomeThemeTVC.xib in Resources */, - 3C7DF0F9269AEE910021939C /* SearchResult.storyboard in Resources */, 3C86FABC2694C7C6009370CD /* NotoSansCJKkr-Bold.otf in Resources */, F4CC1B9A269D3E67009A0C01 /* CreatePostCourseTVC.xib in Resources */, 36E445B9277CA1F3008E31BE /* SettingTVC.xib in Resources */, diff --git a/ChaRo-iOS/ChaRo-iOS/Resource/Storyboards/PostSearchScene/SearchPost.storyboard b/ChaRo-iOS/ChaRo-iOS/Resource/Storyboards/PostSearchScene/SearchPost.storyboard deleted file mode 100644 index e76603f6..00000000 --- a/ChaRo-iOS/ChaRo-iOS/Resource/Storyboards/PostSearchScene/SearchPost.storyboard +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ChaRo-iOS/ChaRo-iOS/Resource/Storyboards/PostSearchScene/SearchResult.storyboard b/ChaRo-iOS/ChaRo-iOS/Resource/Storyboards/PostSearchScene/SearchResult.storyboard deleted file mode 100644 index 5507ae09..00000000 --- a/ChaRo-iOS/ChaRo-iOS/Resource/Storyboards/PostSearchScene/SearchResult.storyboard +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/HomeScene/HomeVC.swift b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/HomeScene/HomeVC.swift index 62b1c703..edc65401 100644 --- a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/HomeScene/HomeVC.swift +++ b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/HomeScene/HomeVC.swift @@ -289,8 +289,7 @@ class HomeVC: UIViewController { } @objc func presentSearchPost() { - let storyboard = UIStoryboard(name: "SearchPost", bundle: nil) - guard let nextVC = storyboard.instantiateViewController(identifier: SearchPostVC.className) as? SearchPostVC else { return } + let nextVC = SearchPostVC() let navigation = UINavigationController(rootViewController: nextVC) navigation.modalPresentationStyle = .fullScreen present(navigation, animated: true, completion: nil) 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/SearchPostVC.swift b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/PostSearchScene/SearchPostVC.swift index 091d39dd..d575b4a5 100644 --- a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/PostSearchScene/SearchPostVC.swift +++ b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/PostSearchScene/SearchPostVC.swift @@ -106,7 +106,7 @@ class SearchPostVC: UIViewController { $0.text = "은 피하고 싶어요" } - private let findButton = UIButton().then { + private lazy var findButton = UIButton().then { $0.isUserInteractionEnabled = false $0.setBackgroundImage(ImageLiterals.icSearchBtnWhite, for: .normal) $0.titleLabel?.font = .notoSansBoldFont(ofSize: 16) @@ -126,10 +126,7 @@ class SearchPostVC: UIViewController { } @objc func pushNextVC() { - let storyboard = UIStoryboard(name: "SearchResult", bundle: nil) - guard let nextVC = storyboard.instantiateViewController(identifier: SearchResultVC.className ) as? SearchResultVC else { - return - } + let nextVC = SearchResultVC() refineFilterList() print("정제됨 -> \(filterList)") nextVC.setFilterTagList(list: filterList) @@ -138,7 +135,7 @@ class SearchPostVC: UIViewController { func refineFilterList() { for index in 0..<4 { - if filterList[index] == "선택안함"{ filterList[index] = "" } + if filterList[index] == "선택안함" { filterList[index] = "" } } } 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..65e2c6a9 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,28 +32,26 @@ class SearchResultVC: UIViewController { private let separateLineView = UIView().then { $0.backgroundColor = .gray20 } - private var collectionView: UICollectionView = { - let collectionView = UICollectionView(frame: .zero, - collectionViewLayout: UICollectionViewFlowLayout()) - - collectionView.isPagingEnabled = true - collectionView.backgroundColor = .clear - collectionView.showsHorizontalScrollIndicator = false - + + private lazy var collectionView = UICollectionView(frame: .zero, + collectionViewLayout: UICollectionViewFlowLayout() ).then { let layout:UICollectionViewFlowLayout = UICollectionViewFlowLayout() layout.itemSize = CGSize(width: UIScreen.getDeviceWidth(), height: 624) - layout.minimumLineSpacing = 0 + layout.minimumLineSpacing = 10 layout.minimumInteritemSpacing = 0 layout.scrollDirection = .vertical - collectionView.setCollectionViewLayout(layout, animated: true) - collectionView.registerCustomXib(xibName: PostResultHeaderCVC.identifier) - collectionView.registerCustomXib(xibName: CommonCVC.identifier) - - return collectionView - }() + $0.isPagingEnabled = false + $0.backgroundColor = .clear + $0.showsHorizontalScrollIndicator = false + $0.setCollectionViewLayout(layout, animated: true) + $0.delegate = self + $0.dataSource = self + $0.registerCustomXib(xibName: CommonCVC.identifier) + $0.registerCustomXib(xibName: HomePostDetailCVC.identifier) + } - 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 +69,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 +82,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 +109,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 +120,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") @@ -151,6 +141,7 @@ class SearchResultVC: UIViewController { } } +// MARK: collection view extension SearchResultVC: UICollectionViewDelegate { } @@ -171,7 +162,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,53 +180,18 @@ 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) - } - - func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { - return 10 - } - - func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { - return 0 - } - - func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { - return .zero + let height = indexPath.row == 0 ? 57 : 260 + return CGSize(width: UIScreen.getDeviceWidth() - 40, height: height) } } +// MARK: - UI extension SearchResultVC { private func setupConstraint() { @@ -246,18 +202,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,20 +250,76 @@ 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.top.equalToSuperview().inset(13) + $0.leading.equalTo(view.snp.leading).offset(20) + $0.bottom.equalToSuperview().inset(15) + $0.height.equalTo(34) + } + return view + } + + private func makeTagLabelList() -> [UIButton] { + var list: [UIButton] = [] + for index in 0..