WWDC:
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
| let name = "Navigation title" | |
| fileprivate extension String { | |
| var toBarButtonItem: UIBarButtonItem { | |
| let titleLabel = UILabel() | |
| titleLabel.font = UIFont.systemFont(ofSize: 24) | |
| titleLabel.text = self | |
| return UIBarButtonItem(customView: titleLabel) | |
| } | |
| } |
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
| struct Content { | |
| let title: String | |
| let description: String | |
| } | |
| fileprivate extension Array where Element == Content { | |
| func filter(text: String) -> [Content] { | |
| let trimmedText = text.trimmingCharacters(in: .whitespacesAndNewlines) | |
| return filter { | |
| $0.title.range(of: trimmedText, options: .caseInsensitive) != nil |
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 UIView { | |
| convenience init(cornerRadius: CGFloat) { | |
| self.init(frame: .zero) | |
| layer.cornerRadius = cornerRadius | |
| clipsToBounds = true | |
| } | |
| } | |
| final class ShimmerCell: UITableViewCell { |
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
| {% for type in types.structs %} | |
| {% if type|annotated:"AutoInitiable" or type.implements.AutoInitiable %} | |
| {% set spacing %}{% if type.parentName %} {% endif %}{% endset %} | |
| {% map type.storedVariables into parameters using var %}{% if not var|annotated:"skipAutoInitiable" %}{{ var.name }}: {{ var.typeName }}{% else %}{% endif %}{% endmap %} | |
| // sourcery:inline:auto:{{ type.name }}.AutoInitiable | |
| {% if type.accessLevel != "internal" %}{{ type.accessLevel }} {% endif %}init( | |
| {% for variable in parameters where variable != "" %} | |
| {{ variable|replace:"_","" }}{% if not forloop.last %},{% endif %} | |
| {% endfor %} | |
| ) { |
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
| // То что видно на ПР | |
| final class Foo { | |
| var observations: [ObjectIdentifier : (OurObject) -> Void] | |
| } | |
| // MARK: - SourceObservable | |
| extension Foo: SourceObservable { } | |
| // MARK: - SourceObservationHoldable | |
| extension Foo: SourceObservationHoldable { } |
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 TemplateImageAddable { | |
| func set(image: UIImage?) | |
| } | |
| extension TemplateImageAddable where Self: UIImageView { | |
| func set(image: UIImage?) { | |
| self.image = image?.withRenderingMode(.alwaysTemplate) | |
| } | |
| } |
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 BaseLabel: UILabel { | |
| var style: ColorStyle = .primary { | |
| didSet { | |
| textColor = style.color | |
| } | |
| } | |
| init(style: ColorStyle, numberOfLines: Int = 1) { | |
| super.init(frame: .zero) |
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
| precedencegroup ChainOperatorPrecedence { | |
| associativity: left | |
| } | |
| infix operator >>>: ChainOperatorPrecedence | |
| @discardableResult | |
| public func >>> (left: Operation, right: Operation) -> Operation { | |
| right.addDependency(left) | |
| return right |
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
| public final class BackgroundOperationQueue: OperationQueue { | |
| private let _blocking: Bool | |
| public init(blocking: Bool = false) { | |
| _blocking = blocking | |
| super.init() | |
| _setup() | |
| } | |
| public func addOperations(_ operations: [Operation]) { |
NewerOlder