Skip to content

Commit 4fe38cf

Browse files
authored
ContextDrawingNode (#90)
1 parent d554ba6 commit 4fe38cf

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
import Foundation
3+
4+
import AsyncDisplayKit
5+
6+
public final class ContextDrawingNode: ASDisplayNode {
7+
private let drawingInstructions: (CGContext, CGRect) -> Void
8+
9+
required public init (_ drawingInstructions: @escaping (CGContext, CGRect) -> Void) {
10+
self.drawingInstructions = drawingInstructions
11+
super.init()
12+
}
13+
14+
public override func drawParameters(forAsyncLayer layer: _ASDisplayLayer) -> NSObjectProtocol? {
15+
return ["drawingInstructions" : drawingInstructions] as NSDictionary
16+
}
17+
18+
19+
public override class func draw(_ bounds: CGRect, withParameters parameters: Any?, isCancelled isCancelledBlock: () -> Bool, isRasterizing: Bool) {
20+
guard
21+
let context = UIGraphicsGetCurrentContext(),
22+
let dictionnary = parameters as? NSDictionary,
23+
let instructions = dictionnary["drawingInstructions"] as? (CGContext, CGRect) -> Void
24+
else { return }
25+
instructions(context, bounds)
26+
}
27+
}

TextureSwiftSupport.xcodeproj/project.pbxproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
5E1466C33BD464A174155DF9 /* Pods_TextureSwiftSupportTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E55AE74C9FB7B22C94CCC1A1 /* Pods_TextureSwiftSupportTests.framework */; };
9191
C10F60211BD6F4CB5AD92EC0 /* Pods_Demo_TextureSwiftSuppoprt.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C23649818DE28AA59570663A /* Pods_Demo_TextureSwiftSuppoprt.framework */; };
9292
F7C9D342E080CFF7361B81C2 /* Pods_TextureSwiftSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E24A3D7641080B18EE97C1D /* Pods_TextureSwiftSupport.framework */; };
93+
FC04AD0128757688007EFBA0 /* ContextDrawingNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC04AD0028757688007EFBA0 /* ContextDrawingNode.swift */; };
9394
/* End PBXBuildFile section */
9495

9596
/* Begin PBXContainerItemProxy section */
@@ -201,6 +202,7 @@
201202
C23649818DE28AA59570663A /* Pods_Demo_TextureSwiftSuppoprt.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Demo_TextureSwiftSuppoprt.framework; sourceTree = BUILT_PRODUCTS_DIR; };
202203
C3B1B5868BA053074C4A411C /* Pods-TextureSwiftSupportTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TextureSwiftSupportTests.debug.xcconfig"; path = "Target Support Files/Pods-TextureSwiftSupportTests/Pods-TextureSwiftSupportTests.debug.xcconfig"; sourceTree = "<group>"; };
203204
E55AE74C9FB7B22C94CCC1A1 /* Pods_TextureSwiftSupportTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_TextureSwiftSupportTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
205+
FC04AD0028757688007EFBA0 /* ContextDrawingNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContextDrawingNode.swift; sourceTree = "<group>"; };
204206
/* End PBXFileReference section */
205207

206208
/* Begin PBXFrameworksBuildPhase section */
@@ -284,6 +286,7 @@
284286
4B5C387A242F0EEF005D9722 /* WrapperNode.swift */,
285287
4B5C3881242F10E3005D9722 /* ShapeLayerNode.swift */,
286288
4B5C3882242F10E3005D9722 /* ShapeDrawingNode.swift */,
289+
FC04AD0028757688007EFBA0 /* ContextDrawingNode.swift */,
287290
4B19E60F244DD9F0009FD799 /* AnyDisplayNode.swift */,
288291
4B58E84F260F0797004A834F /* InteractiveNode.swift */,
289292
4BDD0789264D008F0077590E /* StyledEdgeNode.swift */,
@@ -732,6 +735,7 @@
732735
4BC22F802642724900D1C43B /* EmptyLayout.swift in Sources */,
733736
4B58E850260F0797004A834F /* InteractiveNode.swift in Sources */,
734737
4B80CA2728535818008494B8 /* HostingNode.swift in Sources */,
738+
FC04AD0128757688007EFBA0 /* ContextDrawingNode.swift in Sources */,
735739
4B837DBD2853757E000B3EF7 /* UIResponder+.swift in Sources */,
736740
4B6262E9264FDD1600540F0B /* StackScrollNode.swift in Sources */,
737741
4BDD078A264D008F0077590E /* StyledEdgeNode.swift in Sources */,
@@ -966,7 +970,7 @@
966970
DYLIB_INSTALL_NAME_BASE = "@rpath";
967971
INFOPLIST_FILE = "$(SRCROOT)/Sources/Info.plist";
968972
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
969-
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
973+
IPHONEOS_DEPLOYMENT_TARGET = 11.1;
970974
LD_RUNPATH_SEARCH_PATHS = (
971975
"$(inherited)",
972976
"@executable_path/Frameworks",
@@ -991,7 +995,7 @@
991995
DYLIB_INSTALL_NAME_BASE = "@rpath";
992996
INFOPLIST_FILE = "$(SRCROOT)/Sources/Info.plist";
993997
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
994-
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
998+
IPHONEOS_DEPLOYMENT_TARGET = 11.1;
995999
LD_RUNPATH_SEARCH_PATHS = (
9961000
"$(inherited)",
9971001
"@executable_path/Frameworks",

0 commit comments

Comments
 (0)