Skip to content

[Fix] BaseViewController TabBar Hidden 조건 추가#89

Open
choijungp wants to merge 1 commit intodevelopfrom
fix/tabBar
Open

[Fix] BaseViewController TabBar Hidden 조건 추가#89
choijungp wants to merge 1 commit intodevelopfrom
fix/tabBar

Conversation

@choijungp
Copy link
Contributor

@choijungp choijungp commented Mar 12, 2026

🌁 Background

  1. BaseViewController에서 네트워크 오류에 따른 뷰를 보여줄 때 탭바 히든 처리를 진행
  2. 그로 인해 BaseViewController를 상속한 뷰들은 네트워크 수행 후 문제가 없다면 탭바가 보이는게 됨
  3. 하지만 온보딩 선택 후 맞춤 추천 루틴을 보여주는 화면에서 2)의 이유로 인해 탭바가 보이게 됨
  4. 그렇다고 BaseViewController에 있는 TabBar hidden 로직을 수정하면 네트워크 오류 화면이 사라진 후 탭바 보이는게 제대로 동작하지 않음
  5. 이를 해결하기 위해 해당 PR를 작업했어유 ~

📱 Screenshot

  • 네트워크 오류 화면
ScreenRecording_03-12-2026.15-06-27_1.mp4
  • 온보딩 문제 화면
ScreenRecording_03-12-2026.15-06-53_1.MP4

👩‍💻 Contents

  • BaseViewController TabBar Hidden 조건 추가

📝 Review Note

1. isShowingNetworkError 프로퍼티 삭제

isShowingNetworkError 가 아무 역할을 안하는 것 같아가주구 삭제했어요 !!!
handleNetworkErrorView 함수 내부에서도 show로 처리하는 것 같더라구용 ??? 암튼 잘못 삭제했다면 알려주세요 !!!

2. isShowingTabBar 프로퍼티 추가

탭바 hidden 여부를 처리하기 위한 isShowingTabBar 프로퍼티를 추가했어유
근데 상속 받은 View에서 override로 값을 설정해야 해가주구 private으로 못해서 외부 노출 위험이 있습니다 ...
더 나은 방안이 있다면 말씀해주세요 !!!!

Summary by CodeRabbit

릴리스 노트

  • 버그 수정
    • 권장 루틴 결과 화면에서 탭 바 표시 동작이 개선되었습니다.

@choijungp choijungp requested a review from taipaise March 12, 2026 06:12
@choijungp choijungp self-assigned this Mar 12, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 12, 2026

개요

기본 뷰 컨트롤러에서 네트워크 오류 플래그를 탭 바 표시 여부 플래그로 교체했습니다. 추천 루틴 결과 뷰 컨트롤러에서 탭 바 가시성을 false로 재정의합니다.

변경 사항

Cohort / File(s) Summary
BaseViewController 탭 바 가시성 리팩토링
Projects/Presentation/Sources/Common/Protocol/BaseViewController.swift
isShowingNetworkError 비공개 속성을 isShowingTabBar: Bool { true } 공개 속성으로 교체했습니다. deinit 가드와 네트워크 오류 처리 로직에서 플래그 사용을 업데이트하여 조건부 탭 바 복원을 구현했습니다.
ResultRecommendedRoutineViewController 탭 바 표시 재정의
Projects/Presentation/Sources/ResultRecommendedRoutine/View/ResultRecommendedRoutineViewController.swift
isShowingTabBar 속성을 false로 반환하도록 재정의하여 이 뷰 컨트롤러에 대한 탭 바 가시성을 비활성화합니다.

코드 리뷰 예상 수준

🎯 2 (Simple) | ⏱️ ~8분

축하 시

🐰 탭 바 춤을 춘다네,
네트워크 오류는 이제 없고,
가시성 깃발 하나로 제어하니,
코드는 맑고 깔끔하네! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목이 변경 사항의 주요 내용과 관련이 있으며, BaseViewController의 TabBar 숨김 조건 추가라는 핵심 변화를 명확하게 설명합니다.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/tabBar

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Projects/Presentation/Sources/Common/Protocol/BaseViewController.swift (1)

24-28: ⚠️ Potential issue | 🟠 Major

탭 바 복원 여부는 isShowingTabBar가 아니라 “이 클래스가 직접 숨겼는지”로 추적하는 편이 안전합니다.

isShowingNetworkError를 제거하면서 deinit가 이제 isShowingTabBar == true인 화면에서 항상 탭 바를 다시 보이게 됩니다. 이렇게 되면 이 화면이 탭 바를 숨긴 적이 없어도 다른 전환이나 컨테이너가 숨긴 상태를 덮어써서, 네트워크 에러와 무관한 플로우에서도 탭 바가 갑자기 나타나는 회귀가 생길 수 있습니다. BaseViewController가 직접 숨긴 경우만 별도 플래그로 기록하고, show == false/deinit에서 그 플래그가 있을 때만 복원해 주세요.

수정 예시
 public class BaseViewController<T: ViewModel>: UIViewController {
     let viewModel: T
     private var baseCancellables = Set<AnyCancellable>()
     private lazy var networkErrorView = NetworkErrorView()
+    private var didHideTabBarForNetworkError = false
     var isShowingTabBar: Bool { true }

     deinit {
-        guard isShowingTabBar else { return }
+        guard didHideTabBarForNetworkError else { return }

         DispatchQueue.main.async { [weak tabBarController = self.tabBarController] in
             tabBarController?.tabBar.isHidden = false
         }
     }
@@
     private func handleNetworkErrorView(show: Bool) {
         if show {
             view.bringSubviewToFront(networkErrorView)
             networkErrorView.isHidden = false
-            tabBarController?.tabBar.isHidden = true
+            if isShowingTabBar {
+                tabBarController?.tabBar.isHidden = true
+                didHideTabBarForNetworkError = true
+            }
         } else {
             networkErrorView.isHidden = true
-            if isShowingTabBar {
+            if didHideTabBarForNetworkError {
                 tabBarController?.tabBar.isHidden = false
+                didHideTabBarForNetworkError = false
             }
         }
     }
 }

Also applies to: 79-88

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Projects/Presentation/Sources/Common/Protocol/BaseViewController.swift`
around lines 24 - 28, The controller currently restores the tab bar based on
isShowingTabBar which can erroneously unhide the tab bar when this class never
hid it; add a private Bool property (e.g., didHideTabBarBySelf) on
BaseViewController, set it true at the exact point you hide the tab bar (the
method/logic that currently hides the bar), and when restoring the bar (in
deinit and the show==false branch) only unhide if didHideTabBarBySelf is true,
then reset it to false; apply the same change to the corresponding restore block
around lines 79-88 so only the controller that hid the tab bar will restore it.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@Projects/Presentation/Sources/Common/Protocol/BaseViewController.swift`:
- Around line 24-28: The controller currently restores the tab bar based on
isShowingTabBar which can erroneously unhide the tab bar when this class never
hid it; add a private Bool property (e.g., didHideTabBarBySelf) on
BaseViewController, set it true at the exact point you hide the tab bar (the
method/logic that currently hides the bar), and when restoring the bar (in
deinit and the show==false branch) only unhide if didHideTabBarBySelf is true,
then reset it to false; apply the same change to the corresponding restore block
around lines 79-88 so only the controller that hid the tab bar will restore it.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c625cce8-49de-4e38-82ad-f7f0f8be9939

📥 Commits

Reviewing files that changed from the base of the PR and between cec9be8 and cd3fcb4.

📒 Files selected for processing (2)
  • Projects/Presentation/Sources/Common/Protocol/BaseViewController.swift
  • Projects/Presentation/Sources/ResultRecommendedRoutine/View/ResultRecommendedRoutineViewController.swift

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant