Skip to content

Commit e46afdc

Browse files
authored
Update ViewAnnotationActivity to showcase allowZElevate. (#2676)
1 parent 0b9c053 commit e46afdc

File tree

1 file changed

+31
-8
lines changed

1 file changed

+31
-8
lines changed

compose-app/src/main/java/com/mapbox/maps/compose/testapp/examples/annotation/ViewAnnotationActivity.kt

+31-8
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ import android.widget.Toast.LENGTH_SHORT
66
import androidx.activity.ComponentActivity
77
import androidx.activity.compose.setContent
88
import androidx.compose.animation.animateColorAsState
9+
import androidx.compose.foundation.layout.Column
910
import androidx.compose.foundation.layout.fillMaxSize
1011
import androidx.compose.foundation.layout.padding
1112
import androidx.compose.foundation.shape.RoundedCornerShape
1213
import androidx.compose.material.Button
1314
import androidx.compose.material.ButtonDefaults
1415
import androidx.compose.material.FloatingActionButton
16+
import androidx.compose.material.MaterialTheme
1517
import androidx.compose.material.Text
1618
import androidx.compose.runtime.getValue
1719
import androidx.compose.runtime.mutableStateOf
@@ -46,17 +48,35 @@ public class ViewAnnotationActivity : ComponentActivity() {
4648
var showViewAnnotation by remember {
4749
mutableStateOf(true)
4850
}
51+
var allowZElevate by remember {
52+
mutableStateOf(true)
53+
}
4954
val animatedColor by animateColorAsState(buttonColor, label = "ButtonAnnotationColor")
5055
MapboxMapComposeTheme {
5156
ExampleScaffold(
5257
floatingActionButton = {
53-
FloatingActionButton(
54-
onClick = {
55-
showViewAnnotation = !showViewAnnotation
56-
},
57-
shape = RoundedCornerShape(16.dp),
58-
) {
59-
Text(modifier = Modifier.padding(10.dp), text = "Toggle Visibility")
58+
Column {
59+
FloatingActionButton(
60+
modifier = Modifier.padding(bottom = 10.dp),
61+
onClick = {
62+
showViewAnnotation = !showViewAnnotation
63+
},
64+
shape = RoundedCornerShape(16.dp),
65+
) {
66+
Text(modifier = Modifier.padding(10.dp), text = "Toggle Visibility")
67+
}
68+
FloatingActionButton(
69+
modifier = Modifier.padding(bottom = 10.dp),
70+
backgroundColor = if (showViewAnnotation) MaterialTheme.colors.secondary else Color.LightGray,
71+
onClick = {
72+
if (showViewAnnotation) {
73+
allowZElevate = !allowZElevate
74+
}
75+
},
76+
shape = RoundedCornerShape(16.dp),
77+
) {
78+
Text(modifier = Modifier.padding(10.dp), text = "Toggle allowZElevate")
79+
}
6080
}
6181
}
6282
) {
@@ -65,6 +85,7 @@ public class ViewAnnotationActivity : ComponentActivity() {
6585
mapViewportState = rememberMapViewportState {
6686
setCameraOptions {
6787
zoom(ZOOM)
88+
pitch(PITCH)
6889
center(HELSINKI)
6990
}
7091
}
@@ -77,6 +98,7 @@ public class ViewAnnotationActivity : ComponentActivity() {
7798
anchor(ViewAnnotationAnchor.BOTTOM)
7899
}
79100
allowOverlap(false)
101+
allowZElevate(allowZElevate)
80102
}
81103
) {
82104
Button(
@@ -102,6 +124,7 @@ public class ViewAnnotationActivity : ComponentActivity() {
102124
}
103125

104126
private companion object {
105-
const val ZOOM: Double = 9.0
127+
const val ZOOM: Double = 16.0
128+
const val PITCH: Double = 60.0
106129
}
107130
}

0 commit comments

Comments
 (0)