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 Swinject | |
struct NamedRegistration<Service> { | |
let service: Service.Type | |
let name: String | |
} | |
extension NamedRegistration { | |
static func named<Service>(_ name: String) -> NamedRegistration<Service> { | |
return NamedRegistration<Service>(service: Service.self, name: name) |
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
protocol Creating { | |
associatedtype Arguments | |
associatedtype Service | |
func create(_ arguments: Arguments) -> Service | |
} | |
extension Creating where Arguments == Void { | |
func create() -> Service { | |
return create(()) | |
} |
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 GradientView: UIView { | |
init(style: GradientStyle) { | |
super.init(frame: .zero) | |
isUserInteractionEnabled = false | |
gradientLayer.colors = style.colors.map { $0.color.cgColor } | |
gradientLayer.locations = style.colors.map { NSNumber(value: $0.location) } | |
gradientLayer.startPoint = style.direction.startPoint |
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 | |
extension UIScrollView { | |
var viewport: CGRect { | |
return CGRect( | |
origin: CGPoint( | |
x: contentOffset.x + adjustedContentInset.left, | |
y: contentOffset.y + adjustedContentInset.top | |
), | |
size: CGSize( |
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 | |
struct SketchShadow { | |
let color: UIColor? | |
let x: CGFloat | |
let y: CGFloat | |
let blur: CGFloat | |
let spread: CGFloat | |
} |
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 | |
struct ScrollPageController { | |
func pageOffset(for offset: CGFloat, velocity: CGFloat, in pageOffsets: [CGFloat]) -> CGFloat? { | |
let pages = pageOffsets.enumerated().reduce([Int: CGFloat]()) { | |
var dict = $0 | |
dict[$1.0] = $1.1 | |
return dict | |
} |
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
// swiftlint:disable identifier_name | |
// MARK: - ForwardApplication | |
precedencegroup ForwardApplication { | |
associativity: left | |
higherThan: AssignmentPrecedence | |
} | |
infix operator |>: ForwardApplication |
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 RxCocoa | |
extension Driver { | |
func unwrap<T>() -> Driver<T> where E == T? { | |
// swiftlint:disable:next force_unwrapping | |
return filter { $0 != nil }.map { $0! }.asDriver(onErrorDriveWith: .empty()) | |
} | |
} |
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 Quick | |
import Nimble | |
class CodableDecimalSpec: QuickSpec { | |
override func spec() { | |
context("encode Model to JSON") { | |
var model: Model! | |
var json: [String: String]? | |
beforeEach { |
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
opt_in_rules: | |
- file_name | |
- empty_count | |
- sorted_imports | |
- force_unwrapping | |
- operator_usage_whitespace | |
- number_separator | |
- switch_case_on_newline | |
- implicit_return | |
- overridden_super_call |