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
protocol Accessible { | |
func generateAccessibilityIdentifiers() | |
} | |
extension Accessible { | |
func generateAccessibilityIdentifiers() { | |
#if DEBUG | |
let mirror = Mirror(reflecting: 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 Realm | |
import RealmSwift | |
class RealmManager { | |
static let shared = RealmManager() | |
private func getRealm() -> Realm { | |
if let _ = NSClassFromString("XCTest") { | |
return try! Realm(configuration: Realm.Configuration(fileURL: nil, inMemoryIdentifier: "test", encryptionKey: nil, readOnly: false, schemaVersion: 0, migrationBlock: nil, objectTypes: nil)) | |
} 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 | |
public protocol HasCustomView { | |
associatedtype CustomView: UIView | |
} | |
extension HasCustomView where Self: UIViewController { | |
/// The UIViewController's custom view. | |
public var customView: CustomView { | |
guard let customView = view as? CustomView 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
extension UITextView { | |
func hyperLink(originalText: String, | |
hyperLink: String, | |
urlString: String, | |
withFont font: UIFont = UIFont.systemFont(ofSize: 16.0), | |
textColor: UIColor = .black, | |
linkColor: UIColor = .blue) { | |
isEditable = false | |
let style = NSMutableParagraphStyle() |
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 ActivityPresentable { | |
func presentActivity(_ style: UIActivityIndicatorView.Style, | |
withTintColor tintColor: UIColor?, | |
blockSuperView isBlockView: Bool) | |
func dismissActivity() | |
} | |
extension ActivityPresentable where Self: UIViewController { |
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 XCTest | |
import UIKit | |
class TopLevelUIUtilities<T: UIViewController> { | |
private var rootWindow: UIWindow! | |
func setupTopLevelUI(withViewController viewController: T, withNavigationController navController: Bool = false) -> T { | |
rootWindow = UIWindow(frame: UIScreen.main.bounds) | |
rootWindow.isHidden = 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 | |
extension UIStackView { | |
func addSeparator(color: UIColor, withThickness thickness: CGFloat = 1.0 ) { | |
var index = self.arrangedSubviews.count | |
while index > 1 { | |
let separator = createSeparator(color: color, withThickness: thickness) | |
insertArrangedSubview(separator, at: index - 1) // (index-1) for centers only | |
if self.axis == .horizontal { | |
separator.heightAnchor.constraint(equalTo: self.heightAnchor, multiplier: 1).isActive = 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 os.log | |
/// Wrapper class for os_log function | |
public class Logger: NSObject { | |
/// Returns the default singleton instance. | |
static let shared = Logger() | |
/// Application layer description | |
/// |
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 | |
class Observable<T> { | |
typealias Listener = (T) -> () | |
private var listener: Listener? | |
private var queue: DispatchQueue = DispatchQueue.main | |
var value: T { | |
didSet { | |
fire() |
NewerOlder