앱 최초실행 시 OnboardingPage, 그 이후에는 MainTabBarController의 Home 화면을 보여줍니다.#3
Merged
앱 최초실행 시 OnboardingPage, 그 이후에는 MainTabBarController의 Home 화면을 보여줍니다.#3
Conversation
- HomeViewController 추가 - TapBarContentProtocol 추가 - FlowCoordinator 추가하여 화면전환 구현 (ViewModel의 actions를 통해 전환), 의존성 주입 관리
- UserDefault 사용
Owner
화면전환 동작을 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
배경
앱을 처음 설치하여 실행한 경우에만 OnboardingPage를 보여주고 이후에는 Home 화면을 바로 보여주도록 했습니다.
앱을 실행할 때마다 OnboardingPage를 보여주는 것은 비효율적이라 판단했고, 대부분의 상용 앱도 이런 형태롤 갖추고 있어 해당 방식을 택했습니다.
작업 내용
1. MainTabBarController를 통한 Tab Bar 구현
생성자 주입을 통해Tab Bar에 반영할 화면정보를 전달했습니다. Home 화면에서Tab Bar와Navigation Bar가 모두 존재합니다.MainTabBarController를 초기화하는 과정에서 일부 프로퍼티가viewDidLoad호출 이후에 초기화되는 문제가 발생했습니다.확인 결과,
UITabBarController이니셜라이저 내부에super.init이 호출되면서 비정상적인 side-effect가 발생하는 것이 원인이었습니다.따라서 일반적으로
viewDidLoad에 배치했던 메서드를 부득이viewWillAppear에서 호출하여 문제를 해결했습니다.2. UserDefault를 활용하여 앱이 처음 실행되었는지 확인
FirstLaunchChecker를 생성하여 UserDefault가"isFirstLaunched"를 키로 값을 가지고 있는지에 따라 Bool 타입을 반환하도록 구현했습니다.이를 통해 첫 실행일 경우 OnboardingPage를, 첫 실행이 아니면
MainTabBarController를 보여주도록 했습니다.3. FlowCoordinator를 통한 MVVM-C 구현
FlowCoordinator를 통해 의존성 주입을 관리하고, 화면전환 역할을 담당하도록 했습니다.생성자 주입을 통해navigationController를 주입받고, 화면전환 시 해당navigationController가 다음 화면을 push 하도록 했습니다.이때 화면전환 관련 정보는
ViewModel이 알고 있는 것이 적절하다고 판단했습니다. 따라서 화면전환 동작을 클로저 타입으로actions에 저장하고, actions를ViewModel의 생성자 주입으로 전달했습니다.테스트 방법
리뷰 노트
함께 메뉴 결정,혼밥 메뉴 결정탭을 눌렀을 때 나오는 페이지 구현 예정입니다.스크린샷