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 1 commit
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 @@ -32,6 +32,7 @@ import androidx.compose.ui.viewinterop.AndroidView
import com.arcgismaps.mapping.ArcGISScene
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 All @@ -57,6 +58,7 @@ import kotlinx.coroutines.launch
* @param viewLabelProperties the [ViewLabelProperties] used by the composable SceneView
* @param attributionState specifies the attribution bar's visibility, text changed and layout changed events
* @param onNavigationChanged lambda invoked when the navigation status 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
Expand All @@ -80,6 +82,7 @@ public fun SceneView(
viewLabelProperties: ViewLabelProperties = ViewLabelProperties(),
attributionState: AttributionState = AttributionState(),
onNavigationChanged: ((isNavigating: Boolean) -> Unit)? = null,
onLayerViewStateChanged: ((GeoView.GeoViewLayerViewStateChanged) -> Unit)? = null,
onInteractingChanged: ((isInteracting: Boolean) -> Unit)? = null,
onRotate: ((RotationChangeEvent) -> Unit)? = null,
onScale: ((ScaleChangeEvent) -> Unit)? = null,
Expand Down Expand Up @@ -128,6 +131,7 @@ public fun SceneView(
SceneViewEventHandler(
sceneView,
onNavigationChanged,
onLayerViewStateChanged,
onInteractingChanged,
onRotate,
onScale,
Expand Down Expand Up @@ -164,6 +168,7 @@ private fun ViewpointUpdater(
private fun SceneViewEventHandler(
sceneView: SceneView,
onNavigationChanged: ((isNavigating: Boolean) -> Unit)?,
onLayerViewStateChanged: ((GeoView.GeoViewLayerViewStateChanged) -> Unit)?,
onInteractingChanged: ((isInteracting: Boolean) -> Unit)?,
onRotate: ((RotationChangeEvent) -> Unit)?,
onScale: ((ScaleChangeEvent) -> Unit)?,
Expand All @@ -176,6 +181,7 @@ private fun SceneViewEventHandler(
onPan: ((PanChangeEvent) -> Unit)?,
) {
val currentOnNavigationChanged by rememberUpdatedState(onNavigationChanged)
val currentOnLayerViewStateChanged by rememberUpdatedState(onLayerViewStateChanged)
val currentOnInteractingChanged by rememberUpdatedState(onInteractingChanged)
val currentOnRotate by rememberUpdatedState(onRotate)
val currentOnScale by rememberUpdatedState(onScale)
Expand All @@ -193,6 +199,11 @@ private fun SceneViewEventHandler(
currentOnNavigationChanged?.invoke(it)
}
}
launch {
sceneView.layerViewStateChanged.collect { currentLayerViewState ->
currentOnLayerViewStateChanged?.invoke(currentLayerViewState)
}
}
launch(Dispatchers.Main.immediate) {
sceneView.isInteracting.collect { isInteracting ->
currentOnInteractingChanged?.invoke(isInteracting)
Expand Down