Skip to content

Instantly share code, notes, and snippets.

View AndreyPanov's full-sized avatar
🤚

Andrei Panov AndreyPanov

🤚
View GitHub Profile
override func start(with option: DeepLinkOption?) {
//start with deepLink
if let option = option {
switch option {
case .onboarding: runOnboardingFlow()
case .signUp: runAuthFlow()
default: childCoordinators.forEach { coordinator in
coordinator.start(with: option)
}
}
private func runAuthFlow() {
let coordinator = coordinatorFactory.makeAuthCoordinatorBox(router: router)
coordinator.finishFlow = { [weak self, weak coordinator] in
isAutorized = true
self?.start() //here we'll check instruction
self?.removeDependency(coordinator)
}
addDependency(coordinator)
coordinator.start()
}
struct DeepLinkURLConstants {
static let Onboarding = "onboarding"
static let Items = "items"
static let Item = "item"
static let Settings = "settings"
}
enum DeepLinkOption {
case onboarding
case items
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let notification = launchOptions?[.remoteNotification] as? [String: AnyObject]
let deepLink = DeepLinkOption.build(with: notification)
applicationCoordinator.start(with: deepLink)
return true
}
func application(_ application: UIApplication,
didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
protocol Coordinator: class {
func start()
func start(with option: DeepLinkOption?)
}
override func start() {
switch instructor {
case .onboarding: runOnboardingFlow()
case .auth: runAuthFlow()
case .main: runMainFlow()
}
}
static func build(with userActivity: NSUserActivity) -> DeepLinkOption?
static func build(with url: URL) -> DeepLinkOption?
static func build(with dict: [String : AnyObject]?) -> DeepLinkOption?
override func start(with option: DeepLinkOption?) {
//start with deepLink
if let option = option {
switch option {
case .onboarding: runOnboardingFlow()
case .signUp: runAuthFlow()
default: childCoordinators.forEach { coordinator in
coordinator.start(with: option)
}
}
class MainViewController: UIViewController, Styleable {
@IBOutlet weak var firstHeaderLabel: UILabel!
@IBOutlet weak var secondBodyLabel: UILabel!
@IBOutlet weak var loginTextField: UITextField!
@IBOutlet weak var secondLoginTextField: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
applyStyle()
protocol Styleable {
func applyStyle()
}