Main 화면의 NavigationBar 우상단의 설정 버튼을 탭하면 설정 화면이 나타납니다.#6
Merged
yanghojoon merged 3 commits intodevelopfrom Jun 8, 2022
Merged
Conversation
- SettingCell과 VersionCell을 각각 두어 Section 별로 다른 Cell을 dequeue 함 - Cell을 register하고 dequeue하는 메서드 extension으로 구현 - FlowCoordinator에 showSettingPage action 추가
- 기존의 DislikedFoodSurvey ViewModel/ViewController를 재활용 - Realm 데이터를 read하여 CollectionView에 반영 - Realm CRUD 메서드를 RealmManager로 분리 - FirstLaunchChecker의 UserDefault 값을 변경하는 시점 변경 (못먹는음식 화면의 확인 버튼을 탭한 이후)
- ViewModel을 통해 NavigationController에서 pop하도록 함
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.
배경
사용자가 못먹는 음식 리스트를 수정하고, App에 대한 다양한 정보를 확인할 수 있도록 하기 위해
설정화면을 구현했습니다.탭바를 사용하는 대부분의 상용앱은마이페이지 탭이 있는데, 우리뭐먹지 앱 기능상 사용자 개인정보를 처리하지 않으므로 마이페이지가 없고, 설정 화면에서는 부차적인 기능만 수행하므로 별도 탭을 만들지 않고 NavigationBar에서 접근하도록 구현했습니다.작업 내용
1. UITableView를 통한 설정 화면 리스트 구현
설정화면의 경우 항상 List로 구성이 된다고 판단했습니다. 따라서
CollectionView가 아닌TableView를 활용해 설정 페이지를 만들었습니다. Version Update를 위한 Cell은 구성이 달랐기에VersionCell과 일반적인SettingCell을 구분했습니다.또한 설정의 목록은 고정적이므로 Diffable DataSource를 사용하지 않았습니다.
2. 3개 Section으로 구분하고, 2개의 Cell Type을 활용
Section은
dislikedFood,ordinary,version3가지로 구분했습니다.이처럼 TableView에 여러 개의 Section이 있는 경우 viewModelData.bind(to: tableView.rx.items) 형태로 binding이 불가능하여, UITableViewDataSource 메서드를 사용했습니다.
또한 설정 화면에 필요한 Item의 경우
SettingItem프로토콜을 준수하는OrdinarySettingItem과VersionSettingItem을 두어SettingViewModel이 가지고 있도록 했습니다.이후 rx를 통해 SettingItem을 전달받아, UITableViewDataSource 메서드를 사용하여 TableView를 구성했습니다.
3. Delegate 패턴으로 버전정보의
업데이트버튼의 탭 이벤트를 처리사용자의 버전정보와 앱의 최신버전을 비교하여 업데이트가 가능한 경우 버튼 타이틀을
업데이트로, 업데이트가 불가한 경우최신버전으로 표시했습니다.이때 Cell의 delegate를 ViewController로 설정하여 탭 이벤트를 처리하도록 구현했습니다. 향후 AppStore 앱으로 이동시키도록 구현할 예정입니다.
4.
못먹는음식 수정하기화면을 띄울 때 realm 데이터 반영OnbarodingPage에서 표시한 못먹는 음식을
설정에서 수정할 수 있는 기능을 구현했습니다. 코드 재사용을 위해 기존의configureDislikedFoods메서드를 리팩토링하여 못먹는음식 정보를 표시할 때, 먼저 realm 데이터를 받아와서 반영하도록 했습니다.또한
RealmManager타입에 CRUD 메서드 일부를 추가하여 ViewModel에서 이를 호출하도록 했습니다.이외에도 UX를 고려하여 OnbarodingPage에서 못먹는음식 화면의 확인 버튼을 탭해야 앱의 최초실행 여부를 나타내는
isFirstLaunched가 false가 되도록 기능을 변경했습니다.5. '못먹는 음식 수정하기', '버전정보'를 제외한 다른 리스트에 대한 DetailView 구현
설정의 다른 리스트들의 경우 Text만 올라가면 됐기 때문에, 셀을 선택하면
TextView를 가지고 있는SettingDetailViewController를 띄워주도록 했습니다.사용자가 수정할 수 없도록
isEditable프로퍼티를false로 했으며,TextView가SettingDetailViewController의 View에 가득차도록 했습니다.테스트 방법
버전 정보확인의 경우 추후
ViewModel UnitTest를 통해 검증할 예정입니다.(이미 시뮬레이터를 통해 정상 동작하는 것은 확인했습니다.)
리뷰 노트
업데이트버튼을 탭하면, AppStore 앱으로 이동시켜 사용자가 앱을 업데이트할 수 있도록 구현할 예정입니다.친구에게 추천하기버튼을 탭하면, 앱 다운로드 링크를 복사하거나, SNS 공유 등을 통해 링크를 전달하는 기능을 구현할 예정입니다.스크린샷