diff --git a/ChaRo-iOS/ChaRo-iOS/Source/Views/Cells/TVC/HomeScene/HomeAreaRecommandTVC.swift b/ChaRo-iOS/ChaRo-iOS/Source/Views/Cells/TVC/HomeScene/HomeAreaRecommandTVC.swift index 7f329610..ab5d258d 100644 --- a/ChaRo-iOS/ChaRo-iOS/Source/Views/Cells/TVC/HomeScene/HomeAreaRecommandTVC.swift +++ b/ChaRo-iOS/ChaRo-iOS/Source/Views/Cells/TVC/HomeScene/HomeAreaRecommandTVC.swift @@ -72,7 +72,8 @@ extension HomeAreaRecommandTVC: UICollectionViewDelegate, UICollectionViewDataSo func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { delegate?.isSelectedCVC(indexPath: indexPath) - postDelegate?.sendPostDriveElement(data: localList[indexPath.row]) + guard let cell = collectionView.cellForItem(at: indexPath) as? CommonCVC else { return } + postDelegate?.sendPostDetail(with: cell.postID) } diff --git a/ChaRo-iOS/ChaRo-iOS/Source/Views/Cells/TVC/HomeScene/HomeSeasonRecommandTVC.swift b/ChaRo-iOS/ChaRo-iOS/Source/Views/Cells/TVC/HomeScene/HomeSeasonRecommandTVC.swift index c24a71f3..31d8659d 100644 --- a/ChaRo-iOS/ChaRo-iOS/Source/Views/Cells/TVC/HomeScene/HomeSeasonRecommandTVC.swift +++ b/ChaRo-iOS/ChaRo-iOS/Source/Views/Cells/TVC/HomeScene/HomeSeasonRecommandTVC.swift @@ -85,10 +85,8 @@ extension HomeSeasonRecommandTVC: UICollectionViewDelegate, UICollectionViewData func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { delegate?.isSelectedCVC(indexPath: indexPath) - let cell = collectionView.cellForItem(at: indexPath) as? CommonCVC - let postid = cell!.postID - let sengingData = findDriveElementFrom(postId: postid) - postDelegate?.sendPostDriveElement(data: sengingData) + guard let cell = collectionView.cellForItem(at: indexPath) as? CommonCVC else { return } + postDelegate?.sendPostDetail(with: cell.postID) } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { diff --git a/ChaRo-iOS/ChaRo-iOS/Source/Views/Cells/TVC/HomeScene/HomeSquareTVC.swift b/ChaRo-iOS/ChaRo-iOS/Source/Views/Cells/TVC/HomeScene/HomeSquareTVC.swift index 3ddc5dba..4831cb6e 100644 --- a/ChaRo-iOS/ChaRo-iOS/Source/Views/Cells/TVC/HomeScene/HomeSquareTVC.swift +++ b/ChaRo-iOS/ChaRo-iOS/Source/Views/Cells/TVC/HomeScene/HomeSquareTVC.swift @@ -114,10 +114,8 @@ extension HomeSquareTVC: UICollectionViewDelegate, UICollectionViewDataSource, U func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { delegate?.isSelectedCVC(indexPath: indexPath) - let cell = collectionView.cellForItem(at: indexPath) as? CommonCVC - let postId = cell!.postID - let sendingData = findDriveElementFrom(postId: postId) - postDelegate?.sendPostDriveElement(data: sendingData) + guard let cell = collectionView.cellForItem(at: indexPath) as? CommonCVC else { return } + postDelegate?.sendPostDetail(with: cell.postID) } diff --git a/ChaRo-iOS/ChaRo-iOS/Source/Views/Cells/TVC/HomeScene/HomeTodayDriveTVC.swift b/ChaRo-iOS/ChaRo-iOS/Source/Views/Cells/TVC/HomeScene/HomeTodayDriveTVC.swift index 12cfd122..5a02cf31 100644 --- a/ChaRo-iOS/ChaRo-iOS/Source/Views/Cells/TVC/HomeScene/HomeTodayDriveTVC.swift +++ b/ChaRo-iOS/ChaRo-iOS/Source/Views/Cells/TVC/HomeScene/HomeTodayDriveTVC.swift @@ -67,7 +67,8 @@ extension HomeTodayDriveTVC: UICollectionViewDelegate ,UICollectionViewDataSourc } func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { - postDelegate?.sendPostDriveElement(data: todayDriveList[indexPath.row]) + guard let cell = collectionView.cellForItem(at: indexPath) as? CommonCVC else { return } + postDelegate?.sendPostDetail(with: cell.postID) } diff --git a/ChaRo-iOS/ChaRo-iOS/Source/Views/Cells/TVC/ThemeScene/ThemePostAllTVC.swift b/ChaRo-iOS/ChaRo-iOS/Source/Views/Cells/TVC/ThemeScene/ThemePostAllTVC.swift index 760b9632..290665f8 100644 --- a/ChaRo-iOS/ChaRo-iOS/Source/Views/Cells/TVC/ThemeScene/ThemePostAllTVC.swift +++ b/ChaRo-iOS/ChaRo-iOS/Source/Views/Cells/TVC/ThemeScene/ThemePostAllTVC.swift @@ -12,7 +12,7 @@ protocol ThemeCollectionViewCellDelegate: class { } protocol PostIdDelegate { - func sendPostDriveElement(data: DriveElement?) + func sendPostDetail(with postId: Int) } class ThemePostAllTVC: UITableViewCell { @@ -114,10 +114,8 @@ extension ThemePostAllTVC: UICollectionViewDelegate, UICollectionViewDataSource, } func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { - let cell = collectionView.cellForItem(at: indexPath) as? CommonCVC - let postId = cell!.postID - let sendingData = findDriveElementFrom(postId: postId) - postDelegate?.sendPostDriveElement(data: sendingData) + guard let cell = collectionView.cellForItem(at: indexPath) as? CommonCVC else { return } + postDelegate?.sendPostDetail(with: cell.postID) } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { diff --git a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/HomeScene/HomePostVC.swift b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/HomeScene/HomePostVC.swift index afceac29..2de6b4b6 100644 --- a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/HomeScene/HomePostVC.swift +++ b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/HomeScene/HomePostVC.swift @@ -230,13 +230,10 @@ extension HomePostVC: UICollectionViewDelegate { func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "CommonCVC", for: indexPath) as? CommonCVC else { return UICollectionViewCell() } - cell.clickedPostCell = { postid in - let nextVC = PostDetailVC() - nextVC.setPostId(id: postid) - self.navigationController?.pushViewController(nextVC, animated: true) + cell.clickedPostCell = { [weak self] postId in + let nextVC = PostDetailVC(postId: postId) + self?.navigationController?.pushViewController(nextVC, animated: true) } - - cell.titleLabel.font = UIFont.notoSansBoldFont(ofSize: 14) guard let topCell = collectionView.dequeueReusableCell(withReuseIdentifier: "HomePostDetailCVC", for: indexPath) as? HomePostDetailCVC else {return UICollectionViewCell()} @@ -330,9 +327,8 @@ func dismissDropDownWhenTappedAround() { //postID 넘기기 위한 Delegate 구현 extension HomePostVC: PostIdDelegate { - func sendPostDriveElement(data: DriveElement?) { - let nextVC = PostDetailVC() - nextVC.setAdditionalDataOfPost(data: data) + func sendPostDetail(with postId: Int) { + let nextVC = PostDetailVC(postId: postId) navigationController?.pushViewController(nextVC, animated: true) } 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 edc65401..86f0c26c 100644 --- a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/HomeScene/HomeVC.swift +++ b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/HomeScene/HomeVC.swift @@ -195,8 +195,7 @@ class HomeVC: UIViewController { default: print("잘못된 경우") } if let nextVC = nextVC { - nextVC.modalPresentationStyle = .fullScreen - self.present(nextVC, animated: true) + navigationController?.pushViewController(nextVC, animated: true) } } @@ -605,9 +604,8 @@ extension HomeVC: CollectionViewCellDelegate { //postID 넘기기 위한 Delegate 구현 extension HomeVC: PostIdDelegate { - func sendPostDriveElement(data: DriveElement?) { - let nextVC = PostDetailVC() - nextVC.setAdditionalDataOfPost(data: data) + func sendPostDetail(with postId: Int) { + let nextVC = PostDetailVC(postId: postId) navigationController?.pushViewController(nextVC, animated: true) } } diff --git a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/MyPageScene/MyPageVC.swift b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/MyPageScene/MyPageVC.swift index 4c51dbd0..0ea84665 100644 --- a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/MyPageScene/MyPageVC.swift +++ b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/MyPageScene/MyPageVC.swift @@ -737,32 +737,24 @@ extension MyPageVC: UICollectionViewDelegate { extension MyPageVC: UICollectionViewDataSource { func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { - let detailVC = PostDetailVC() + var postId = 0 var driveData = MyPageDrive() //내가 작성한 글 태그 = 1 / 저장한 글 컬렉션 뷰 태그 = 2 if indexPath.row > 0 { - if collectionView.tag == 1 { - detailVC.setPostId(id: writenPostDriveData[indexPath.row-1].postID) - driveData = writenPostDriveData[indexPath.row-1] - } else { - detailVC.setPostId(id: savePostDriveData[indexPath.row-1].postID) + if collectionView.tag == 1 { + postId = writenPostDriveData[indexPath.row-1].postID + driveData = writenPostDriveData[indexPath.row-1] + } else { + postId = savePostDriveData[indexPath.row-1].postID driveData = savePostDriveData[indexPath.row-1] - } - detailVC.setAdditionalDataOfPost(data: DriveElement( - postID: driveData.postID, - title: driveData.title, - image: driveData.image, - region: driveData.region, - theme: driveData.theme, - warning: driveData.warning, - year: driveData.year, - month: driveData.month, - day: driveData.day, - isFavorite: driveData.isFavorite)) - } - if indexPath.row > 0 { - self.tabBarController?.tabBar.isHidden = true - self.navigationController?.pushViewController(detailVC, animated: true) + } + + let detailVC = PostDetailVC(postId: postId) + + if indexPath.row > 0 { + self.tabBarController?.tabBar.isHidden = true + self.navigationController?.pushViewController(detailVC, animated: true) + } } } diff --git a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/MyPageScene/OtherMyPageVC.swift b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/MyPageScene/OtherMyPageVC.swift index bef1b965..b59e00c5 100644 --- a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/MyPageScene/OtherMyPageVC.swift +++ b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/MyPageScene/OtherMyPageVC.swift @@ -534,49 +534,34 @@ extension OtherMyPageVC: UICollectionViewDataSource { let detailCell = collectionView.dequeueReusableCell(withReuseIdentifier:HomePostDetailCVC.identifier , for: indexPath) as! HomePostDetailCVC detailCell.delegate = self detailCell.setSelectName(name: currentState) - + if(indexPath.row == 0){ return detailCell } else { let writenElement = writenPostDriveData[indexPath.row-1] var writenTags = [writenElement.region, writenElement.theme, - writenElement.warning ?? ""] as [String] - cell.setData(image: writenPostDriveData[indexPath.row-1].image, - title: writenPostDriveData[indexPath.row-1].title, - tagCount:writenTags.count, tagArr: writenTags, - heart:writenPostDriveData[indexPath.row-1].favoriteNum, - save: writenPostDriveData[indexPath.row-1].saveNum, - year: writenPostDriveData[indexPath.row-1].year, - month: writenPostDriveData[indexPath.row-1].month, - day: writenPostDriveData[indexPath.row-1].day, - postID: writenPostDriveData[indexPath.row-1].postID) - return cell - + writenElement.warning ?? ""] as [String] + cell.setData(image: writenPostDriveData[indexPath.row-1].image, + title: writenPostDriveData[indexPath.row-1].title, + tagCount:writenTags.count, tagArr: writenTags, + heart:writenPostDriveData[indexPath.row-1].favoriteNum, + save: writenPostDriveData[indexPath.row-1].saveNum, + year: writenPostDriveData[indexPath.row-1].year, + month: writenPostDriveData[indexPath.row-1].month, + day: writenPostDriveData[indexPath.row-1].day, + postID: writenPostDriveData[indexPath.row-1].postID) + return cell + } } - func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { - let detailVC = PostDetailVC() - if indexPath.row > 0{ - //detailVC.setPostId(id: writenPostDriveData[indexPath.row-1].postID) - detailVC.setAdditionalDataOfPost(data: DriveElement.init( - postID: writenPostDriveData[indexPath.row-1].postID, - title: writenPostDriveData[indexPath.row-1].title, - image: writenPostDriveData[indexPath.row-1].image, - region: writenPostDriveData[indexPath.row-1].region, - theme: writenPostDriveData[indexPath.row-1].theme, - warning: writenPostDriveData[indexPath.row-1].warning, - year: writenPostDriveData[indexPath.row-1].year, - month: writenPostDriveData[indexPath.row-1].month, - day: writenPostDriveData[indexPath.row-1].day, - isFavorite: writenPostDriveData[indexPath.row-1].isFavorite)) + if indexPath.row > 0 { + let postId = writenPostDriveData[indexPath.row-1].postID + let detailVC = PostDetailVC(postId: postId) self.navigationController?.pushViewController(detailVC, animated: true) } } - - - } extension OtherMyPageVC: UICollectionViewDelegate { func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: diff --git a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/NotificationVC.swift b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/NotificationVC.swift index fbb1d8eb..984badaa 100644 --- a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/NotificationVC.swift +++ b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/NotificationVC.swift @@ -92,8 +92,8 @@ extension NotificationVC { otherVC.setOtherUserID(userID: notificationList[indexPath.row].followed ?? "") self.navigationController?.pushViewController(otherVC, animated: true) } else { - let detailVC = PostDetailVC() - detailVC.setPostId(id: notificationList[indexPath.row].postID ?? -1) + let postId = notificationList[indexPath.row].postID ?? -1 + let detailVC = PostDetailVC(postId: postId) self.navigationController?.pushViewController(detailVC, animated: true) } } 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 65e2c6a9..d53a3c96 100644 --- a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/PostSearchScene/SearchResultVC.swift +++ b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/PostSearchScene/SearchResultVC.swift @@ -157,10 +157,9 @@ extension SearchResultVC: UICollectionViewDataSource { let dropDownCell = collectionView.dequeueReusableCell(withReuseIdentifier: HomePostDetailCVC.identifier, for: indexPath) as? HomePostDetailCVC dropDownCell?.delegate = self topCVCCell?.delegate = self - cell?.clickedPostCell = { postid in - let nextVC = PostDetailVC() - nextVC.setPostId(id: postid) - self.navigationController?.pushViewController(nextVC, animated: true) + cell?.clickedPostCell = { [weak self] postId in + let nextVC = PostDetailVC(postId: postId) + self?.navigationController?.pushViewController(nextVC, animated: true) } if indexPath.row == 0 { if myCellIsFirstLoaded { diff --git a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/ThemeScene/ThemePostVC.swift b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/ThemeScene/ThemePostVC.swift index cae1d83b..2f7449ad 100644 --- a/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/ThemeScene/ThemePostVC.swift +++ b/ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/ThemeScene/ThemePostVC.swift @@ -269,9 +269,8 @@ extension ThemePostVC: ThemeNetworkDelegate { } extension ThemePostVC: PostIdDelegate { - func sendPostDriveElement(data: DriveElement?) { - let nextVC = PostDetailVC() - nextVC.setAdditionalDataOfPost(data: data) + func sendPostDetail(with postId: Int) { + let nextVC = PostDetailVC(postId: postId) navigationController?.pushViewController(nextVC, animated: true) } }