포스트

Final (15)

코드 리팩토링

기존에 있던 걸 viewmodel로 넘겨서 좀더 단순하게 바꾼다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
func checkUserisBlock(uid: String, completion: @escaping (Bool) -> Void) {
        signManager.fetchUserData(uid: uid) { error, dataSnapshot in
            if let dataSnapshot = dataSnapshot {
                if let userData = dataSnapshot.value as? [String: Any] {
                    let isBlockInt = userData[db_isBlock] as? Int ?? 0
                    let isBlock = isBlockInt != 0
                    if isBlock {
                        completion(isBlock)
                    } else {
                        completion(isBlock)
                    }
                }
            }
        }
    }

이렇게 바꿔준다.

이렇게하면 completion handler의 결과인 true / false에 따라서 처리만 해주면 된다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
func configureInitialViewController() {
        let auth = Auth.auth().currentUser
        if auth != nil {
            signViewModel.checkUserisBlock(uid: auth!.uid) { [weak self] isBlock in
                if isBlock {
                    self?.switchToGreetingViewController()
                    self?.greetingVC.showMessage(title: "차단 알림", message: "현재 계정은 차단되었습니다.\n관리자에게 문의하세요")
                } else {
                    self?.switchToMainTabBarController()
                }
            }
        } else {
            switchToGreetingViewController()
        }
    }

수정 완료.

ReportVC 디자인

코드는 생략..

오늘은 두통이 좀 심해서 여기까지…

이 기사는 저작권자의 CC BY 4.0 라이센스를 따릅니다.