Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial hosting support #26

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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?
}