Skip to content

Instantly share code, notes, and snippets.

View AndreyPanov's full-sized avatar
🤚

Andrei Panov AndreyPanov

🤚
View GitHub Profile
@AndreyPanov
AndreyPanov / BaseCoordinator.swift
Created January 12, 2017 16:11
BaseCoordinator
class BaseCoordinator {
var childCoordinators: [Coordinator] = []
// add only unique object
func addDependency(_ coordinator: Coordinator) {
for element in childCoordinators {
if element === coordinator { return }
}
childCoordinators.append(coordinator)
}
func push(_ module: Presentable?)
@AndreyPanov
AndreyPanov / Presentable.swift
Created January 12, 2017 16:12
Presentable
protocol Presentable {
func toPresent() -> UIViewController?
}
@AndreyPanov
AndreyPanov / MakeItemDetailOutput.swift
Created January 12, 2017 16:13
makeItemDetailOutput
func makeItemDetailOutput(item: Item) -> ItemDetailView {
let controller = ItemDetailController.controllerFromStoryboard(.items)
controller.item = item
return controller
}
@AndreyPanov
AndreyPanov / ItemModuleFactory.swift
Created January 12, 2017 16:14
ItemModuleFactory
protocol ItemModuleFactory {
func makeItemsOutput() -> ItemsListView
func makeItemDetailOutput(item: ItemList) -> ItemDetailView
}
@AndreyPanov
AndreyPanov / ModuleFactoryImp.swift
Created January 12, 2017 16:14
ModuleFactoryImp
class ModuleFactoryImp:
AuthModuleFactory,
ItemModuleFactory,
ItemCreateModuleFactory,
SettingsModuleFactory {
/* implementation */
}
moduleA.onNext = { [weak self] dict in
self?.storage.dict = dict
self?.showModuleB()
}
@AndreyPanov
AndreyPanov / Reflection.swift
Last active March 17, 2017 17:15
Reflection Generic Properties
import UIKit
protocol Reflectable {
func properties<T>() -> [T]
}
extension Reflectable {
func properties<T>() -> [T] {
var s = [T]()
Mirror(reflecting: self).children.forEach { property in
@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,
fileprivate enum LaunchInstructor {
case main, auth, onboarding
static func configure(tutorialWasShown: Bool, isAutorized: Bool) -> LaunchInstructor {
switch (tutorialWasShown, isAutorized) {
case (true, false), (false, false): return .auth
case (false, true): return .onboarding
case (true, true): return .main
}
}