@webspatial/platform-visionos 0.1.2 → 0.1.4
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 +1 -1
- package/web-spatial/libs/SpatialWindowComponent.swift +5 -0
- package/web-spatial/libs/webView/backend/NativeWebView.swift +1 -0
- package/web-spatial/views/MaterialWithBorderCornerModifier.swift +21 -0
- package/web-spatial/views/SpatialWebViewUI.swift +5 -3
- package/web-spatial/views/ui/NavView.swift +3 -2
package/package.json
CHANGED
|
@@ -18,6 +18,10 @@ struct LoadingStyles {
|
|
|
18
18
|
var backgroundMaterial: BackgroundMaterial = .None
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
class NavInfo: ObservableObject {
|
|
22
|
+
@Published var url: String = ""
|
|
23
|
+
}
|
|
24
|
+
|
|
21
25
|
@Observable
|
|
22
26
|
class SpatialWindowComponent: SpatialComponent {
|
|
23
27
|
override func inspect() -> [String: Any] {
|
|
@@ -66,6 +70,7 @@ class SpatialWindowComponent: SpatialComponent {
|
|
|
66
70
|
var parentWindowContainerID: String
|
|
67
71
|
var childWindowContainers = [String: WindowContainerData]()
|
|
68
72
|
var spawnedNativeWebviews = [String: WebViewNative]()
|
|
73
|
+
var navInfo = NavInfo()
|
|
69
74
|
|
|
70
75
|
// Resources that will be destroyed when this webpage is destoryed or if it is navigated away from
|
|
71
76
|
private var childResources = [String: SpatialObject]()
|
|
@@ -129,6 +129,7 @@ class Coordinator: NSObject, WKNavigationDelegate, WKScriptMessageHandler, WKUID
|
|
|
129
129
|
// backward/forward
|
|
130
130
|
webViewRef?.didNavBackForward()
|
|
131
131
|
}
|
|
132
|
+
webViewRef?.navInfo.url = resource
|
|
132
133
|
decisionHandler(.allow)
|
|
133
134
|
} else {
|
|
134
135
|
decisionHandler(.cancel)
|
|
@@ -7,6 +7,27 @@ enum BackgroundMaterial: String, Codable {
|
|
|
7
7
|
case ThickMaterial = "thick"
|
|
8
8
|
case RegularMaterial = "regular"
|
|
9
9
|
case ThinMaterial = "thin"
|
|
10
|
+
|
|
11
|
+
init(from decoder: Decoder) throws {
|
|
12
|
+
let container = try decoder.singleValueContainer()
|
|
13
|
+
let rawValue = try container.decode(String.self)
|
|
14
|
+
switch rawValue {
|
|
15
|
+
case "none":
|
|
16
|
+
self = .None
|
|
17
|
+
case "transparent":
|
|
18
|
+
self = .Transparent
|
|
19
|
+
case "translucent":
|
|
20
|
+
self = .GlassMaterial
|
|
21
|
+
case "thick":
|
|
22
|
+
self = .ThickMaterial
|
|
23
|
+
case "regular":
|
|
24
|
+
self = .RegularMaterial
|
|
25
|
+
case "thin":
|
|
26
|
+
self = .ThinMaterial
|
|
27
|
+
default:
|
|
28
|
+
self = .None
|
|
29
|
+
}
|
|
30
|
+
}
|
|
10
31
|
}
|
|
11
32
|
|
|
12
33
|
struct CornerRadius: Codable {
|
|
@@ -18,6 +18,9 @@ struct OptionalClip<Content: View>: View {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
// zIndex() have some bug, so use zOrderBias to simulate zIndex effect
|
|
22
|
+
let zOrderBias = 0.001
|
|
23
|
+
|
|
21
24
|
struct SpatialWebViewUI: View {
|
|
22
25
|
@Environment(SpatialEntity.self) var ent: SpatialEntity
|
|
23
26
|
var body: some View {
|
|
@@ -38,7 +41,7 @@ struct SpatialWebViewUI: View {
|
|
|
38
41
|
let view = childWindowcomponent
|
|
39
42
|
let x = CGFloat(e.modelEntity.position.x)
|
|
40
43
|
let y = CGFloat(e.modelEntity.position.y - (view.scrollWithParent ? parentYOffset : 0))
|
|
41
|
-
let z = CGFloat(e.modelEntity.position.z)
|
|
44
|
+
let z = CGFloat(e.modelEntity.position.z) + (e.zIndex * zOrderBias)
|
|
42
45
|
let width = CGFloat(view.resolutionX)
|
|
43
46
|
let height = CGFloat(view.resolutionY)
|
|
44
47
|
let anchor = view.rotationAnchor
|
|
@@ -66,7 +69,6 @@ struct SpatialWebViewUI: View {
|
|
|
66
69
|
|
|
67
70
|
.position(x: x, y: y)
|
|
68
71
|
.offset(z: z)
|
|
69
|
-
.zIndex(e.zIndex)
|
|
70
72
|
.gesture(
|
|
71
73
|
DragGesture()
|
|
72
74
|
.onChanged { gesture in
|
|
@@ -178,7 +180,7 @@ struct SpatialWebViewUI: View {
|
|
|
178
180
|
.hidden(!ent.visible)
|
|
179
181
|
.ornament(attachmentAnchor: .scene(.bottomTrailing), contentAlignment: .bottomTrailing) {
|
|
180
182
|
if wv.isRootWebview() {
|
|
181
|
-
NavView(swc: wv)
|
|
183
|
+
NavView(swc: wv, navInfo: wv.navInfo)
|
|
182
184
|
}
|
|
183
185
|
}
|
|
184
186
|
}
|
|
@@ -3,6 +3,7 @@ import WebKit
|
|
|
3
3
|
|
|
4
4
|
struct NavView: View {
|
|
5
5
|
@State var swc: SpatialWindowComponent?
|
|
6
|
+
@StateObject var navInfo: NavInfo
|
|
6
7
|
@State var showUrl: Bool = true
|
|
7
8
|
@State private var showCopyTip = false
|
|
8
9
|
@State private var navWidth: CGFloat = 0
|
|
@@ -52,7 +53,7 @@ struct NavView: View {
|
|
|
52
53
|
HStack(spacing: 5) {
|
|
53
54
|
if showUrl {
|
|
54
55
|
Text(
|
|
55
|
-
|
|
56
|
+
navInfo.url
|
|
56
57
|
)
|
|
57
58
|
.padding()
|
|
58
59
|
.lineLimit(1)
|
|
@@ -64,7 +65,7 @@ struct NavView: View {
|
|
|
64
65
|
}
|
|
65
66
|
return AnyView(EmptyView())
|
|
66
67
|
})
|
|
67
|
-
.frame(width:
|
|
68
|
+
.frame(width: .maximum(300, texWidth))
|
|
68
69
|
Button(action: {
|
|
69
70
|
UIPasteboard.general.string = swc?.getURL()?.absoluteString ?? ""
|
|
70
71
|
showCopyTip = true
|