Skip to content
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 [#106] 마이페이지 탭바로 높이가 달라지는 오류 해결 #108

Merged
merged 4 commits into from
Jan 18, 2024

Conversation

boogios
Copy link
Member

@boogios boogios commented Jan 18, 2024

👻 PULL REQUEST

💻 작업한 내용

  • 마이페이지 탭바로 높이가 달라지는 오류 해결했습니다!

💡 참고사항

  • 이제는 마이페이지 갔다가 홈, 댓글 가도 텍스트뷰 높이가 달라지지 않습니다!!

📸 스크린샷

기능 스크린샷
GIF

📟 관련 이슈

@@ -109,7 +111,7 @@ final class MyPageAccountInfoViewController: UIViewController, UIGestureRecogniz

extension MyPageAccountInfoViewController {
private func setUI() {
self.title = "계정 정보"
self.title = StringLiterals.MyPage.MyPageAccountInfoNavigationTitle
self.view.backgroundColor = .donWhite

self.navigationController?.navigationBar.backgroundColor = .donWhite

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

다음은 코드 패치입니다. 코드 리뷰를 간단히 하여 버그 위험 및 개선 제안을 해드리겠습니다.

@@ -10,7 +10,7 @@ import UIKit
 
 import SnapKit
 
-final class MyPageAccountInfoViewController: UIViewController, UIGestureRecognizerDelegate {
+final class MyPageAccountInfoViewController: UIViewController {
     
     // MARK: - Properties
     
@@ -99,6 +99,8 @@ final class MyPageAccountInfoViewController: UIViewController, UIGestureRecogniz
         self.navigationController?.navigationBar.isHidden = false
         self.navigationController?.navigationBar.backgroundColor = .clear
         self.navigationController?.navigationBar.titleTextAttributes = [.foregroundColor: UIColor.donBlack]
+        self.tabBarController?.tabBar.isHidden = true
+        self.tabBarController?.tabBar.isTranslucent = true
         
         let backButton = UIBarButtonItem.backButton(target: self, action: #selector(backButtonTapped))
         self.navigationItem.leftBarButtonItem = backButton
@@ -109,7 +111,7 @@ final class MyPageAccountInfoViewController: UIViewController, UIGestureRecogniz
 
 extension MyPageAccountInfoViewController {
     private func setUI() {
-        self.title = "계정 정보"
+        self.title = StringLiterals.MyPage.MyPageAccountInfoNavigationTitle
         self.view.backgroundColor = .donWhite
         
         self.navigationController?.navigationBar.backgroundColor = .donWhite

개선 제안:

  1. UIGestureRecognizerDelegate 프로토콜을 구현하는 것이 없으므로, 클래스 선언에서 해당 프로토콜을 삭제할 수 있습니다.
  2. 탭바를 관리하기 위해 tabBarController?.tabBar.isHiddentrue로 설정하고, tabBarController?.tabBar.isTranslucenttrue로 설정하여 탭바가 숨겨지고 투명한 스타일이 적용되도록 할 수 있습니다.
  3. self.title을 하드코딩된 문자열 대신 StringLiterals를 사용하도록 변경하는 것이 좋습니다. 이렇게 하면 문자열이 나중에 변경되어도 모든 인스턴스에서 일관된 값을 사용할 수 있습니다.

더 자세한 리뷰나 버그 위험점은 주어진 정보로는 판단하기 어렵습니다. 전체 코드나 추가적인 내용이 있다면 제공해주시면 더 나은 리뷰를 할 수 있습니다.

self.view.backgroundColor = .donWhite
self.tabBarController?.tabBar.isHidden = true
self.tabBarController?.tabBar.isTranslucent = true
self.title = StringLiterals.MyPage.MyPageEditNavigationTitle
self.navigationItem.hidesBackButton = true
self.navigationController?.navigationBar.titleTextAttributes = [.foregroundColor: UIColor.donBlack]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 코드 패치는 MyPageEditProfileViewController 클래스를 수정하는 것으로 보입니다. 여러 개의 변경 사항과 개선될 수 있는 부분이 있습니다.

  1. UIGestureRecognizerDelegate 프로토콜을 더 이상 채택하지 않습니다. 이 프로토콜은 해당 클래스에서 사용되지 않고 제거되었는데, 관련 코드에서도 해당 프로토콜을 제거 할 수 있습니다.

  2. viewWillAppear(_ animated: Bool) 메서드 내에서 다음 변경 사항을 수행합니다:

    • self.navigationItem.hidesBackButton = true : 뒤로 가기 버튼을 숨기도록 설정합니다.
    • self.navigationController?.navigationBar.isHidden = false : 네비게이션 바를 표시합니다.
    • self.navigationController?.navigationBar.backgroundColor = .clear : 네비게이션 바의 배경색을 투명하게 설정합니다.
    • self.tabBarController?.tabBar.isHidden = true : 탭 바를 숨깁니다.
    • self.tabBarController?.tabBar.isTranslucent = true : 탭 바를 반투명으로 설정합니다.
  3. setUI() 메서드에서 다음 변경 사항이 이루어집니다:

    • 화면 제목을 StringLiterals.MyPage.MyPageEditNavigationTitle로 설정합니다.
    • 배경색을 .donWhite로 설정합니다.
    • 뒤로 가기 버튼을 숨깁니다.
    • 네비게이션 바의 글꼴 색상을 .donBlack으로 설정합니다.

이 외에도 코드 리뷰 과정에서 발견되지 않았지만 다른 잠재적인 버그나 개선 사항이 있을 수 있습니다.

@@ -359,6 +353,7 @@ extension MyPageViewController: UICollectionViewDelegate {
$0.top.equalTo(rootView.segmentedControl.snp.bottom).offset(2.adjusted)
$0.leading.trailing.equalToSuperview()
let navigationBarHeight = self.navigationController?.navigationBar.frame.height ?? 0
print("\(tabBarHeight)")
$0.height.equalTo(UIScreen.main.bounds.height - statusBarHeight - navigationBarHeight - self.tabBarHeight)
}
} else if yOffset >= (rootView.myPageProfileView.frame.height - statusBarHeight - navigationBarHeight) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

다음은 코드 패치에 대한 간단한 코드 리뷰를 도와드리겠습니다. 버그 위험 및 개선 제안을 환영합니다.

  1. 첫 번째 변경 사항은 viewWillAppear(_ animated: Bool) 메서드에서 탭 바의 isHiddenisTranslucent 속성을 설정하는 부분입니다. 이 부분은 보다 일관된 UI를 위해 추가되었습니다.

  2. 두 번째 변경 사항은 setUI() 메서드에서 탭 바의 isTranslucent 속성을 true로 설정하여 일부 불필요한 중복 설정을 제거하는 것입니다.

  3. 세 번째 변경 사항은 pageViewController.view의 제약 조건을 삭제하는 것입니다. 이는 코드 내에서 해당 제약 조건이 다시 정의되지 않은 상태에서 불필요하게 제거되는 것으로 보입니다.

  4. 네 번째 변경 사항은 pushViewController(_:animated:) 메서드 호출 시 애니메이션 사용 여부를 false로 변경한 것입니다. 이는 뷰 전환 시 애니메이션을 비활성화하여 사용자 경험을 향상시키기 위한 것입니다.

위의 변경 사항들은 주로 UI 관련 수정이며, 버그 위험이나 큰 문제는 없어 보입니다.

@@ -525,7 +525,7 @@ extension PostViewController: UICollectionViewDataSource, UICollectionViewDelega
cell.profileImageView.load(url: "\(viewModel.postReplyData[indexPath.row].memberProfileUrl)")
self.commentId = viewModel.postReplyData[indexPath.row].commentId
cell.likeButton.setImage(viewModel.postReplyData[indexPath.row].isLiked ? ImageLiterals.Posting.btnFavoriteActive : ImageLiterals.Posting.btnFavoriteInActive, for: .normal)
cell.isLiked = self.viewModel.postReplyData[indexPath.row].isLiked
cell.isLiked = self.viewModel.postReplyData[indexPath.row].isLiked
// 내가 투명도를 누른 유저인 경우 -85% 적용
if self.viewModel.postReplyData[indexPath.row].isGhost {
cell.grayView.alpha = 0.85

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 코드 패치를 간단히 검토해 드리겠습니다.

  1. line 29: 불필요한 공백 제거
  2. line 43: 불필요한 공백 제거
  3. line 47: grayView 변수 선언 시 초기화하는 부분에서 불필요한 공백 제거
  4. line 95-108: NotificationCenter의 addObserver를 extension으로 분리하여 관심사를 분리할 수 있음.
  5. line 182: indentation 정렬이 필요함.
  6. line 189-205: didDismissDetailNotification 메서드 내부의 코드들을 들여쓰기로 정렬
  7. line 213: indentation 정렬이 필요함.
  8. line 217-225: refreshControl과 관련된 코드들을 별도의 메서드로 분리하여 가독성 향상
  9. line 244-257: likeButtonTapped 파라미터와 관련된 코드들을 별도의 메서드로 분리하여 가독성 향상
  10. line 290-301: commentLikedButtonTapped 파라미터와 관련된 코드들을 별도의 메서드로 분리하여 가독성 향상
  11. line 331: indentation 정렬이 필요함.
  12. line 351-365: collectionView(_:cellForItemAt:) 메서드 내부의 코드들을 들여쓰기로 정렬
  13. 그 외에는 보이는 버그나 개선사항은 없어보입니다.

전반적으로 가독성을 위해 코드 들여쓰기와 정렬이 필요한 부분들이 있습니다. 코드의 구조적인 변경은 별도로 확인되지 않습니다.

let image = UIImageView()
image.contentMode = .scaleAspectFill
image.clipsToBounds = true
image.image = ImageLiterals.Onboarding.imgTwo
image.image = ImageLiterals.Common.imgProfile
image.backgroundColor = .lightGray
image.layer.cornerRadius = 20.adjusted
return image

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여러 개의 코드 변경 사항이 있지만 몇 가지 중요한 점을 강조해 보겠습니다:

  1. profileImageView 변수 선언에 private 접근 제어자가 없습니다. 원하는 경우 해당 변수를 외부에서 접근할 수 없도록 수정하십시오.

  2. 이미지 리터럴 (ImageLiterals) 대신 하드 코딩된 문자열을 사용하여 이미지를 할당하는 방식이 있습니다. 상수 또는 속성을 사용하여 이미지 식별자를 정의하면 코드의 유지 관리와 가독성이 향상됩니다.

  3. image.backgroundColor.lightGray로 설정했습니다. 이 값은 UI 디자인과 일치하지 않을 수 있습니다. 선택적으로 배경색을 조정하여 사용자 인터페이스에 더 적합한 색상을 선택할 수 있습니다.

  4. 클래스명인 PostReplyTextFieldView를 기반으로 하는 클래스입니다. 해당 클래스 정의 부분이 주어지지 않아 해당 부분의 코드를 검토할 수 없습니다. 다른 문제가 발생하지 않는 한, 코드 패치의 나머지 부분이 잘 작동할 것으로 보입니다.

위의 사항을 고려하여 코드를 리뷰하고 방어적인 프로그래밍 원칙을 준수하는지 확인하십시오.

Copy link
Collaborator

@Heyjooo Heyjooo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p3
수고하셨습니다 !!!!

@boogios boogios merged commit ff1a066 into develop Jan 18, 2024
1 check passed
@boogios boogios deleted the fix/#106-textViewHeight branch January 18, 2024 16:34
@@ -359,6 +353,7 @@ extension MyPageViewController: UICollectionViewDelegate {
$0.top.equalTo(rootView.segmentedControl.snp.bottom).offset(2.adjusted)
$0.leading.trailing.equalToSuperview()
let navigationBarHeight = self.navigationController?.navigationBar.frame.height ?? 0
print("\(tabBarHeight)")
$0.height.equalTo(UIScreen.main.bounds.height - statusBarHeight - navigationBarHeight - self.tabBarHeight)
}
} else if yOffset >= (rootView.myPageProfileView.frame.height - statusBarHeight - navigationBarHeight) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

다음은 코드 패치에 대한 간단한 코드 리뷰입니다.

  1. 노출 여부 설정:

    • self.tabBarController?.tabBar.isHidden = falseself.tabBarController?.tabBar.isTranslucent = false는 정확한 노출 여부를 설정하는 것으로 보입니다. 이 변경사항은 필요하다면 유용할 수 있습니다.
  2. 제약 조건 재설정:

    • rootView.pageViewController.view.snp.remakeConstraints의 제약 조건을 제거하는 것은 해당 제약 조건이 필요하지 않다는 의미일 수 있습니다. 이 변경사항은 별도의 제약 조건을 추가하기 전에 확인되어야 합니다.
  3. UI 설정:

    • self.navigationController?.navigationBar.backgroundColor, self.navigationController?.navigationBar.barTintColor, self.tabBarController?.tabBar.isTranslucent 설정은 UI 요소를 변경하는 것입니다. 코드 상에서 이러한 설정들은 원래 값과 목적에 따라 적절히 검토되어야 합니다.
  4. 애니메이션 옵션 변경:

    • pushViewController(_:animated:) 메서드의 애니메이션 옵션은 수정된 모습으로 변경되었습니다. 일부 뷰 컨트롤러는 애니메이션 없이 화면에 표시됩니다(animated: false).
    • 이는 애니메이션이 필요하지 않을 때 성능상의 이점이 있을 수 있습니다.
  5. 새로운 print 문장:

    • 마지막 변경부분에 추가된 print("\(tabBarHeight)")는 디버깅 목적으로 사용될 수 있는 것 같습니다.

이외의 버그 리스크나 개선 제안은 별도로 확인되지 않았습니다. 이 코드 패치를 적용할 때 위의 사항들을 고려하면 좋을 것입니다.

@@ -558,7 +558,7 @@ extension PostViewController: UICollectionViewDataSource, UICollectionViewDelega
cell.profileImageView.load(url: "\(viewModel.postReplyData[indexPath.row].memberProfileUrl)")
self.commentId = viewModel.postReplyData[indexPath.row].commentId
cell.likeButton.setImage(viewModel.postReplyData[indexPath.row].isLiked ? ImageLiterals.Posting.btnFavoriteActive : ImageLiterals.Posting.btnFavoriteInActive, for: .normal)
cell.isLiked = self.viewModel.postReplyData[indexPath.row].isLiked
cell.isLiked = self.viewModel.postReplyData[indexPath.row].isLiked
// 내가 투명도를 누른 유저인 경우 -85% 적용
if self.viewModel.postReplyData[indexPath.row].isGhost {
cell.grayView.alpha = 0.85

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아래는 코드 패치입니다. 코드 리뷰를 간단히 해드리겠습니다. 버그 위험과/또는 개선 제안 등 모든 사항을 환영합니다:

  1. 44번째 줄: lazy var postView = PostView() 뒤에 있는 들여쓰기가 이상합니다. 수정이 필요합니다.
  2. 94번째 줄: addObserver의 여는 소괄호 앞에 있는 들여쓰기가 이상합니다. 수정이 필요합니다.
  3. 186번째 줄: refreshPost 앞에 있는 @objc 키워드를 확인하세요. 정확한 메서드 이름이어야 합니다.
  4. 432번째 줄: store(in: self.cancelBag) 다음에 있는 들여쓰기가 이상합니다. 수정이 필요합니다.
  5. 558번째 줄: cell.isLiked = self.viewModel.postReplyData[indexPath.row].isLiked 앞에 있는 불필요한 공백을 제거하세요.

위와 같은 몇 가지 작은 문제가 있는 것으로 보입니다. 함께 코드를 실행해보고, 기능적인 측면에서도 문제가 없는지 확인하는 것이 좋습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Fix] 글쓰기, 답글 달기 텍스트뷰 높이 조정
2 participants