-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix [#96] 마이페이지 디테일 수정 #98
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,7 +77,10 @@ final class HomeViewController: UIViewController { | |
override func viewDidLayoutSubviews() { | ||
super.viewDidLayoutSubviews() | ||
|
||
tabBarHeight = tabBarController?.tabBar.frame.size.height ?? 0 | ||
let safeAreaHeight = view.safeAreaInsets.bottom | ||
let tabBarHeight: CGFloat = 70.0 | ||
|
||
self.tabBarHeight = tabBarHeight + safeAreaHeight | ||
} | ||
|
||
override func viewWillAppear(_ animated: Bool) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 코드 패치는 여러 가지 개선 사항과 버그 위험이 있습니다:
적절하게 수정된 코드: final class HomeViewController: UIViewController {
// MARK: - Properties
private var tabBarHeight: CGFloat = 70.0
// MARK: - Lifecycle Methods
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
let safeAreaHeight = view.safeAreaInsets.bottom
tabBarHeight = tabBarHeight + safeAreaHeight
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// 추가 작업을 수행하거나 초기화를 진행할 수 있습니다.
}
} 주어진 코드 패치는 큰 문제는 없지만 일부 개선 사항이 있습니다. 나머지는 추가 기능 및 전반적인 앱의 목적과 요구사항 등에 맞게 코드를 구성해야 합니다. |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,23 +132,28 @@ extension MyPageCommentViewController: UICollectionViewDataSource, UICollectionV | |
cell.likeNumLabel.text = "\(commentData[indexPath.row].commentLikedNumber)" | ||
cell.commentNumLabel.text = "\(commentData[indexPath.row].commentLikedNumber)" | ||
cell.profileImageView.load(url: "\(commentData[indexPath.row].memberProfileUrl)") | ||
|
||
cell.likeStackView.snp.remakeConstraints { | ||
$0.top.equalTo(cell.contentTextLabel.snp.bottom).offset(4.adjusted) | ||
$0.height.equalTo(cell.commentStackView) | ||
$0.trailing.equalTo(cell.kebabButton).inset(8.adjusted) | ||
$0.bottom.equalToSuperview().inset(16) | ||
} | ||
|
||
cell.commentStackView.isHidden = true | ||
|
||
return cell | ||
} | ||
|
||
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { | ||
let destinationViewController = PostViewController(viewModel: PostViewModel(networkProvider: NetworkService())) | ||
self.navigationController?.pushViewController(destinationViewController, animated: true) | ||
let contentId = commentData[indexPath.row].contentId | ||
NotificationCenter.default.post(name: MyPageContentViewController.pushViewController, object: nil, userInfo: ["contentId": contentId]) | ||
} | ||
|
||
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { | ||
return CGSize(width: 343.adjusted, height: 210.adjusted) | ||
} | ||
|
||
func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { | ||
guard let footer = homeCollectionView.dequeueReusableSupplementaryView(ofKind: UICollectionView.elementKindSectionFooter, withReuseIdentifier: "HomeCollectionFooterView", for: indexPath) as? HomeCollectionFooterView else { return UICollectionReusableView() } | ||
return footer | ||
} | ||
|
||
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize { | ||
|
||
return CGSize(width: UIScreen.main.bounds.width, height: 24.adjusted) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아래는 코드의 수정 사항입니다:
이 외에는 주요한 버그가나 개선 사항을 찾지 못했습니다. |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ final class MyPageContentViewController: UIViewController { | |
|
||
// MARK: - Properties | ||
|
||
static let pushViewController = NSNotification.Name("pushViewController") | ||
|
||
var showUploadToastView: Bool = false | ||
var deleteBottomsheet = DontBeBottomSheetView(singleButtonImage: ImageLiterals.Posting.btnDelete) | ||
private let refreshControl = UIRefreshControl() | ||
|
@@ -163,19 +165,14 @@ extension MyPageContentViewController: UICollectionViewDataSource, UICollectionV | |
} | ||
|
||
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { | ||
let destinationViewController = PostViewController(viewModel: PostViewModel(networkProvider: NetworkService())) | ||
self.navigationController?.pushViewController(destinationViewController, animated: true) | ||
let contentId = contentData[indexPath.row].contentId | ||
NotificationCenter.default.post(name: MyPageContentViewController.pushViewController, object: nil, userInfo: ["contentId": contentId]) | ||
} | ||
|
||
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { | ||
return CGSize(width: 343.adjusted, height: 210.adjusted) | ||
} | ||
|
||
// func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { | ||
// guard let footer = homeCollectionView.dequeueReusableSupplementaryView(ofKind: UICollectionView.elementKindSectionFooter, withReuseIdentifier: "HomeCollectionFooterView", for: indexPath) as? HomeCollectionFooterView else { return UICollectionReusableView() } | ||
// return footer | ||
// } | ||
|
||
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize { | ||
|
||
return CGSize(width: UIScreen.main.bounds.width, height: 24.adjusted) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 해당 코드 패치에 대한 간단한 코드 리뷰를 도와드리겠습니다.
개선 사항:
위에서 언급한 개선 사항을 참고하시면 됩니다. |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,6 +69,7 @@ final class MyPageViewController: UIViewController { | |
setUI() | ||
setLayout() | ||
setDelegate() | ||
setNotification() | ||
setAddTarget() | ||
} | ||
|
||
|
@@ -93,7 +94,7 @@ final class MyPageViewController: UIViewController { | |
super.viewDidLayoutSubviews() | ||
|
||
let safeAreaHeight = view.safeAreaInsets.bottom | ||
let tabBarHeight: CGFloat = 70.0.adjusted | ||
let tabBarHeight: CGFloat = 70.0 | ||
|
||
self.tabBarHeight = tabBarHeight + safeAreaHeight | ||
|
||
|
@@ -138,6 +139,10 @@ extension MyPageViewController { | |
rootView.pageViewController.dataSource = self | ||
} | ||
|
||
private func setNotification() { | ||
NotificationCenter.default.addObserver(self, selector: #selector(pushViewController), name: MyPageContentViewController.pushViewController, object: nil) | ||
} | ||
|
||
private func setAddTarget() { | ||
rootView.segmentedControl.addTarget(self, action: #selector(changeValue(control:)), for: .valueChanged) | ||
rootView.myPageBottomsheet.profileEditButton.addTarget(self, action: #selector(profileEditButtonTapped), for: .touchUpInside) | ||
|
@@ -176,6 +181,9 @@ extension MyPageViewController { | |
.receive(on: RunLoop.main) | ||
.sink { data in | ||
self.rootView.myPageCommentViewController.commentData = data | ||
if !data.isEmpty { | ||
self.rootView.myPageCommentViewController.noCommentLabel.isHidden = true | ||
} | ||
self.rootView.myPageCommentViewController.homeCollectionView.reloadData() | ||
} | ||
.store(in: self.cancelBag) | ||
|
@@ -197,6 +205,15 @@ extension MyPageViewController { | |
} | ||
} | ||
|
||
@objc | ||
private func pushViewController(_ notification: Notification) { | ||
if let contentId = notification.userInfo?["contentId"] as? Int { | ||
let destinationViewController = PostViewController(viewModel: PostViewModel(networkProvider: NetworkService())) | ||
destinationViewController.contentId = contentId | ||
self.navigationController?.pushViewController(destinationViewController, animated: true) | ||
} | ||
} | ||
|
||
@objc | ||
private func changeValue(control: UISegmentedControl) { | ||
self.currentPage = control.selectedSegmentIndex | ||
|
@@ -300,15 +317,11 @@ extension MyPageViewController: UICollectionViewDelegate { | |
|
||
scrollView.isScrollEnabled = true | ||
rootView.myPageContentViewController.homeCollectionView.isScrollEnabled = false | ||
rootView.myPageContentViewController.homeCollectionView.isUserInteractionEnabled = false | ||
rootView.myPageCommentViewController.homeCollectionView.isScrollEnabled = false | ||
rootView.myPageCommentViewController.homeCollectionView.isUserInteractionEnabled = false | ||
|
||
if yOffset <= -(navigationBarHeight + statusBarHeight) { | ||
rootView.myPageContentViewController.homeCollectionView.isScrollEnabled = false | ||
rootView.myPageContentViewController.homeCollectionView.isUserInteractionEnabled = false | ||
rootView.myPageCommentViewController.homeCollectionView.isScrollEnabled = false | ||
rootView.myPageCommentViewController.homeCollectionView.isUserInteractionEnabled = false | ||
yOffset = -(navigationBarHeight + statusBarHeight) | ||
rootView.segmentedControl.frame.origin.y = yOffset + statusBarHeight + navigationBarHeight | ||
rootView.segmentedControl.snp.remakeConstraints { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아래는 코드 패치에 대한 간단한 코드 리뷰입니다:
개선사항:
위의 지적을 참고하여 코드를 수정할 수 있습니다. |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -158,16 +158,20 @@ extension MyPageView { | |
private func infoButtonTapped() { | ||
self.myPageScrollView.isScrollEnabled = false | ||
|
||
transparencyInfoView = DontBeTransparencyInfoView() | ||
self.addSubview(transparencyInfoView ?? DontBeTransparencyInfoView()) | ||
self.transparencyInfoView = DontBeTransparencyInfoView() | ||
|
||
transparencyInfoView?.snp.makeConstraints { | ||
$0.edges.equalToSuperview() | ||
if let window = UIApplication.shared.keyWindowInConnectedScenes { | ||
window.addSubview(transparencyInfoView ?? DontBeTransparencyInfoView()) | ||
} | ||
|
||
self.transparencyInfoView?.snp.makeConstraints { | ||
$0.top.leading.trailing.equalToSuperview() | ||
$0.height.equalTo(UIScreen.main.bounds.height) | ||
} | ||
|
||
transparencyInfoView?.bringSubviewToFront(self) | ||
transparencyInfoView?.closeButton.addTarget(self, action: #selector(closeButtonTapped), for: .touchUpInside) | ||
transparencyInfoView?.infoScrollView.delegate = self | ||
self.transparencyInfoView?.bringSubviewToFront(self) | ||
self.transparencyInfoView?.closeButton.addTarget(self, action: #selector(closeButtonTapped), for: .touchUpInside) | ||
self.transparencyInfoView?.infoScrollView.delegate = self | ||
} | ||
|
||
@objc | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아래는 코드 패치입니다. 코드 리뷰를 간단히 해드리겠습니다. 버그 가능성 및 개선 제안은 환영합니다: @@ -158,16 +158,20 @@ extension MyPageView {
이 코드의 문제점이나 개선할 사항은 없어보입니다. 다만, 'transparencyInfoView'가 Optional로 선언되어 있으므로 올바르게 처리되었는지 확인이 필요합니다. 또한 UIApplication.shared.keyWindowInConnectedScenes에서 반환된 window가 nil이 아닌지 확인해야 합니다. 이외에는 버그의 위험이나 개선점은 보이지 않습니다. |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import Combine | |
final class PostViewController: UIViewController { | ||
|
||
// MARK: - Properties | ||
|
||
var tabBarHeight: CGFloat = 0 | ||
private lazy var postUserNickname = postView.postNicknameLabel.text | ||
private lazy var postDividerView = postView.horizontalDivierView | ||
|
@@ -80,7 +81,10 @@ final class PostViewController: UIViewController { | |
override func viewDidLayoutSubviews() { | ||
super.viewDidLayoutSubviews() | ||
|
||
tabBarHeight = tabBarController?.tabBar.frame.size.height ?? 0 | ||
let safeAreaHeight = view.safeAreaInsets.bottom | ||
let tabBarHeight: CGFloat = 70.0 | ||
|
||
self.tabBarHeight = tabBarHeight + safeAreaHeight | ||
} | ||
|
||
override func viewWillAppear(_ animated: Bool) { | ||
|
@@ -92,7 +96,11 @@ final class PostViewController: UIViewController { | |
|
||
let backButton = UIBarButtonItem.backButton(target: self, action: #selector(backButtonPressed)) | ||
self.navigationItem.leftBarButtonItem = backButton | ||
|
||
// self.textFieldView.snp.remakeConstraints { | ||
// $0.leading.trailing.equalToSuperview() | ||
// $0.bottom.equalTo(self.view.safeAreaLayoutGuide).offset(-tabBarHeight) | ||
// $0.height.equalTo(56.adjusted) | ||
// } | ||
getAPI() | ||
} | ||
} | ||
|
@@ -136,7 +144,7 @@ extension PostViewController { | |
} | ||
|
||
textFieldView.snp.makeConstraints { | ||
$0.bottom.equalTo(tabBarHeight.adjusted) | ||
$0.bottom.equalTo(self.view.safeAreaLayoutGuide).offset(-tabBarHeight) | ||
$0.leading.trailing.equalToSuperview() | ||
$0.height.equalTo(56.adjusted) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아래는 코드 패치에 대한 간단한 코드 리뷰입니다. 버그 위험과/또는 개선 제안이 있으면 알려주세요:
모든 코드가 리뷰되었으며 개선 사항은 다음과 같습니다:
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ final class WriteReplyViewController: UIViewController { | |
}.eraseToAnyPublisher() | ||
|
||
var contentId: Int = 0 | ||
|
||
var tabBarHeight: CGFloat = 0 | ||
|
||
// MARK: - UI Components | ||
|
||
|
@@ -61,6 +61,15 @@ final class WriteReplyViewController: UIViewController { | |
override func viewWillAppear(_ animated: Bool) { | ||
bindViewModel() | ||
} | ||
|
||
override func viewDidLayoutSubviews() { | ||
super.viewDidLayoutSubviews() | ||
|
||
let safeAreaHeight = view.safeAreaInsets.bottom | ||
let tabBarHeight: CGFloat = 70.0 | ||
|
||
self.tabBarHeight = tabBarHeight + safeAreaHeight | ||
} | ||
} | ||
|
||
// MARK: - Extensions | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 해당 코드 패치에 대한 간단한 코드 리뷰를 도와드리겠습니다. 버그 위험과 개선 제안을 환영합니다: @@ -22,7 +22,7 @@ final class WriteReplyViewController: UIViewController { var contentId: Int = 0+var tabBarHeight: CGFloat = 0 // MARK: - UI Components @@ -61,6 +61,15 @@ final class WriteReplyViewController: UIViewController {
} // MARK: - Extensions 개선 제안:
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,7 +149,7 @@ extension WriteTextView { | |
keyboardToolbarView.snp.makeConstraints { | ||
$0.leading.trailing.equalToSuperview() | ||
$0.height.equalTo(56.adjusted) | ||
$0.bottom.equalToSuperview() | ||
$0.bottom.equalTo(self.safeAreaLayoutGuide) | ||
} | ||
|
||
circleProgressBar.snp.makeConstraints { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 제가 어떠한 코드 리뷰를 진행하겠습니다. 주어진 코드 패치의 변경 내용은 이 변경 사항은 안전 영역 레이아웃 가이드에 대한 제약 조건을 사용하도록 수정하는 것으로 보입니다. 이와 같은 변경으로 인해 화면 하단에 위치한 키보드 도구 모음 뷰의 배치가 조정됩니다. 추가적인 버그 위험성이나 개선 제안은 보이지 않습니다. 다만, 제공된 코드 스니펫은 완전하지 않으므로, 전체 코드 컨텍스트를 고려하여 보다 자세한 검토가 필요할 수 있습니다. |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 코드 패치는
DontBeTransparencyInfoView
의 확장입니다.setLayout()
함수 내부에서container
의 레이아웃을 설정하고 있습니다. 이 부분에 대한 리뷰를 해보도록 하겠습니다.$0.top.equalToSuperview().inset(67.adjusted)
수정 후 코드:
$0.centerY.equalToSuperview()
개선 제안:
top
constraint를centerY
로 변경했습니다. 이러한 변경은 원하는 결과에 따라 달라질 수 있지만, 컨테이너를 수직 중앙 정렬할 수 있습니다.그 외에는 주석 코드를 포함한 다른 부분에 대한 정보가 없어서 현재 부위의 일부만 확인할 수 있습니다.