Skip to content
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

Update SnapGeometryEdits #201

Merged
merged 4 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[versions]
# ArcGIS Maps SDK for Kotlin version
arcgisMapsKotlinVersion = "200.5.0-4223"
arcgisMapsKotlinVersion = "200.5.0-4244"
# SDK versions
compileSdk = "34"
minSdk = "26"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ class MapViewModel(
*/
init {
sampleCoroutineScope.launch {
// set the feature layer's feature tiling mode
// set the id for the graphics overlay
graphicsOverlay.id = "Editor Graphics Overlay"
// set the feature layer's tiling mode
map.loadSettings.featureTilingMode =
FeatureTilingMode.EnabledWithFullResolutionWhenSupported
// load the map
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ fun MainScreen(sampleName: String) {
val graphicsOverlayCollection = listOf(mapViewModel.graphicsOverlay)

Scaffold(
topBar = { SampleTopAppBar(title = sampleName) },
content = {
Column(
modifier = Modifier
.fillMaxSize()
.padding(it)
) {
SampleTopAppBar(title = sampleName)
MapView(
modifier = Modifier
.fillMaxSize()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.arcgismaps.geometry.GeometryType
import com.arcgismaps.mapping.layers.FeatureLayer
import com.arcgismaps.mapping.view.GraphicsOverlay
import com.arcgismaps.mapping.view.geometryeditor.SnapSourceSettings
import com.esri.arcgismaps.sample.sampleslib.theme.SampleTypography

Expand Down Expand Up @@ -126,117 +127,102 @@ fun SnapSettings(
}
}
}
Row(
modifier = Modifier
.fillMaxWidth()
.padding(20.dp, 10.dp, 20.dp, 10.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween
) {
Text(
style = SampleTypography.titleMedium,
text = "Point Layers",
color = MaterialTheme.colorScheme.primary
)
TextButton(
onClick = {
snapSourceList.value.forEachIndexed { index, snapSource ->
if ((snapSource.source as FeatureLayer).featureTable?.geometryType == GeometryType.Point) {
onSnapSourceChanged(true, index)
}
}
}
) {
Text(text = "Enable All Sources")
SetupSnapSourceUI(snapSourceList, isSnapSourceEnabled, onSnapSourceChanged, GeometryType.Point)
SetupSnapSourceUI(snapSourceList, isSnapSourceEnabled, onSnapSourceChanged, GeometryType.Polyline)
SetupSnapSourceUI(snapSourceList, isSnapSourceEnabled, onSnapSourceChanged, null)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice 👍

}
}
}

@Composable
fun SetupSnapSourceUI(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Better to make this a noun, ie. SnapSourceUI

snapSourceList: State<List<SnapSourceSettings>>,
isSnapSourceEnabled: List<Boolean>,
onSnapSourceChanged: (Boolean, Int) -> Unit,
geometryType : GeometryType?
) {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(20.dp, 10.dp, 20.dp, 10.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween
) {
Text(
style = SampleTypography.titleMedium,
text = when (geometryType) {
is GeometryType.Point -> "Point Layer"
is GeometryType.Polyline -> "Polyline Layer"
else -> "Graphics Overlays"
},
color = MaterialTheme.colorScheme.primary
)
TextButton(
onClick = {
snapSourceList.value.forEachIndexed { index, snapSource ->
if ((snapSource.source as? FeatureLayer)?.featureTable?.geometryType == geometryType) {
onSnapSourceChanged(true, index)
} else if (geometryType == null && snapSource.source is GraphicsOverlay) {
onSnapSourceChanged(true, index)
}
}
Surface(
modifier = Modifier.padding(20.dp, 0.dp, 20.dp, 10.dp),
tonalElevation = 1.dp,
shape = RoundedCornerShape(20.dp),
border = BorderStroke(1.dp, MaterialTheme.colorScheme.outlineVariant)
) {
Column(
modifier = Modifier.padding(14.dp)
) {
Column {
snapSourceList.value.forEachIndexed { index, snapSource ->
if ((snapSource.source as FeatureLayer).featureTable?.geometryType == GeometryType.Point) {
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween
) {
Text(
modifier = Modifier.padding(20.dp, 0.dp, 0.dp, 0.dp),
text = (snapSource.source as FeatureLayer).name
)
Switch(
checked = isSnapSourceEnabled[index],
onCheckedChange = { newValue ->
onSnapSourceChanged(newValue, index)
}
)
}
}
}
}
}
}
) {
Text(
text = if (geometryType != null) {
"Enable All Layers"
} else {
"Enable All Overlays"
}
Row(
modifier = Modifier
.fillMaxWidth()
.padding(20.dp, 0.dp, 20.dp, 10.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween
) {
Text(
style = SampleTypography.titleMedium,
text = "Polyline Layers",
color = MaterialTheme.colorScheme.primary
)
TextButton(
onClick = {
snapSourceList.value.forEachIndexed { index, snapSource ->
if ((snapSource.source as FeatureLayer).featureTable?.geometryType == GeometryType.Polyline) {
onSnapSourceChanged(true, index)
)
}
}
Surface(
modifier = Modifier.padding(20.dp, 0.dp, 20.dp, 10.dp),
tonalElevation = 1.dp,
shape = RoundedCornerShape(20.dp),
border = BorderStroke(1.dp, MaterialTheme.colorScheme.outlineVariant)
) {
Column(
modifier = Modifier.padding(14.dp)
) {
Column {
snapSourceList.value.forEachIndexed { index, snapSource ->
if (geometryType != null &&
(snapSource.source as? FeatureLayer)?.featureTable?.geometryType == geometryType) {
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween
) {
Text(
modifier = Modifier.padding(20.dp, 0.dp, 0.dp, 0.dp),
text = (snapSource.source as FeatureLayer).name
)
Switch(
checked = isSnapSourceEnabled[index],
onCheckedChange = { newValue ->
onSnapSourceChanged(newValue, index)
}
}
)
}
) {
Text(text = "Enable All Sources")
}
}
Surface(
modifier = Modifier.padding(20.dp, 0.dp, 20.dp, 10.dp),
tonalElevation = 1.dp,
shape = RoundedCornerShape(20.dp),
border = BorderStroke(1.dp, MaterialTheme.colorScheme.outlineVariant)
) {
Column(
modifier = Modifier.padding(14.dp)
) {
Column {
snapSourceList.value.forEachIndexed { index, snapSource ->
if ((snapSource.source as FeatureLayer).featureTable?.geometryType == GeometryType.Polyline) {
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween
) {
Text(
modifier = Modifier.padding(20.dp, 0.dp, 0.dp, 0.dp),
text = (snapSource.source as FeatureLayer).name
)
Switch(
checked = isSnapSourceEnabled[index],
onCheckedChange = { newValue ->
onSnapSourceChanged(newValue, index)
}
)
}
} else if (geometryType == null && snapSource.source is GraphicsOverlay) {
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween
) {
Text(
modifier = Modifier.padding(20.dp, 0.dp, 0.dp, 0.dp),
text = (snapSource.source as GraphicsOverlay).id
)
Switch(
checked = isSnapSourceEnabled[index],
onCheckedChange = { newValue ->
onSnapSourceChanged(newValue, index)
}
}
)
}
}
}
Expand Down
Loading