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 AVFoundation | |
import MobileCoreServices | |
import Photos | |
import UIKit | |
enum CaptureError: Error { | |
case cameraUnavailable | |
case cameraDenied | |
case libraryUnavailable | |
} |
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 | |
class TextFieldsKeyboardHandler: NSObject, UITextFieldDelegate { | |
private weak var delegate: TextFieldsKeyboardHandlerDelegate! | |
/// Used to resolve issues with old devices having offset y origins where nav bars are present | |
private var restingYOrigin: CGFloat = 0 | |
/// Replace for a different handling of the keyboard offset | |
lazy var updateKeyboardFrame: (CGRect) -> Void = updateViewOffset | |
init(delegate: TextFieldsKeyboardHandlerDelegate, shouldAddDismissGesture: Bool = true) { |
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 XCTestCase { | |
var app: XCUIApplication { return XCUIApplication() } | |
func checkExistenceOfElements(_ typesAndTexts: [(XCUIElement.ElementType, String)], timeout: TimeInterval = 3) { | |
for (type, text) in typesAndTexts { | |
checkExistenceOfElement(type, text, timeout: timeout) | |
} | |
} | |
func checkExistenceOfElement(_ type: XCUIElement.ElementType, _ text: String, timeout: TimeInterval = 3) { |
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 | |
class TimestampPickerView: UIPickerView { | |
private(set) var date: Date = Date() | |
var minimumDate: Date? | |
var maximumDate: Date? | |
var isMilitaryTime: Bool { | |
get { | |
return timestampDatasource?.isMilitaryTime ?? 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
import UIKit | |
class PostFixTextField: UITextField { | |
@IBInspectable var postfixColor: UIColor? | |
@IBInspectable var shouldRemovePostfixOnEditing: Bool = false | |
@IBInspectable var postfixText: String = "" { | |
willSet { | |
removePostFix() | |
} | |
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 UIKit | |
/** | |
A convenient way to filter your table with a search bar. | |
Example use: | |
extension MyTableViewController: SearchTableType { | |
func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) { |
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 | |
/// Used to mark text for localization. Keys include the class using the text and the first 10 characters of the default text. | |
protocol Localizable {} | |
extension Localizable { | |
static func localize(_ text: String) -> String { | |
let caller = String(describing: Self.self) | |
let prefixIndex = text.index(text.startIndex, offsetBy: min(15, text.count)) |
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
class Stopwatch { | |
static let shared = Stopwatch() | |
let name: String | |
var shouldLogInRealTime: Bool = false | |
private var start: Date? { | |
willSet { | |
lap = newValue | |
} |
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 | |
/// Have a UIViewController adopt this to easily block interactions while loading. | |
protocol LoadingOverlayDisplayable: class { | |
var loadingOverlayView: LoadingOverlayView? { get set } | |
} | |
extension LoadingOverlayDisplayable where Self: UIViewController { | |
/// Call in `viewDidLoad` to establish the loading overlay view |