This file contains 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
final class ThreadSafe<T> { | |
private var _value: T | |
private let queue = DispatchQueue(label: ThreadSafe.description()) | |
init(_ value: T) { | |
self._value = value | |
} | |
var value: T { | |
return queue.sync { _value } | |
} |
This file contains 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
let gifsProvider: AnyObjectsProvider<GIF> = objectsManager.makeGIFsProvider() | |
protocol ObjectsManager { | |
var defaultGIFPredicate: NSPredicate { get } | |
func makeGIFsProvider() -> AnyObjectsProvider<GIF> | |
func save(gifs: [GIF]) -> Completable | |
func hide(gif: GIF) | |
This file contains 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 | |
typealias Constraint = (_ child: UIView, _ other: UIView) -> NSLayoutConstraint | |
func equal<Axis, Anchor>(_ keyPath: KeyPath<UIView, Anchor>, constant: CGFloat = 0, priority: UILayoutPriority = .required) -> [Constraint] where Anchor: NSLayoutAnchor<Axis> { | |
return equal(keyPath, keyPath, constant: constant, priority: priority) | |
} | |
func equal<Axis, Anchor>(_ keyPath: KeyPath<UIView, Anchor>, _ toAnchor: KeyPath<UIView, Anchor>, constant: CGFloat = 0, priority: UILayoutPriority = .required) -> [Constraint] where Anchor: NSLayoutAnchor<Axis> { | |
return [{ view, other in |
This file contains 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 FeedView: UIView { | |
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: GiftainerLayout()) | |
let tooltipView = TooltipView() | |
init() { | |
super.init(frame: .zero) | |
addSubviews() | |
} |
This file contains 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 FeedViewController { | |
private let referencesBag = ReferencesBag() | |
private var tokens: [Token] = [] | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
setupApplicationNotifications() | |
} | |
} |
This file contains 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 ReferencesBag { | |
private var references: [AnyObject] = [] | |
func append(_ reference: AnyObject) { | |
references.append(reference) | |
} | |
} | |
// For details about Token class please visit this address : |
This file contains 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 SizeClassView: UIView { | |
private var regularHeightConstraints = [NSLayoutConstraint]() | |
private var compactHeigthConstraints = [NSLayoutConstraint]() | |
func addRegularHeightConstraint(regularHeightConstraint: NSLayoutConstraint) { | |
regularHeightConstraints.append(regularHeightConstraint) | |
addConstraint(regularHeightConstraint) |