This file contains hidden or 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
import Foundation | |
#if DEBUG | |
/// Use this to print out helpful information on network requests when debugging. | |
/// The functions return strings so I can decide whether to use print statemens or custom breakpoints to log them. | |
public enum NetworkLogger { | |
static func cURLLog(request: URLRequest) -> String { | |
"\n🌎 \(request.cURL)\n" |
This file contains hidden or 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
import Foundation | |
import RxCocoa | |
import RxSwift | |
/// To persist updates through either the `wrappedValue` or `relay` while keeping the implementing property a value type. | |
private var cache = NSCache<AnyObject, AnyObject>() | |
@propertyWrapper | |
struct Bindable<Element> { | |
var projectedValue: Bindable { self } |
This file contains hidden or 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
import Foundation | |
extension NSAttributedString { | |
struct FontTypes: OptionSet { | |
static let `default` = FontTypes(rawValue: 1 << 0) | |
static let bold = FontTypes(rawValue: 1 << 1) | |
static let italic = FontTypes(rawValue: 1 << 2) | |
static let underlined = FontTypes(rawValue: 1 << 3) | |
let rawValue: Int8 |
This file contains hidden or 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
#!/usr/bin/env bash | |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | |
echo "Running from" $DIR | |
ln -s $DIR/pre-commit $DIR/../.git/hooks/pre-commit |
This file contains hidden or 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
import UIKit | |
public protocol PageContainerDelegate: class { | |
func switchedPage(to index: Int, isLastPage: Bool) | |
} | |
open class PagedContentViewController: UIPageViewController { | |
public weak var containerDelegeate: PageContainerDelegate? | |
open var orderedViewControllers: [UIViewController] = [] { | |
didSet { |
This file contains hidden or 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
import Foundation | |
public typealias JSON = [String: Any] | |
/// A Codable object with added JSON conversion abilities | |
public protocol JSONCodable: Codable, JSONAttributable { | |
// Replace declaration in adoptor's extension to change expected date format | |
static var dateFormatter: DateFormatter { get } | |
} |
This file contains hidden or 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
import Foundation | |
/// Manages all the link handlers and routes a url to the appropriate one. | |
public class LinkRouter: NSObject { | |
private(set) static var shared: LinkRouter = LinkRouter() | |
public var appScheme: String? | |
private var handlers: [LinkHandlerType] = [] | |
public init(appScheme: String? = nil) { |
This file contains hidden or 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
import UIKit | |
extension UIView { | |
func addShadow() { | |
layer.shadowColor = UIColor.black.cgColor | |
layer.shadowOpacity = 0.15 | |
layer.shadowOffset = CGSize(width: 0, height: 3.0) | |
layer.shadowRadius = 4 | |
layer.masksToBounds = false | |
} |
This file contains hidden or 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
override func viewDidLayoutSubviews() { | |
super.viewDidLayoutSubviews() | |
sizeTableViewHeaderToFit() | |
} | |
// MARK: - Dynamic Header Height | |
func sizeTableViewHeaderToFit() { | |
guard let headerView = tableView.tableHeaderView else { |
This file contains hidden or 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
import UIKit | |
extension UIImageView { | |
func setAnimationImagesWithGif(named name: String, animationDuration: TimeInterval? = nil) { | |
guard let bundleURL = Bundle.main.url(forResource: name, withExtension: "gif"), | |
let imageData = try? Data(contentsOf: bundleURL), | |
let source = CGImageSourceCreateWithData(imageData as CFData, nil) else { | |
return | |
} | |
let frameCount = CGImageSourceGetCount(source) |
NewerOlder