fix: conform TemplateDrawingOperation to OrientationAwareDrawingOperation
This commit is contained in:
parent
7c8a29a7f9
commit
65ae079e62
|
|
@ -22,15 +22,22 @@
|
|||
|
||||
import CoreGraphics
|
||||
|
||||
public struct TemplateDrawingOperation: DrawingOperation {
|
||||
private let image: CGImage
|
||||
private let imageSize: CGSize
|
||||
private let color: CGColor
|
||||
public struct TemplateDrawingOperation: OrientationAwareDrawingOperation {
|
||||
|
||||
public var image: CGImage
|
||||
public var imageSize: CGSize
|
||||
public var color: CGColor
|
||||
public var flipHorizontallyDuringDrawing: Bool
|
||||
|
||||
public init(image: CGImage,
|
||||
imageSize: CGSize,
|
||||
color: CGColor,
|
||||
flipHorizontallyDuringDrawing: Bool = true) {
|
||||
|
||||
public init(image: CGImage, imageSize: CGSize, color: CGColor) {
|
||||
self.image = image
|
||||
self.imageSize = imageSize
|
||||
self.color = color
|
||||
self.flipHorizontallyDuringDrawing = flipHorizontallyDuringDrawing
|
||||
}
|
||||
|
||||
public func affectedArea(in context: CGContext?) -> CGRect {
|
||||
|
|
@ -40,13 +47,11 @@ public struct TemplateDrawingOperation: DrawingOperation {
|
|||
public func apply(in context: CGContext) {
|
||||
let imageRect = CGRect(origin: .zero, size: imageSize)
|
||||
|
||||
context.setFillColor(color)
|
||||
|
||||
context.translateBy(x: 0, y: imageSize.height)
|
||||
context.scaleBy(x: 1, y: -1)
|
||||
context.clip(to: imageRect, mask: image)
|
||||
context.fill(imageRect)
|
||||
|
||||
context.setBlendMode(.multiply)
|
||||
apply(in: context) {
|
||||
$0.setFillColor(color)
|
||||
$0.clip(to: imageRect, mask: image)
|
||||
$0.fill(imageRect)
|
||||
$0.setBlendMode(.multiply)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,47 +0,0 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
|
||||
public extension Nef {
|
||||
|
||||
static func run<T: XCTestCase>(testCase class: T.Type) {
|
||||
startTestObserver()
|
||||
T.defaultTestSuite.run()
|
||||
}
|
||||
|
||||
static private func startTestObserver() {
|
||||
_ = testObserverInstalled
|
||||
}
|
||||
|
||||
static private var testObserverInstalled = { () -> NefTestFailObserver in
|
||||
let testObserver = NefTestFailObserver()
|
||||
XCTestObservationCenter.shared.addTestObserver(testObserver)
|
||||
return testObserver
|
||||
}()
|
||||
}
|
||||
|
||||
// MARK: enrich the output for XCTest
|
||||
fileprivate class NefTestFailObserver: NSObject, XCTestObservation {
|
||||
|
||||
private var numberOfFailedTests = 0
|
||||
|
||||
func testSuiteWillStart(_ testSuite: XCTestSuite) {
|
||||
numberOfFailedTests = 0
|
||||
}
|
||||
|
||||
func testSuiteDidFinish(_ testSuite: XCTestSuite) {
|
||||
if numberOfFailedTests > 0 {
|
||||
print("💢 Test Suite '\(testSuite.name)' finished with \(numberOfFailedTests) failed \(numberOfFailedTests > 1 ? "tests" : "test").")
|
||||
} else {
|
||||
print("🔅 Test Suite '\(testSuite.name)' finished successfully.")
|
||||
}
|
||||
}
|
||||
|
||||
func testCase(_ testCase: XCTestCase,
|
||||
didFailWithDescription description: String,
|
||||
inFile filePath: String?,
|
||||
atLine lineNumber: Int) {
|
||||
|
||||
numberOfFailedTests += 1
|
||||
print("❗️Test Fail '\(testCase.name)':\(UInt(lineNumber)): \(description.description)")
|
||||
}
|
||||
}
|
||||
|
|
@ -19,5 +19,5 @@ Pod::Spec.new do |s|
|
|||
s.exclude_files = s.name + '/*.app'
|
||||
end
|
||||
|
||||
s.framework = 'CoreGraphics'
|
||||
s.framework = 'CoreGraphics'
|
||||
end
|
||||
|
|
|
|||
|
|
@ -75,14 +75,11 @@ open class DefaultClusterIconRenderer {
|
|||
}
|
||||
|
||||
open func textDrawingOperation(for text: String) -> TextDrawingOperation {
|
||||
let ctFont = CTFontCreateWithFontDescriptorAndOptions(textAttributes.font.fontDescriptor,
|
||||
textAttributes.font.pointSize,
|
||||
nil,
|
||||
[])
|
||||
|
||||
return TextDrawingOperation(text: text,
|
||||
font: ctFont,
|
||||
textColor: textAttributes.color.cgColor)
|
||||
TextDrawingOperation(text: text,
|
||||
textAttributes: [
|
||||
.font: textAttributes.font,
|
||||
.foregroundColor: textAttributes.color
|
||||
])
|
||||
}
|
||||
|
||||
open func backgroundDrawingOperation(iconSize: CGSize,
|
||||
|
|
|
|||
|
|
@ -60,14 +60,15 @@ open class YandexMapManager<DataModel>: BaseMapManager<YMKMapView,
|
|||
}
|
||||
|
||||
public convenience init(map: YMKMapView,
|
||||
iconFactory: DefaultMarkerIconFactory<DataModel>? = nil,
|
||||
iconFactory: DefaultMarkerIconFactory<DataModel>,
|
||||
clusterIconFactory: DefaultClusterMarkerIconFactory<DataModel>? = nil,
|
||||
selectPlacemarkHandler: @escaping SelectPlacemarkHandler)
|
||||
where DataModel: MapLocatable, DataModel.Position == YMKPoint {
|
||||
|
||||
self.init(map: map,
|
||||
positionGetter: { $0.position },
|
||||
defaultMarkerIcon: defaultMarkerIcon,
|
||||
iconFactory: iconFactory,
|
||||
clusterIconFactory: clusterIconFactory,
|
||||
selectPlacemarkHandler: selectPlacemarkHandler)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue