You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -15,16 +15,23 @@ Use SwiftUI with NativeScript.
15
15
16
16
## Contents
17
17
18
-
-[Installation](#installation)
19
-
-[Usage](#usage)
20
-
1.[Create your SwiftUI view](#1-create-your-swiftui-view)
21
-
2.[Create your SwiftUI view Provider](#2-create-your-swiftui-view-provider)
22
-
3.[Register your SwiftUI with an identifier and use it in the markup](#3-register-your-swiftui-with-an-identifier-and-use-it-in-markup)
23
-
-[Core](#core)
24
-
-[Generate Types](#generate-types)
25
-
-[SwiftUI with Angular](#swiftui-with-angular)
26
-
-[SwiftUI with Vue](#swiftui-with-vue)
27
-
-[SwiftUI with React](#swiftui-with-react)
18
+
-[@nativescript/swift-ui](#nativescriptswift-ui)
19
+
-[Contents](#contents)
20
+
-[Installation](#installation)
21
+
-[Usage](#usage)
22
+
-[1. Create your SwiftUI view](#1-create-your-swiftui-view)
23
+
-[2. Create your SwiftUI view Provider](#2-create-your-swiftui-view-provider)
24
+
-[3. Register your SwiftUI with an identifier and use it in markup](#3-register-your-swiftui-with-an-identifier-and-use-it-in-markup)
25
+
-[Core](#core)
26
+
-[Generate Types](#generate-types)
27
+
-[SwiftUI with Angular](#swiftui-with-angular)
28
+
-[SwiftUI with Vue](#swiftui-with-vue)
29
+
-[SwiftUI with React](#swiftui-with-react)
30
+
-[Open Multiple Scenes](#open-multiple-scenes)
31
+
-[Passing contextual data to scenes](#passing-contextual-data-to-scenes)
32
+
-[Closing windows](#closing-windows)
33
+
-[Credits](#credits)
34
+
-[License](#license)
28
35
29
36
## Installation
30
37
@@ -241,8 +248,119 @@ Then use it in markup as follows:
241
248
</stackLayout>
242
249
```
243
250
251
+
## Open Multiple Scenes
252
+
253
+
When using a SwiftUI App Lifecycle setup for your NativeScript app, _the default with_[visionOS](https://docs.nativescript.org/guide/visionos)_development_, you can enable multiple scenes in your `Info.plist` with the following:
// Both options work with XR/Immersive Spaces as well, for example:
325
+
WindowManager.getWindow('NeatImmersive').update({
326
+
salutation: 'Hello World',
327
+
})
328
+
```
329
+
330
+
### Passing contextual data to scenes
331
+
332
+
You can use the `onReceive` modifier in SwiftUI to handle any data passed to your windows.
333
+
334
+
For example, anytime `WindowManager.getWindow("Window_ID").update(...)` is called, a Notification is dispatched which can be picked up for data to be handled:
335
+
336
+
```swift
337
+
structNeatView: View {
338
+
@Statevar context: NativeScriptWindowContext?
339
+
340
+
var body: some View {
341
+
ZStack {
342
+
// more neat views here
343
+
}.onReceive(NotificationCenter.default.publisher(for: NSNotification.Name("NativeScriptWindowUpdate")), perform: { obj in
NativeScript is proudly supported by Valor Software as an official partner. We are proud to offer guidance, consulting, and development assistance in all things NativeScript.
0 commit comments