Skip to content

Instantly share code, notes, and snippets.

@mehdok
Created December 8, 2018 08:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mehdok/aa357ee00af3a157f21fbb8f4e9e655e to your computer and use it in GitHub Desktop.
Save mehdok/aa357ee00af3a157f21fbb8f4e9e655e to your computer and use it in GitHub Desktop.
import RKCommon
import RxSwift
import UIKit
enum SocialSigninCoordinationResult {
case successGoogle(Bool)
case successFacebook
case error(Error)
case cancel
}
class SocialSigninCR: BaseCoordinator<SocialSigninCoordinationResult> {
let navigationController: UINavigationController
let authenticator: FireAuthenticatorProtocol
public init(navigationController: UINavigationController,
authenticator: FireAuthenticatorProtocol) {
self.navigationController = navigationController
self.authenticator = authenticator
}
override func start() -> Observable<SocialSigninCoordinationResult> {
let viewController = SocialSigninVC.initFromStoryboard(name: "SocialSigninSB")
viewController.modalPresentationStyle = .overCurrentContext
let viewModel = SocialSigninVM(authenticator: authenticator)
viewController.viewModel = viewModel
let successGoogle = viewModel.didLogedInGoogle.map { SocialSigninCoordinationResult.successGoogle($0) }
let successFacebook = viewModel.didLogedInFacebook.map { _ in SocialSigninCoordinationResult.successFacebook }
let cancel = viewModel.didCancel.map { _ in SocialSigninCoordinationResult.cancel }
navigationController.navigationBar.isHidden = true
navigationController.present(viewController, animated: true, completion: nil)
return Observable.merge(successGoogle, successFacebook, cancel)
.take(1)
.do(onNext: { _ in
viewController.dismiss(animated: true)
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment