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
10 changes: 5 additions & 5 deletions Example/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@
};
279283B82DFF11CE00234D64 = {
CreatedOnToolsVersion = 16.3;
TestTargetID = 27D49DF72BA604FB00F6E2E2;
TestTargetID = 275751E22DEE1441003E467C;
};
27CD0B482AFC8D37003665EB = {
CreatedOnToolsVersion = 15.0;
Expand Down Expand Up @@ -1116,7 +1116,7 @@
SUPPORTS_MACCATALYST = NO;
SWIFT_EMIT_LOC_STRINGS = NO;
TARGETED_DEVICE_FAMILY = "1,2,7";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/HostingExample.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/HostingExample";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TestingHost.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/TestingHost";
};
name = SwiftUIDebug;
};
Expand All @@ -1138,7 +1138,7 @@
SUPPORTS_MACCATALYST = NO;
SWIFT_EMIT_LOC_STRINGS = NO;
TARGETED_DEVICE_FAMILY = "1,2,7";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/HostingExample.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/HostingExample";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TestingHost.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/TestingHost";
};
name = SwiftUIRelease;
};
Expand All @@ -1160,7 +1160,7 @@
SUPPORTS_MACCATALYST = NO;
SWIFT_EMIT_LOC_STRINGS = NO;
TARGETED_DEVICE_FAMILY = "1,2,7";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/HostingExample.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/HostingExample";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TestingHost.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/TestingHost";
};
name = OpenSwiftUIDebug;
};
Expand All @@ -1182,7 +1182,7 @@
SUPPORTS_MACCATALYST = NO;
SWIFT_EMIT_LOC_STRINGS = NO;
TARGETED_DEVICE_FAMILY = "1,2,7";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/HostingExample.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/HostingExample";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TestingHost.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/TestingHost";
};
name = OpenSwiftUIRelease;
};
Expand Down
6 changes: 6 additions & 0 deletions Sources/COpenSwiftUI/Shims/UIKit/UIKit_Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ OPENSWIFTUI_ASSUME_NONNULL_BEGIN
- (nullable NSString *)_launchTestName_openswiftui_safe_wrapper OPENSWIFTUI_SWIFT_NAME(_launchTestName());

- (void)_performBlockAfterCATransactionCommits_openswiftui_safe_wrapper:(void (^)(void))block OPENSWIFTUI_SWIFT_NAME(_performBlockAfterCATransactionCommits(_:));

- (void)_saveRestorationUserActivityStateForScene_openswiftui_safe_wrapper:(UIScene *)scene OPENSWIFTUI_SWIFT_NAME(_saveRestorationUserActivityState(forScene:));
@end

@interface UIView (OpenSwiftUI_SPI)
Expand Down Expand Up @@ -92,6 +94,10 @@ OPENSWIFTUI_ASSUME_NONNULL_BEGIN
@end
#endif

@interface UISceneConfiguration (OpenSwiftUI_SPI)
@property (nonatomic, readonly, nullable) id<UISceneDelegate> sceneDelegate;
@end

OPENSWIFTUI_EXPORT
bool UIViewIgnoresTouchEvents(UIView *view);

Expand Down
5 changes: 5 additions & 0 deletions Sources/COpenSwiftUI/Shims/UIKit/UIKit_Private.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ - (NSString *)_launchTestName_openswiftui_safe_wrapper {
OPENSWIFTUI_SAFE_WRAPPER_IMP(NSString *, @"_launchTestName", nil);
return func(self, selector);
}

- (void)_saveRestorationUserActivityStateForScene_openswiftui_safe_wrapper:(UIScene *)scene {
OPENSWIFTUI_SAFE_WRAPPER_IMP(void, @"_saveRestorationUserActivityStateForScene:", , UIScene *);
func(self, selector, scene);
}
@end

@implementation UIView (OpenSwiftUI_SPI)
Expand Down
27 changes: 27 additions & 0 deletions Sources/COpenSwiftUI/Shims/UserActivity/UserActivity_Private.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// UserActivity_Private.h
// COpenSwiftUI
//
// Audited for 6.5.4
// Status: Complete

#ifndef UserActivity_Private_h
#define UserActivity_Private_h

#include "OpenSwiftUIBase.h"

#if OPENSWIFTUI_TARGET_OS_DARWIN

#import <Foundation/Foundation.h>

OPENSWIFTUI_ASSUME_NONNULL_BEGIN

@interface NSUserActivity (OpenSwiftUI_SPI)
@property (nonatomic, readonly) BOOL _isUniversalLink;
@end

OPENSWIFTUI_ASSUME_NONNULL_END

#endif /* OPENSWIFTUI_TARGET_OS_DARWIN */

#endif /* UserActivity_Private_h */
50 changes: 48 additions & 2 deletions Sources/OpenSwiftUI/App/App/AppGraph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import Glibc
import WASILibc
#endif
import OpenAttributeGraphShims
@_spi(ForOpenSwiftUIOnly) package import OpenSwiftUICore
@_spi(ForOpenSwiftUIOnly)
package import OpenSwiftUICore

package final class AppGraph: GraphHost {
static var shared: AppGraph? = nil {
Expand Down Expand Up @@ -170,10 +171,55 @@ extension AppGraph {
}
}

// MARK: - AppGreaph + GraphDelegate

extension AppGraph: GraphDelegate {
package func updateGraph<T>(body: (GraphHost) -> T) -> T {
body(self)
}

package func graphDidChange() {
data.updateSeed &+= 1
runTransaction()
let phaseChanged = $rootScenePhase.changedValue().changed
let commandsChanged = $rootCommandsList?.changedValue().changed ?? false
// TODO: notifyObservers
_openSwiftUIUnimplementedWarning()
}

package func preferencesDidChange() {
_openSwiftUIEmptyStub()
}
}

extension AppGraph {
func addObserver(_ observer: some AppGraphObserver) {
observers = observers.filter { $0.base != nil }
observers.insert(HashableWeakBox(observer))
}

func removeObserver(_ observer: some AppGraphObserver) {
observers = observers.filter { $0.base != nil }
observers.remove(HashableWeakBox(observer))
}

// func notifyObservers(phaseChanged: Bool) {
// for box in observers {
// (box.base as? AppGraphObserver)?.scenesDidChange(phaseChanged: phaseChanged)
// }
// }
//
// func notifyCommandsChanged() {
// for box in observers {
// (box.base as? AppGraphObserver)?.commandsDidChange()
// }
// }
}

// MARK: - AppGraphObserver

protocol AppGraphObserver: AnyObject {
func sceneDidChange(phaseChanged: Bool)
func scenesDidChange(phaseChanged: Bool)
func commandsDidChange()
}

Expand Down
39 changes: 39 additions & 0 deletions Sources/OpenSwiftUI/App/App/AppKit/AppKitAppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,45 @@ class AppDelegate: NSResponder, NSApplicationDelegate {
override func forwardingTarget(for aSelector: Selector!) -> Any? {
appDelegate
}

func applicationWillFinishLaunching(_ notification: Notification) {
Update.begin()
defer { Update.end() }
// FIXME
let items = AppGraph.shared?.rootSceneList?.items ?? []
let view = items[0].value.view
let hostingVC = NSHostingController(rootView: view)
let windowVC = WindowController(hostingVC)
windowVC.showWindow(nil)
}
}

// FIXME: frame is zero
final class WindowController<Content>: NSWindowController where Content: View {
init(_ hostingVC: NSHostingController<Content>) {
self.hostingVC = hostingVC
super.init(window: nil)
}

@available(*, unavailable)
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override var windowNibName: NSNib.Name? { "" }

let hostingVC: NSHostingController<Content>

override func loadWindow() {
window = NSWindow(contentRect: .init(x: 0, y: 0, width: 500, height: 300), styleMask: [.titled, .closable, .miniaturizable], backing: .buffered, defer: false)
window?.center()
}

override func windowDidLoad() {
super.windowDidLoad()
contentViewController = hostingVC
hostingVC.host.frame = window!.frame
}
}

// MARK: - App Utils
Expand Down
Loading
Loading