forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
60e72d7
commit 32260e7
Showing
5 changed files
with
115 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// App.swift | ||
// RNTester-visionOS | ||
// | ||
// Created by Oskar Kwaśniewski on 21/12/2023. | ||
// Copyright © 2023 Facebook. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
@main | ||
struct NavTestApp: App { | ||
@UIApplicationDelegateAdaptor var delegate: AppDelegate | ||
|
||
var body: some Scene { | ||
WindowGroup { | ||
Text("Hey") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// AppDelegate.swift | ||
// RNTester-visionOS | ||
// | ||
// Created by Oskar Kwaśniewski on 21/12/2023. | ||
// Copyright © 2023 Facebook. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import UIKit | ||
import React | ||
import React_RCTAppDelegate | ||
|
||
class AppDelegate: NSObject, UIApplicationDelegate, ObservableObject { | ||
private var bridge: RCTBridge? | ||
|
||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { | ||
// Do magic | ||
print("application did finish launching") | ||
return true | ||
} | ||
|
||
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { | ||
let sceneConfig = UISceneConfiguration(name: nil, sessionRole: connectingSceneSession.role) | ||
sceneConfig.delegateClass = SceneDelegate.self | ||
return sceneConfig | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
packages/rn-tester/RNTester-visionOS/ReactRootViewRepresentable.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// ReactRootViewRepresentable.swift | ||
// RNTester-visionOS | ||
// | ||
// Created by Oskar Kwaśniewski on 21/12/2023. | ||
// Copyright © 2023 Facebook. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import React | ||
|
||
struct ReactRootViewRepresentable: UIViewRepresentable { | ||
var bridge: RCTBridge | ||
var moduleName: String | ||
|
||
func updateUIView(_ uiView: UIViewType, context: Context) { | ||
// Do nothing | ||
} | ||
|
||
func makeUIView(context: Context) -> some UIView { | ||
let rootView = RCTRootView(bridge: bridge, moduleName: moduleName, initialProperties: nil) | ||
|
||
return rootView | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// SceneDelegate.swift | ||
// RNTester-visionOS | ||
// | ||
// Created by Oskar Kwaśniewski on 21/12/2023. | ||
// Copyright © 2023 Facebook. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import UIKit | ||
|
||
class SceneDelegate: NSObject, UIWindowSceneDelegate { | ||
func sceneWillEnterForeground(_ scene: UIScene) { | ||
// ... | ||
} | ||
|
||
func sceneDidBecomeActive(_ scene: UIScene) { | ||
// ... | ||
} | ||
|
||
func sceneWillResignActive(_ scene: UIScene) { | ||
// ... | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters