This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol AssetLoadable { | |
var rawValue: String { get } | |
func imageNamed() -> String | |
} | |
extension AssetLoadable { | |
func imageNamed() -> String { | |
return rawValue | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UITableView { | |
func animatedInsert(indexPaths paths: [NSIndexPath], withRowAnimation animation: UITableViewRowAnimation = .Automatic) { | |
guard paths.isEmpty == false else { return } | |
beginUpdates() | |
insertRowsAtIndexPaths(paths, withRowAnimation: animation) | |
endUpdates() | |
} | |
func animatedlReload(indexPaths paths: [NSIndexPath], withRowAnimation animation: UITableViewRowAnimation = .Automatic) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Compile with clang -framework Foundation sethack.m | |
#import <Foundation/Foundation.h> | |
#import <objc/runtime.h> | |
/* | |
CFHashBytes from http://www.opensource.apple.com/source/CF/CF-1153.18/CFUtilities.c | |
*/ | |
#define ELF_STEP(B) T1 = (H << 4) + B; T2 = T1 & 0xF0000000; if (T2) T1 ^= (T2 >> 24); T1 &= (~T2); H = T1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
if 🍌🍌 { | |
router.openControllerA() | |
} else if 🍌🍌🍌 { | |
router.openControllerB() | |
} else if 🍐 { | |
router.openControllerC() | |
} else if 🍐🍐 { | |
router.openControllerD() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func prepare(for segue: UIStoryboardSegue, sender: Any?) { | |
if segue.identifier == "openControllerA" { | |
let vc = segue.destinationViewController as! ControllerA | |
vc.monkey = 🐒 | |
} else if segue.identifier == "openControllerB" { | |
let vc = segue.destinationViewController as! ControllerB | |
vc.tiger = 🐯 | |
} else if segue.identifier == "openControllerC" { | |
let vc = segue.destinationViewController as! ControllerC | |
vc.frog = 🐸 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol Coordinator: class { | |
func start() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol CoordinatorOutput { | |
var finishFlow: (Item -> Void)? { get set } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class ItemCoordinator { | |
private let factory: ItemModuleFactory | |
private let coordinatorFactory: CoordinatorFactory | |
private let router: Router | |
init(router: Router, | |
factory: ItemModuleFactory, | |
coordinatorFactory: CoordinatorFactory) { | |
self.router = router | |
self.factory = factory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func showItemList() { | |
let itemsView = factory.makeItemsView() | |
itemsView.onItemSelect = { [weak self] (item) in | |
self?.showItemDetail(item) | |
} | |
itemsView.onCreateButtonTap = { [weak self] in | |
self?.runCreationCoordinator() | |
} | |
router.setRootModule(itemsView) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func runCreationFlow() { | |
let (coordinator, module) = coordinatorFactory.makeItemCoordinatorBox() | |
coordinator.finishFlow = { [weak self, weak coordinator] item in | |
self?.router.dismissModule() | |
self?.removeDependency(coordinator) | |
self?.showItemDetail(item) | |
} | |
addDependency(coordinator) | |
router.present(module) | |
coordinator.start() |
OlderNewer