Build Instagram App: Part 2 (Swift 5) - 2022 - Xcode 11 - iOS Development
private func bind() {
let output = viewModel.transform(input: input.eraseToAnyPublisher())
output
.receive(on: DispatchQueue.main)
.sink { [weak self] result in
switch result {
case .loginOutput(result: let result):
if !result {
self?.handleNotLogined()
}
}
}
.store(in: &cancellables)
}
func transform(input: AnyPublisher<Input, Never>) -> AnyPublisher<Output, Never> {
input
.receive(on: DispatchQueue.global(qos: .default))
.sink { [weak self] result in
switch result {
case .isAlreadyLogin: self?.isAlreadyLogin()
}
}
.store(in: &cancellables)
return output.eraseToAnyPublisher()
}
class AuthManager {
private let auth = FirebaseAuth.Auth.auth()
func isSignedIn() -> Bool {
return auth.currentUser != nil
}
}
private func handleNotLogined() {
let loginVC = LoginViewController()
loginVC.modalPresentationStyle = .fullScreen
present(loginVC, animated: true)
}
강의에서는 프로그레스 뷰(로딩 뷰)를 서드 파티를 통해 구현하고 있는데, UIActivityIndicatorView를 사용하도록 하겠다.