Skip to content

Commit 56d29ff

Browse files
authored
Add initial hosting support (#26)
1 parent c0e6e19 commit 56d29ff

11 files changed

+104
-12
lines changed

Sources/OpenSwiftUI/FrameworkIntegration/TODO/_UIHostingView.swift

-12
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#if os(iOS)
2+
import UIKit
3+
4+
@available(macOS, unavailable)
5+
@available(watchOS, unavailable)
6+
@MainActor(unsafe)
7+
open class UIHostingController<Content> : UIViewController where Content : View {
8+
override open dynamic var keyCommands: [UIKeyCommand]? {
9+
fatalError("Unimplemented")
10+
}
11+
}
12+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#if os(iOS)
2+
import UIKit
3+
4+
@available(macOS, unavailable)
5+
@available(watchOS, unavailable)
6+
@MainActor(unsafe)
7+
open class _UIHostingView<Content>: UIView where Content: View {
8+
@available(macOS, unavailable)
9+
@available(watchOS, unavailable)
10+
final public func _viewDebugData() -> [_ViewDebug.Data] {
11+
// TODO
12+
[]
13+
}
14+
}
15+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#if os(iOS)
2+
import CoreGraphics
3+
4+
@available(macOS, unavailable)
5+
public protocol _UIHostingViewable: AnyObject {
6+
var rootView: AnyView { get set }
7+
func _render(seconds: Swift.Double)
8+
func _forEachIdentifiedView(body: (_IdentifiedViewProxy) -> Void)
9+
func sizeThatFits(in size: CGSize) -> CGSize
10+
var _disableSafeArea: Bool { get set }
11+
// var _rendererConfiguration: _RendererConfiguration { get set }
12+
var _rendererObject: AnyObject? { get }
13+
}
14+
15+
//@available(macOS, unavailable)
16+
//extension UIHostingController : _UIHostingViewable where Content == AnyView {
17+
//}
18+
19+
@available(macOS, unavailable)
20+
public func _makeUIHostingController(_ view: AnyView) -> NSObject & _UIHostingViewable {
21+
fatalError("TODO")
22+
23+
}
24+
25+
@available(macOS, unavailable)
26+
public func _makeUIHostingController(_ view: AnyView, tracksContentSize: Swift.Bool) -> NSObject & _UIHostingViewable {
27+
fatalError("TODO")
28+
}
29+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// ID: CE19A3CEA6B9730579C42CE4C3071E74
2+
3+
#if canImport(Darwin)
4+
import CoreGraphics
5+
#elseif os(Linux)
6+
import Foundation
7+
#endif
8+
9+
struct ViewTransform {
10+
private var chunks: ContiguousArray<Chunk>
11+
var positionAdjustment: CGSize
12+
}
13+
14+
extension ViewTransform {
15+
private class Chunk {
16+
var tags: [Tag]
17+
var values: [CGFloat]
18+
var spaces: [AnyHashable]
19+
init() {
20+
fatalError()
21+
}
22+
23+
enum Tag {
24+
case translation
25+
case affine
26+
case affine_inverse
27+
case projection
28+
case projection_inverse
29+
case space
30+
case sized_space
31+
case scroll_layout
32+
}
33+
}
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#if canImport(Darwin)
2+
import CoreGraphics
3+
#elseif os(Linux)
4+
import Foundation
5+
#endif
6+
7+
public struct _IdentifiedViewProxy {
8+
var identifier: AnyHashable
9+
var size: CGSize
10+
var position: CGPoint
11+
var transform: ViewTransform
12+
var adjustment: (inout CGRect) -> ()?
13+
// var accessibilityNodeStorage: AccessibilityNodeProxy?
14+
}

0 commit comments

Comments
 (0)