Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ struct OpenSwiftUITextAlwaysOnProvider: TextAlwaysOnProvider {
schedule: @autoclosure () -> Attribute<(any TimelineSchedule)?>,
outputs: inout _ViewOutputs
) {

guard _UIAlwaysOnEnvironment._alwaysOnSupported else {
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,4 +235,25 @@ extension UITraitEnvironmentLayoutDirection {
}
}

// MARK: - UIUserInterfaceIdiom Conversions

extension UIUserInterfaceIdiom {
package var idiom: AnyInterfaceIdiom? {
switch self {
case .phone: AnyInterfaceIdiom(.phone)
case .pad: AnyInterfaceIdiom(.pad)
case .tv: AnyInterfaceIdiom(.tv)
case .carPlay: AnyInterfaceIdiom(.carPlay)
case .watch: AnyInterfaceIdiom(.watch)
case .mac: AnyInterfaceIdiom(.mac)
case .vision: AnyInterfaceIdiom(.vision)
default: nil
}
}
}

extension UIUserInterfaceIdiom {
static let watch = UIUserInterfaceIdiom(rawValue: 4)!
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
// ID: FAF0B683EB49BE9BABC9009857940A1E (SwiftUI)

#if os(iOS) || os(visionOS)
public import UIKit
import OpenAttributeGraphShims
@_spi(ForOpenSwiftUIOnly)
@_spi(Private)
public import OpenSwiftUICore
public import UIKit
import OpenSwiftUI_SPI

import OpenSwiftUISymbolDualTestsSupport
import OpenSwiftUI_SPI

/// A UIView which hosts an OpenSwiftUI View hierarchy.
@available(macOS, unavailable)
Expand Down Expand Up @@ -143,7 +143,9 @@ open class _UIHostingView<Content>: UIView, XcodeViewDebugDataProvider where Con
// AccessibilityFocus.changed(from: nil, to: nil, within: self)
}
}


// private weak var delegate: UIHostingViewDelegate?

required public init(rootView: Content) {
_rootView = rootView
Update.begin()
Expand All @@ -167,6 +169,7 @@ open class _UIHostingView<Content>: UIView, XcodeViewDebugDataProvider where Con
}
// TODO
super.init(frame: .zero)
_base.viewGraph.append(feature: HostViewGraph(host: self))
// TODO
let base = base
if let host = base.host {
Expand Down Expand Up @@ -718,4 +721,33 @@ extension _UIHostingView: UIViewControllerProvider {
}
}

// MARK: _UIHostingView.HostViewGraph [6.5.4] [Blocked by Gesture System]

extension _UIHostingView {
private struct HostViewGraph: ViewGraphFeature {
weak var host: _UIHostingView?

func modifyViewInputs(inputs: inout _ViewInputs, graph: ViewGraph) {
guard let host else {
return
}
// inputs.eventBindingBridgeFactory = UIKitResponderEventBindingBridge.Factory.self
// inputs.gestureContainerFactory = UIKitGestureContainerFactory.self
// host.delegate?.xx
var idiom = inputs[InterfaceIdiomInput.self]
if idiom == nil {
Update.syncMain {
idiom = host.traitCollection.userInterfaceIdiom.idiom ?? UIDevice.current.userInterfaceIdiom.idiom
}
}
idiom.map { inputs[InterfaceIdiomInput.self] = $0 }
let box: WeakBox<UIView> = WeakBox(host)
let boxAttr = Attribute(value: box)
// inputs[UIKitHostContainerFocusItemInput.self] = boxAttr
inputs.textAlwaysOnProvider = OpenSwiftUITextAlwaysOnProvider.self
// navigationBridge?.updateViewInputs(&inputs)
}
}
}

#endif
8 changes: 7 additions & 1 deletion Sources/OpenSwiftUICore/Event/Event/EventBindingSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,17 @@ package struct EventBindingBridgeFactoryInput: ViewInput {
}

extension _ViewInputs {
@inline(__always)
package var eventBindingBridgeFactory: (any EventBindingBridgeFactory.Type)? {
get { self[EventBindingBridgeFactoryInput.self] }
set { self[EventBindingBridgeFactoryInput.self] = newValue }
}

package func makeEventBindingBridge(
bindingManager: EventBindingManager,
responder: any AnyGestureResponder
) -> any EventBindingBridge & GestureGraphDelegate {
guard let factory = self[EventBindingBridgeFactoryInput.self] else {
guard let factory = eventBindingBridgeFactory else {
preconditionFailure("Event binding factory must be configured")
}
return factory.makeEventBindingBridge(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
// GestureContainerFactory.swift
// OpenSwiftUICore
//
// Audited for 6.5.4
// Status: Complete

// MARK: - GestureContainerFactory [6.5.4]
// MARK: - GestureContainerFactory

package protocol GestureContainerFactory {
static func makeGestureContainer(responder: any AnyGestureContainingResponder) -> AnyObject
Expand All @@ -17,8 +18,14 @@ package struct GestureContainerFactoryInput: ViewInput {
}

extension _ViewInputs {
@inline(__always)
package var gestureContainerFactory: (any GestureContainerFactory.Type)? {
get { self[GestureContainerFactoryInput.self] }
set { self[GestureContainerFactoryInput.self] = newValue }
}

package func makeGestureContainer(responder: any AnyGestureContainingResponder) -> AnyObject {
guard let factory = self[GestureContainerFactoryInput.self] else {
guard let factory = gestureContainerFactory else {
preconditionFailure("Gesture container factory must be configured")
}
return factory.makeGestureContainer(responder: responder)
Expand Down