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 | |
protocol ScrollToRefreshable: UIScrollViewDelegate { | |
var refreshableScrollView: UIScrollView { get } | |
var activityIndicatorView: UIActivityIndicatorView! { get } | |
func updateViewModel() | |
} | |
extension ScrollToRefreshable { |
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
extension String { | |
func removePrefix(_ prefixString: String) -> String { | |
guard self.hasPrefix(prefixString) else { | |
return self | |
} | |
let index = self.index(self.startIndex, offsetBy: prefixString.characters.count) | |
return self.substring(from: index) | |
} | |
} |
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 | |
protocol JSONUpdatable { | |
func update(with json: JSON) | |
} |
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 CoreData | |
/// Use `ContextGenerator.contextForDatabase(named:)` to generate an NSManagedObjectContext for interacting with CoreData | |
class ContextGenerator: NSObject { | |
class func contextForDatabase(named databaseName: String, inMemoryOnly: Bool = false) -> NSManagedObjectContext? { | |
return ContextGenerator.init(databaseName: databaseName, inMemoryOnly: inMemoryOnly)?.managedObjectContext | |
} | |
private let managedObjectContext: NSManagedObjectContext | |
private let managedObjectModel: NSManagedObjectModel |
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 | |
protocol TextFieldKeyboardPresentable: class, UITextFieldDelegate { | |
/// Collection of all fields in a form in the order in which they should be navigated | |
var textFields: [UITextField] { get } | |
/// Can be used to take action once a form is completely filled out | |
func lastTextFieldDidReturn() | |
/// Can be used to enable a button when text field(s) become valid | |
func checkValidation() |
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
enum DeviceScreenType { | |
case fourOrLess, five, six, sixPlus | |
} | |
struct DeviceHelper { | |
static var screenType: DeviceScreenType { | |
let maxScreenLength = max(UIScreen.main.bounds.size.width, UIScreen.main.bounds.size.height) | |
if maxScreenLength < 568.0 { | |
return .fourOrLess |
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 | |
struct StoryboardHelper { | |
/// Assumes that the storyboard identifier for the View Controller class provided matches its name and that it has been added to the `storyboardNameForViewController` switch statement. | |
static func new<T>() -> T? { | |
let nibName = String(describing: T.self) | |
let storyboardName = storyboardNameForViewController(named: nibName) | |
return getViewController(named: nibName, fromStoryboardNamed: storyboardName) as? T | |
} |
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 | |
/** | |
The adopting UIView is the File Ower of a nib by the same name. All IBOutlets are wired through the File Owner (not the content view itself) and the content view is also wired to the IBOutlet `view`. | |
NOTE - `loadFromNib:` must be called within a convenience initializer. | |
Keep in mind that any UIView instance method that you would normally use `self` should be called `view` instead. | |
*/ | |
protocol NibViewType: UIAppearance { |
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 | |
// MARK: - ImageLoader Protocol | |
public typealias ImageLoaderHandler = (UIImage?, Error?) -> Void | |
public protocol ImageLoader { | |
func updateImage(fromURLString urlString: String?, placeholderImage: UIImage?, completionHandler: @escaping ImageLoaderHandler) | |
func imageFromCache(_ urlString: String?) -> UIImage? | |
} |
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 UIAlertAction { | |
convenience init(title: String, handler: ((UIAlertAction?) -> Void)? = nil) { | |
self.init(title: title, style: .default, handler: handler) | |
} | |
} | |
/// - Tag: AlertHelper | |
struct AlertHelper { |