Skip to content

SceneView: Add onLayerViewStateChanged #262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import com.arcgismaps.mapping.ArcGISScene
import com.arcgismaps.mapping.TimeExtent
import com.arcgismaps.mapping.view.DoubleTapEvent
import com.arcgismaps.mapping.view.DownEvent
import com.arcgismaps.mapping.view.GeoView
import com.arcgismaps.mapping.view.LongPressEvent
import com.arcgismaps.mapping.view.PanChangeEvent
import com.arcgismaps.mapping.view.RotationChangeEvent
Expand Down Expand Up @@ -64,8 +65,9 @@ import kotlinx.coroutines.launch
* @param timeExtent the [TimeExtent] used by the composable SceneView
* @param onTimeExtentChanged lambda invoked when the composable SceneView's [TimeExtent] is changed
* @param onNavigationChanged lambda invoked when the navigation status of the composable SceneView has changed
* @param onInteractingChanged lambda invoked when the user starts and ends interacting with the composable SceneView
* @param onSpatialReferenceChanged lambda invoked when the spatial reference of the composable SceneView has changed
* @param onLayerViewStateChanged lambda invoked when the composable SceneView's layer view state is changed
* @param onInteractingChanged lambda invoked when the user starts and ends interacting with the composable SceneView
* @param onRotate lambda invoked when a user performs a rotation gesture on the composable SceneView
* @param onScale lambda invoked when a user performs a pinch gesture on the composable SceneView
* @param onUp lambda invoked when the user removes all their pointers from the composable SceneView
Expand Down Expand Up @@ -93,6 +95,7 @@ public fun SceneView(
onTimeExtentChanged: ((TimeExtent?) -> Unit)? = null,
onNavigationChanged: ((isNavigating: Boolean) -> Unit)? = null,
onSpatialReferenceChanged: ((spatialReference: SpatialReference?) -> Unit)? = null,
onLayerViewStateChanged: ((GeoView.GeoViewLayerViewStateChanged) -> Unit)? = null,
onInteractingChanged: ((isInteracting: Boolean) -> Unit)? = null,
onRotate: ((RotationChangeEvent) -> Unit)? = null,
onScale: ((ScaleChangeEvent) -> Unit)? = null,
Expand Down Expand Up @@ -145,8 +148,9 @@ public fun SceneView(
sceneView,
onTimeExtentChanged,
onNavigationChanged,
onInteractingChanged,
onSpatialReferenceChanged,
onLayerViewStateChanged,
onInteractingChanged,
onRotate,
onScale,
onUp,
Expand Down Expand Up @@ -183,8 +187,9 @@ private fun SceneViewEventHandler(
sceneView: SceneView,
onTimeExtentChanged: ((TimeExtent?) -> Unit)? = null,
onNavigationChanged: ((isNavigating: Boolean) -> Unit)?,
onInteractingChanged: ((isInteracting: Boolean) -> Unit)?,
onSpatialReferenceChanged: ((spatialReference: SpatialReference?) -> Unit)?,
onLayerViewStateChanged: ((GeoView.GeoViewLayerViewStateChanged) -> Unit)?,
onInteractingChanged: ((isInteracting: Boolean) -> Unit)?,
onRotate: ((RotationChangeEvent) -> Unit)?,
onScale: ((ScaleChangeEvent) -> Unit)?,
onUp: ((UpEvent) -> Unit)?,
Expand All @@ -197,8 +202,9 @@ private fun SceneViewEventHandler(
) {
val currentOnTimeExtentChanged by rememberUpdatedState(onTimeExtentChanged)
val currentOnNavigationChanged by rememberUpdatedState(onNavigationChanged)
val currentOnInteractingChanged by rememberUpdatedState(onInteractingChanged)
val currentOnSpatialReferenceChanged by rememberUpdatedState(onSpatialReferenceChanged)
val currentOnLayerViewStateChanged by rememberUpdatedState(onLayerViewStateChanged)
val currentOnInteractingChanged by rememberUpdatedState(onInteractingChanged)
val currentOnRotate by rememberUpdatedState(onRotate)
val currentOnScale by rememberUpdatedState(onScale)
val currentOnUp by rememberUpdatedState(onUp)
Expand All @@ -225,6 +231,11 @@ private fun SceneViewEventHandler(
currentOnSpatialReferenceChanged?.invoke(spatialReference)
}
}
launch {
sceneView.layerViewStateChanged.collect { currentLayerViewState ->
currentOnLayerViewStateChanged?.invoke(currentLayerViewState)
}
}
launch(Dispatchers.Main.immediate) {
sceneView.isInteracting.collect { isInteracting ->
currentOnInteractingChanged?.invoke(isInteracting)
Expand Down