-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathContentResponder.swift
40 lines (35 loc) · 1.12 KB
/
ContentResponder.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//
// ContentResponder.swift
// OpenSwiftUI
//
// Audited for iOS 15.5
// Status: WIP
package import Foundation
import OpenSwiftUI_SPI
package protocol ContentResponder {
func contains(points: [CGPoint], size: CGSize) -> BitVector64
func contentPath(size: CGSize) -> Path
func contentPath(size: CGSize, kind: ContentShapeKinds) -> Path
}
extension ContentResponder {
func contains(points: [CGPoint], size: CGSize) -> BitVector64 {
guard !points.isEmpty else { return BitVector64() }
let rect = CGRect(origin: .zero, size: size)
return points.mapBool { rect.contains($0) }
}
func contentPath(size: CGSize) -> Path {
Path(CGRect(origin: .zero, size: size))
}
func contentPath(size: CGSize, kind: ContentShapeKinds) -> Path {
if kind == .interaction {
return contentPath(size: size)
} else {
let shouldReturnEmptyPath = _SemanticFeature_v3.isEnabled
if shouldReturnEmptyPath {
return Path()
} else {
return contentPath(size: size)
}
}
}
}