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 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 | |
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
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 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
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 | |
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) |
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 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
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) { |