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
class ViewController: UIViewController | |
{ | |
@IBOutlet weak var avatarView: UIImageView! | |
var api: API! | |
var imagePickerDelegate: ImagePickerDelegate! | |
@IBAction func changeAvatar(_ sender: UITapGestureRecognizer) { | |
guard let senderView = sender.view else { fatalError("Tapped on viewless gesture recognizer?") } | |
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 UIViewController | |
{ | |
func getImage(focusView: UIView) -> Promise<UIImage> { | |
var delegate: ImagePickerDelegate! = ImagePickerDelegate() | |
let controller = UIImagePickerController() | |
controller.delegate = delegate | |
let result = choiceIndexUsingActionSheet(title: "", message: "", choices: sourceOptions.map { $0.title }, onSourceView: focusView).then { (index) -> Promise<UIImage> in | |
sourceOptions[index].action(controller) | |
self.present(controller, animated: true, completion: nil) | |
return delegate.promise |
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
class ViewController: UIViewController | |
{ | |
@IBOutlet weak var avatarView: UIImageView! | |
var api: API! | |
@IBAction func changeAvatar(_ sender: UITapGestureRecognizer) { | |
guard let senderView = sender.view else { fatalError("Tapped on viewless gesture recognizer?") } | |
getImage(focusView: senderView).then { image -> Promise<UIImage> in |
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
// | |
// Regex.swift | |
// | |
// Created by Daniel Tartaglia on 2/6/16. | |
// Copyright © 2016 Daniel Tartaglia. MIT License. | |
// | |
import Foundation | |
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
// | |
// DelayScheduler.swift | |
// | |
// Created by Daniel Tartaglia on 4/20/17. | |
// Copyright © 2017 Daniel Tartaglia. MIT License. | |
// | |
final class DelayScheduler: ImmediateSchedulerType { | |
init(delay: TimeInterval, queue: DispatchQueue = .main) { |
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
// | |
// DictionaryExtensions.swift | |
// | |
// Created by Daniel Tartaglia on 6/18/16. | |
// Copyright © 2016 Daniel Tartaglia. MIT License. | |
// | |
extension Dictionary { |
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
// | |
// UITextField+Extensions.swift | |
// | |
// Created by Daniel Tartaglia on 8/8/16. | |
// Copyright © 2016 MIT License. | |
// | |
import UIKit | |
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
enum UserInteractionError: Error { | |
case userCanceled | |
} | |
extension UIViewController | |
{ | |
func choiceIndexUsingActionSheet(title: String, message: String, choices: [String], onSourceView view: UIView) -> Promise<Int> { | |
return Promise(queue: DispatchQueue.main) { fulfill, reject in | |
let alert = UIAlertController(title: title.isEmpty ? nil : title, message: message.isEmpty ? nil : message, preferredStyle: .actionSheet) |
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
// | |
// Redux.swift | |
// | |
// Created by Daniel Tartaglia on 01/16/15. | |
// Copyright © 2017. MIT License. | |
// | |
public final class Store<State, Action> { |
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
// | |
// Created by Daniel Tartaglia on 4/20/17. | |
// Copyright © 2017 Daniel Tartaglia. MIT License. | |
import UIKit | |
import RxSwift | |
import RxCocoa | |
class ViewController: UIViewController { |