@nativescript/core 8.7.0-alpha.6 → 8.7.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nativescript/core",
3
- "version": "8.7.0-alpha.6",
3
+ "version": "8.7.0-alpha.7",
4
4
  "description": "A JavaScript library providing an easy to use api for interacting with iOS and Android platform APIs.",
5
5
  "main": "index",
6
6
  "types": "index.d.ts",
@@ -4,6 +4,16 @@ import UIKit
4
4
 
5
5
  @available(iOS 14.0, *)
6
6
  struct NativeScriptMainWindow: Scene {
7
+
8
+ #if os(visionOS)
9
+ // Environment control
10
+ @State var openedScenes: [String:Bool] = [:]
11
+ @Environment(\.openWindow) private var openWindow
12
+ @Environment(\.dismissWindow) private var dismissWindow
13
+ @Environment(\.openImmersiveSpace) private var openImmersiveSpace
14
+ @Environment(\.dismissImmersiveSpace) private var dismissImmersiveSpace
15
+ #endif
16
+
7
17
  var body: some Scene {
8
18
  #if os(visionOS)
9
19
  // windowStyle is only supported on visionOS
@@ -15,7 +25,42 @@ struct NativeScriptMainWindow: Scene {
15
25
  DispatchQueue.main.async {
16
26
  NativeScriptStart.boot()
17
27
  }
18
- }.onOpenURL { (url) in
28
+ }.onReceive(NotificationCenter.default
29
+ .publisher(for: NSNotification.Name("NativeScriptOpenScene")), perform: { obj in
30
+ Task {
31
+ if let userInfo = obj.userInfo {
32
+ var sceneType: String = ""
33
+ var isImmersive = false
34
+ for (key, value) in userInfo {
35
+ let k = key as! String
36
+ if (k == "type") {
37
+ sceneType = value as! String
38
+ } else if (k == "isImmersive") {
39
+ isImmersive = value as! Bool
40
+ }
41
+ }
42
+
43
+ let isOpened = openedScenes[sceneType] ?? false
44
+ if isOpened {
45
+ openedScenes[sceneType] = false
46
+ if (isImmersive) {
47
+ await dismissImmersiveSpace()
48
+ } else {
49
+ dismissWindow(id: sceneType)
50
+ }
51
+ } else {
52
+ openedScenes[sceneType] = true
53
+ if (isImmersive) {
54
+ await openImmersiveSpace(id: sceneType)
55
+ } else {
56
+ openWindow(id: sceneType)
57
+ }
58
+ }
59
+ }
60
+
61
+ }
62
+ })
63
+ .onOpenURL { (url) in
19
64
  NotificationCenter.default.post(name: Notification.Name("NativeScriptOpenURL"), object: nil, userInfo: ["url": url.absoluteString ])
20
65
  }
21
66
  }