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 Observer: AnyObject { | |
| func onNext(_ event: Notifier.Event) | |
| } | |
| class Notifier { | |
| typealias Event = String | |
| class WeakContainer { | |
| private(set) weak var value: Observer? | |
| init(_ value: Observer?) { |
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 RealmSwift | |
| class RealmService { | |
| static let version: UInt64 = 1 | |
| static func configure() { | |
| Realm.Configuration.defaultConfiguration = Realm.Configuration(schemaVersion: version, migrationBlock: migrate) | |
| } | |
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 UInt { | |
| static var base: UInt { | |
| return 0 | |
| } | |
| nonmutating func apply(bits: UInt, to range: ClosedRange<Int>) -> UInt { | |
| let cleanedSelf = self & (~(mask(range))) | |
| let clampedValue = bits & (mask(0...range.count)) | |
| return cleanedSelf | (clampedValue << range.lowerBound) | |
| } |
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 RealmSwift | |
| class RealmObjectAdapter<T: Object> { | |
| func objects() -> Results<T>? { | |
| return try? Realm().objects(T.self) | |
| } | |
| @discardableResult func create(_ value: [String: Any]? = nil) throws -> T { | |
| let object = 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 Foundation | |
| import UIKit | |
| struct PickerIndexPath { | |
| var component: Int | |
| var row: Int | |
| } | |
| class PickerViewHandler: NSObject { | |
| let picker: UIPickerView |
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 CoreLocation | |
| typealias LocationCompletion = (_ coordinate: CLLocationCoordinate2D?)->() | |
| class LocationService: NSObject { | |
| static var expirationTime = TimeInterval(60 * 60 * 1) | |
| static let shared = LocationService() | |
| fileprivate let manager = CLLocationManager() |
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 TextFieldHandler: NSObject, UITextFieldDelegate { | |
| var maxLength: Int? | |
| var prefix: String? | |
| private var textField: UITextField | |
| init(with textField: UITextField) { |
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 KeyboardHandler { | |
| let scrollView: UIScrollView | |
| let responders: [UIView] | |
| var bottomContentMargin: CGFloat? | |
| init(with scrollView: UIScrollView, responders: [UIView]) { |
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 UIKit | |
| protocol ConfigurableCell { | |
| func configure(with data: Any) | |
| } | |
| enum TableHandlerError: Error { | |
| case noData | |
| case invalidSection(Int) |