Skip to content

Instantly share code, notes, and snippets.

View AndreyPanov's full-sized avatar
🤚

Andrei Panov AndreyPanov

🤚
View GitHub Profile
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var rootController: UINavigationController {
return self.window!.rootViewController as! UINavigationController
}
private lazy var applicationCoordinator: Coordinator = self.makeCoordinator()
func application(_ application: UIApplication,
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?
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]) {
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()
}
var headerLabel: (UILabel) -> () = { control in
control.font = .systemFont(ofSize: 20)
control.textColor = .red
}
var bodyLabel: (UILabel) -> () = { control in
control.font = .systemFont(ofSize: 15)
control.textColor = .darkGray
}
var loginTextField: (UITextField) -> () = { control in
control.font = .systemFont(ofSize: 15)
enum Guide {
case headerLabel((UILabel) -> ())
case bodyLabel((UILabel) -> ())
case loginTextField((UITextField) -> ())
func identifier() -> String {
switch self {
case .headerLabel: return "header"
case .bodyLabel: return "body"
case .loginTextField: return "login"
func guide() -> [Guide] {
return [
.headerLabel(headerLabel),
.bodyLabel(bodyLabel),
.loginTextField(loginTextField)
]
}