Skip to content

Commit

Permalink
Add initial hosting support (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle-Ye authored Jan 11, 2024
1 parent c0e6e19 commit 56d29ff
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 12 deletions.
12 changes: 0 additions & 12 deletions Sources/OpenSwiftUI/FrameworkIntegration/TODO/_UIHostingView.swift

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#if os(iOS)
import UIKit

@available(macOS, unavailable)
@available(watchOS, unavailable)
@MainActor(unsafe)
open class UIHostingController<Content> : UIViewController where Content : View {
override open dynamic var keyCommands: [UIKeyCommand]? {
fatalError("Unimplemented")
}
}
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#if os(iOS)
import UIKit

@available(macOS, unavailable)
@available(watchOS, unavailable)
@MainActor(unsafe)
open class _UIHostingView<Content>: UIView where Content: View {
@available(macOS, unavailable)
@available(watchOS, unavailable)
final public func _viewDebugData() -> [_ViewDebug.Data] {
// TODO
[]
}
}
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#if os(iOS)
import CoreGraphics

@available(macOS, unavailable)
public protocol _UIHostingViewable: AnyObject {
var rootView: AnyView { get set }
func _render(seconds: Swift.Double)
func _forEachIdentifiedView(body: (_IdentifiedViewProxy) -> Void)
func sizeThatFits(in size: CGSize) -> CGSize
var _disableSafeArea: Bool { get set }
// var _rendererConfiguration: _RendererConfiguration { get set }
var _rendererObject: AnyObject? { get }
}

//@available(macOS, unavailable)
//extension UIHostingController : _UIHostingViewable where Content == AnyView {
//}

@available(macOS, unavailable)
public func _makeUIHostingController(_ view: AnyView) -> NSObject & _UIHostingViewable {
fatalError("TODO")

}

@available(macOS, unavailable)
public func _makeUIHostingController(_ view: AnyView, tracksContentSize: Swift.Bool) -> NSObject & _UIHostingViewable {
fatalError("TODO")
}
#endif
34 changes: 34 additions & 0 deletions Sources/OpenSwiftUI/Views/View/ViewTransform.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// ID: CE19A3CEA6B9730579C42CE4C3071E74

#if canImport(Darwin)
import CoreGraphics
#elseif os(Linux)
import Foundation
#endif

struct ViewTransform {
private var chunks: ContiguousArray<Chunk>
var positionAdjustment: CGSize
}

extension ViewTransform {
private class Chunk {
var tags: [Tag]
var values: [CGFloat]
var spaces: [AnyHashable]
init() {
fatalError()
}

enum Tag {
case translation
case affine
case affine_inverse
case projection
case projection_inverse
case space
case sized_space
case scroll_layout
}
}
}
14 changes: 14 additions & 0 deletions Sources/OpenSwiftUI/Views/View/_IdentifiedViewProxy.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#if canImport(Darwin)
import CoreGraphics
#elseif os(Linux)
import Foundation
#endif

public struct _IdentifiedViewProxy {
var identifier: AnyHashable
var size: CGSize
var position: CGPoint
var transform: ViewTransform
var adjustment: (inout CGRect) -> ()?
// var accessibilityNodeStorage: AccessibilityNodeProxy?
}

0 comments on commit 56d29ff

Please sign in to comment.