Skip to content

Commit 4c26838

Browse files
authored
SceneView: create SceneViewProxy (#246)
* create initial SceneViewProxy class * add disposal logic to proxy class * add sceneViewProxy to SceneView * add copyright
1 parent 6c33b06 commit 4c26838

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

toolkit/geo-compose/src/main/java/com/arcgismaps/toolkit/geocompose/SceneView.kt

+9
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import kotlinx.coroutines.launch
4848
*
4949
* @param modifier Modifier to be applied to the composable SceneView
5050
* @param arcGISScene the [ArcGISScene] to be rendered by this composable SceneView
51+
* @param sceneViewProxy the [SceneViewProxy] to associate with the composable SceneView
5152
* @param onInteractingChanged lambda invoked when the user starts and ends interacting with the composable SceneView
5253
* @param onRotate lambda invoked when a user performs a rotation gesture on the composable SceneView
5354
* @param onScale lambda invoked when a user performs a pinch gesture on the composable SceneView
@@ -64,6 +65,7 @@ import kotlinx.coroutines.launch
6465
public fun SceneView(
6566
modifier: Modifier = Modifier,
6667
arcGISScene: ArcGISScene? = null,
68+
sceneViewProxy: SceneViewProxy? = null,
6769
onInteractingChanged: ((isInteracting: Boolean) -> Unit)? = null,
6870
onRotate: ((RotationChangeEvent) -> Unit)? = null,
6971
onScale: ((ScaleChangeEvent) -> Unit)? = null,
@@ -94,6 +96,13 @@ public fun SceneView(
9496
}
9597
}
9698

99+
DisposableEffect(sceneViewProxy) {
100+
sceneViewProxy?.setSceneView(sceneView)
101+
onDispose {
102+
sceneViewProxy?.setSceneView(null)
103+
}
104+
}
105+
97106
SceneViewEventHandler(
98107
sceneView,
99108
onInteractingChanged,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright 2023 Esri
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
package com.arcgismaps.toolkit.geocompose
19+
20+
/**
21+
* Used to perform operations on a composable [SceneView].
22+
*
23+
* There should be a one-to-one relationship between a SceneViewProxy and a composable [SceneView]. This
24+
* relationship is established by passing an instance of SceneViewProxy to the composable [SceneView] function.
25+
* Operations can only be performed once the associated composable SceneView has entered the composition.
26+
* Operations performed when the associated composable SceneView is not in the composition will fail gracefully,
27+
* i.e. won't throw exceptions but won't return a successful result.
28+
*
29+
* @since 200.4.0
30+
*/
31+
public class SceneViewProxy : GeoViewProxy("SceneView") {
32+
/**
33+
* The view-based [com.arcgismaps.mapping.view.SceneView] that this SceneViewProxy will operate on. This should
34+
* be initialized by the composable [SceneView] when it enters the composition and set to null when
35+
* it is disposed by calling [setSceneView].
36+
*
37+
* @since 200.4.0
38+
*/
39+
private var sceneView: com.arcgismaps.mapping.view.SceneView? = null
40+
set(value) {
41+
setGeoView(value)
42+
}
43+
44+
/**
45+
* Sets the [sceneView] parameter on this operator. This should be called by the composable [SceneView]
46+
* when it enters the composition and set to null when it is disposed.
47+
*
48+
* @since 200.4.0
49+
*/
50+
internal fun setSceneView(sceneView: com.arcgismaps.mapping.view.SceneView?) {
51+
this.sceneView = sceneView
52+
}
53+
}

0 commit comments

Comments
 (0)