Skip to content

Instantly share code, notes, and snippets.

View AndreyPanov's full-sized avatar
🤚

Andrei Panov AndreyPanov

🤚
View GitHub Profile
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"
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)
protocol Styleable {
func applyStyle()
}
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()
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)
}
}
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() {
switch instructor {
case .onboarding: runOnboardingFlow()
case .auth: runAuthFlow()
case .main: runMainFlow()
}
}
protocol Coordinator: class {
func start()
func start(with option: 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]) {
struct DeepLinkURLConstants {
static let Onboarding = "onboarding"
static let Items = "items"
static let Item = "item"
static let Settings = "settings"
}
enum DeepLinkOption {
case onboarding
case items