Skip to content

Geo-compose: add basic SceneView function #230

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
merged 4 commits into from
Dec 14, 2023
Merged
Changes from 3 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
@@ -0,0 +1,61 @@
/*
* Copyright 2023 Esri
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.arcgismaps.toolkit.geocompose

This comment was marked as resolved.


import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.viewinterop.AndroidView
import com.arcgismaps.mapping.ArcGISScene

/**
* A compose equivalent of the view-based [com.arcgismaps.mapping.view.SceneView].
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In composable mapview we have added the import for view-based mapview. we should do the same here.

Suggested change
* A compose equivalent of the view-based [com.arcgismaps.mapping.view.SceneView].
* A compose equivalent of the view-based [SceneView].

*
* @param modifier Modifier to be applied to the composable SceneView
* @param arcGISScene the [ArcGISScene] to be rendered by this composable SceneView
* @since 200.4.0
*/
@Composable
public fun SceneView(
modifier: Modifier = Modifier,
arcGISScene: ArcGISScene? = null
) {
val lifecycleOwner = LocalLifecycleOwner.current
val context = LocalContext.current
val sceneView = remember { com.arcgismaps.mapping.view.SceneView(context) }

AndroidView(
modifier = modifier.semantics { contentDescription = "SceneView" },
factory = { sceneView },
update = {
it.scene = arcGISScene
})

DisposableEffect(Unit) {
lifecycleOwner.lifecycle.addObserver(sceneView)
onDispose {
lifecycleOwner.lifecycle.removeObserver(sceneView)
sceneView.onDestroy(lifecycleOwner)
}
}
}