Skip to content

Refactor View into Core module #134

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

Merged
merged 3 commits into from
Oct 7, 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
1 change: 1 addition & 0 deletions Sources/COpenSwiftUI/empty.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions Sources/COpenSwiftUI/include/empty.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
//
// ProtocolDescriptor.c
// FIXME: Use ProtocolDescriptor.m due to COpenSwiftUICore module contains ObjC symbol.
// Solution: Move down to COpenSwiftUICore module.
// COpenSwiftUI

// COpenSwiftUICore

#include "ProtocolDescriptor.h"

Expand All @@ -13,15 +10,15 @@ void _OpenSwiftUI_callVisitViewType(void *visitor_value,
const void *view_pwt);

OPENSWIFTUI_EXPORT
const void *$s11OpenSwiftUI4ViewMp;
const void *$s15OpenSwiftUICore4ViewMp;

const void *_OpenSwiftUI_viewProtocolDescriptor(void) {
return &$s11OpenSwiftUI4ViewMp;
return &$s15OpenSwiftUICore4ViewMp;
}

OPENSWIFTUI_EXPORT
const void *$s11OpenSwiftUI12ViewModifierMp;
const void *$s15OpenSwiftUICore12ViewModifierMp;

const void *_OpenSwiftUI_viewModifierProtocolDescriptor(void) {
return &$s11OpenSwiftUI12ViewModifierMp;
return &$s15OpenSwiftUICore12ViewModifierMp;
}
2 changes: 1 addition & 1 deletion Sources/OpenSwiftUI/App/AppGraph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Glibc
import WASILibc
#endif
internal import OpenGraphShims
@_spi(ForOpenSwiftUIOnly) import OpenSwiftUICore
@_spi(ForOpenSwiftUIOnly) package import OpenSwiftUICore

package final class AppGraph: GraphHost {
static var shared: AppGraph? = nil
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenSwiftUI/App/OpenSwiftUIApplication.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Status: WIP
// ID: ACC2C5639A7D76F611E170E831FCA491

@_spi(ForOpenSwiftUIOnly) import OpenSwiftUICore
@_spi(ForOpenSwiftUIOnly) internal import OpenSwiftUICore

#if os(iOS) || os(tvOS)
import UIKit
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenSwiftUI/Core/Render/DisplayLink.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import UIKit
import AppKit
#endif

@_spi(ForOpenSwiftUIOnly) import OpenSwiftUICore
@_spi(ForOpenSwiftUIOnly) internal import OpenSwiftUICore

final class DisplayLink: NSObject {
private weak var host: AnyUIHostingView?
Expand Down
21 changes: 0 additions & 21 deletions Sources/OpenSwiftUI/Core/Util/Comparable+Extension.swift

This file was deleted.

144 changes: 0 additions & 144 deletions Sources/OpenSwiftUI/Core/View/View/ViewInputs.swift

This file was deleted.

2 changes: 1 addition & 1 deletion Sources/OpenSwiftUI/EventHandling/Focus/FocusState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Status: WIP
// ID: 274D264A38B51DC68ACC48A91353B7D0

@_spi(ForOpenSwiftUIOnly) import OpenSwiftUICore
@_spi(ForOpenSwiftUIOnly) public import OpenSwiftUICore

@frozen
@propertyWrapper
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@_spi(ForOpenSwiftUIOnly) import OpenSwiftUICore
@_spi(ForOpenSwiftUIOnly) internal import OpenSwiftUICore

class FocusStoreLocation<A: Hashable>: AnyLocation<A>, @unchecked Sendable {
override var wasRead: Bool {
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenSwiftUI/Export.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
@_spi(DisplayList_ViewSystem)
@_spi(SystemUI)
@_spi(DoNotImport)
import OpenSwiftUICore
public import OpenSwiftUICore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import Foundation
typealias PlatformView = Void
#endif

internal import OpenSwiftUICore

protocol PlatformViewRepresentable: View {
associatedtype PlatformViewProvider
associatedtype Coordinator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#if os(iOS)

@_spi(ForOpenSwiftUIOnly) import OpenSwiftUICore
@_spi(ForOpenSwiftUIOnly) internal import OpenSwiftUICore

protocol AnyUIHostingView: AnyObject {
func displayLinkTimer(timestamp: Time, isAsyncThread: Bool)
Expand Down
24 changes: 12 additions & 12 deletions Sources/OpenSwiftUI/Integration/UIKit/UIHostingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
// ID: FAF0B683EB49BE9BABC9009857940A1E

#if os(iOS)
@_spi(ForOpenSwiftUIOnly) import OpenSwiftUICore
@_spi(ForOpenSwiftUIOnly) public import OpenSwiftUICore
import UIKit

@available(macOS, unavailable)
@available(watchOS, unavailable)
open class _UIHostingView<Content>: UIView where Content: View {
private var _rootView: Content
var viewGraph: ViewGraph
var currentTimestamp: Time = .zero
var propertiesNeedingUpdate: ViewRendererHostProperties = [.rootView] // FIXME
var isRendering: Bool = false
package var viewGraph: ViewGraph
package var currentTimestamp: Time = .zero
package var propertiesNeedingUpdate: ViewRendererHostProperties = [.rootView] // FIXME
package var isRendering: Bool = false
var inheritedEnvironment: EnvironmentValues?
var environmentOverride: EnvironmentValues?
weak var viewController: UIHostingController<Content>?
Expand Down Expand Up @@ -154,30 +154,30 @@ open class _UIHostingView<Content>: UIView where Content: View {
}

extension _UIHostingView: ViewRendererHost {
func addImplicitPropertiesNeedingUpdate(to _: inout ViewRendererHostProperties) {}
package func addImplicitPropertiesNeedingUpdate(to _: inout ViewRendererHostProperties) {}

func updateRootView() {
package func updateRootView() {
let rootView = makeRootView()
viewGraph.setRootView(rootView)
}

func requestUpdate(after: Double) {
package func requestUpdate(after: Double) {
// TODO
}

func modifyViewInputs(_ inputs: inout _ViewInputs) {
package func modifyViewInputs(_ inputs: inout _ViewInputs) {
// TODO
}

func outputsDidChange(outputs: ViewGraph.Outputs) {
package func outputsDidChange(outputs: ViewGraph.Outputs) {
// TODO
}

func focusDidChange() {
package func focusDidChange() {
// TODO
}

func rootTransform() -> ViewTransform {
package func rootTransform() -> ViewTransform {
fatalError("TODO")
}

Expand Down
1 change: 1 addition & 0 deletions Sources/OpenSwiftUI/Test/TestIDView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Status: WIP

internal import OpenGraphShims
internal import OpenSwiftUICore

struct TestIDView<Content, ID>: PrimitiveView, UnaryView {
var content: Content
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
public struct ButtonStyleConfiguration {
public struct Label: ViewAlias {
public typealias Body = Never

package init() {}

Check warning on line 12 in Sources/OpenSwiftUI/View/Control/Button/ButtonStyle/ButtonStyleConfiguration.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUI/View/Control/Button/ButtonStyle/ButtonStyleConfiguration.swift#L12

Added line #L12 was not covered by tests
}

// 0x0 - 2 Byte
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
public struct PrimitiveButtonStyleConfiguration {
public struct Label: ViewAlias {
public typealias Body = Never

package init() {}

Check warning on line 12 in Sources/OpenSwiftUI/View/Control/Button/ButtonStyle/PrimitiveButtonStyleConfiguration.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUI/View/Control/Button/ButtonStyle/PrimitiveButtonStyleConfiguration.swift#L12

Added line #L12 was not covered by tests
}

// 0x0 - 2 Byte
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenSwiftUI/View/Control/Slider/Slider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Status: Blocked by Accessibility
// ID: F045F16106E380A820CC0B639278A953

@_spi(ForOpenSwiftUIOnly) import OpenSwiftUICore
@_spi(ForOpenSwiftUIOnly) public import OpenSwiftUICore

/// A control for selecting a value from a bounded linear range of values.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
// ID: A9FAE381E99529D5274BA37A9BC9B074

internal import OpenGraphShims
@_spi(ForOpenSwiftUIOnly) import OpenSwiftUICore

final class PreferenceBridge {
package final class PreferenceBridge {
unowned let viewGraph: ViewGraph
private(set) var children: [Unmanaged<ViewGraph>] = []
var requestedPreferences = PreferenceKeys()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
// Status: Complete
// ID: 6C396F98EFDD04A6B58F2F9112448013

@_spi(ForOpenSwiftUIOnly) import OpenSwiftUICore
@_spi(Private) import OpenSwiftUICore

extension View {
/// Sets a value for the given preference.
@inlinable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
// Status: WIP

import Foundation
internal import COpenSwiftUI
@_spi(ForOpenSwiftUIOnly) import OpenSwiftUICore
internal import COpenSwiftUICore

protocol ContentResponder {
func contains(points: [CGPoint], size: CGSize) -> BitVector64
Expand Down
Loading
Loading