Skip to content

Commit 5cd9f99

Browse files
committed
Change layout of Example02Zoom
1 parent 5164c9f commit 5cd9f99

2 files changed

Lines changed: 41 additions & 46 deletions

File tree

-2.62 MB
Loading

examples/Example02Zoom/src/main/kotlin/de/afarber/openmapview/example02zoom/MainActivity.kt

Lines changed: 41 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ import android.os.Bundle
1313
import androidx.activity.ComponentActivity
1414
import androidx.activity.compose.setContent
1515
import androidx.compose.foundation.layout.Box
16-
import androidx.compose.foundation.layout.Column
17-
import androidx.compose.foundation.layout.Spacer
1816
import androidx.compose.foundation.layout.fillMaxSize
19-
import androidx.compose.foundation.layout.height
2017
import androidx.compose.foundation.layout.padding
2118
import androidx.compose.material3.FloatingActionButton
2219
import androidx.compose.material3.MaterialTheme
@@ -80,53 +77,51 @@ fun MapViewScreen() {
8077
modifier = Modifier.fillMaxSize(),
8178
)
8279

83-
// Zoom controls overlay
84-
Column(
80+
// Zoom level title at the top
81+
Surface(
8582
modifier = Modifier
86-
.align(Alignment.BottomEnd)
87-
.padding(bottom = 16.dp),
83+
.align(Alignment.TopCenter)
84+
.padding(top = 16.dp),
85+
color = MaterialTheme.colorScheme.surface.copy(alpha = 0.9f),
86+
shape = MaterialTheme.shapes.small,
8887
) {
89-
// Zoom level display
90-
Surface(
91-
color = MaterialTheme.colorScheme.surface.copy(alpha = 0.9f),
92-
shape = MaterialTheme.shapes.small,
93-
) {
94-
Text(
95-
text = "Zoom: ${zoomLevel.roundToInt()}",
96-
modifier = Modifier.padding(12.dp),
97-
style = MaterialTheme.typography.bodyMedium,
98-
)
99-
}
100-
101-
Spacer(modifier = Modifier.height(8.dp))
102-
103-
// Zoom in button
104-
FloatingActionButton(
105-
onClick = {
106-
mapView?.let {
107-
val newZoom = (it.getZoom() + 1.0).coerceAtMost(19.0)
108-
it.setZoom(newZoom)
109-
zoomLevel = newZoom
110-
}
111-
},
112-
) {
113-
Text("+", style = MaterialTheme.typography.headlineMedium)
114-
}
88+
Text(
89+
text = "Zoom: ${zoomLevel.roundToInt()}",
90+
modifier = Modifier.padding(horizontal = 16.dp, vertical = 12.dp),
91+
style = MaterialTheme.typography.titleMedium,
92+
)
93+
}
11594

116-
Spacer(modifier = Modifier.height(8.dp))
95+
// Zoom in button
96+
FloatingActionButton(
97+
onClick = {
98+
mapView?.let {
99+
val newZoom = (it.getZoom() + 1.0).coerceAtMost(19.0)
100+
it.setZoom(newZoom)
101+
zoomLevel = newZoom
102+
}
103+
},
104+
modifier = Modifier
105+
.align(Alignment.BottomEnd)
106+
.padding(end = 16.dp, bottom = 88.dp),
107+
) {
108+
Text("+", style = MaterialTheme.typography.headlineMedium)
109+
}
117110

118-
// Zoom out button
119-
FloatingActionButton(
120-
onClick = {
121-
mapView?.let {
122-
val newZoom = (it.getZoom() - 1.0).coerceAtLeast(2.0)
123-
it.setZoom(newZoom)
124-
zoomLevel = newZoom
125-
}
126-
},
127-
) {
128-
Text("-", style = MaterialTheme.typography.headlineMedium)
129-
}
111+
// Zoom out button
112+
FloatingActionButton(
113+
onClick = {
114+
mapView?.let {
115+
val newZoom = (it.getZoom() - 1.0).coerceAtLeast(2.0)
116+
it.setZoom(newZoom)
117+
zoomLevel = newZoom
118+
}
119+
},
120+
modifier = Modifier
121+
.align(Alignment.BottomEnd)
122+
.padding(end = 16.dp, bottom = 16.dp),
123+
) {
124+
Text("-", style = MaterialTheme.typography.headlineMedium)
130125
}
131126
}
132127
}

0 commit comments

Comments
 (0)