Skip to content
Merged
Changes from all 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
@@ -1,5 +1,8 @@
package com.mapconductor.example.pages.circle

import kotlinx.coroutines.delay
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.foundation.background
import androidx.annotation.DrawableRes
import androidx.compose.foundation.Image
import androidx.compose.foundation.border
Expand Down Expand Up @@ -213,6 +216,12 @@ fun AntennaHorizonsPage(
}
}
}
adding?.let { (added, total) ->
DrawingOverlay(
if (total == 0) "Drawing the map…" else "Adding to the map… $added / $total",
Modifier.padding(top = padding.calculateTopPadding()),
)
}
}
Card(Modifier.fillMaxWidth().padding(12.dp)) {
Column(Modifier.padding(12.dp)) {
Expand All @@ -221,7 +230,8 @@ fun AntennaHorizonsPage(
error
?: if (rows.isEmpty()) "Loading OpenCellID data…" else "${states.size} / ${rows.size} circles",
)
adding?.let { (added, total) -> Text("Adding to the map… $added / $total") }
// total is 0 when nothing new is added: a filter that only hides cells, or the camera moving.
adding?.let { (added, total) -> Text(if (total == 0) "Drawing the map…" else "Adding to the map… $added / $total") }
TextButton(onClick = { alaska = !alaska }) { Text(if (alaska) "US overview" else "Alaska") }
Row(Modifier.padding(vertical = 8.dp), horizontalArrangement = Arrangement.spacedBy(6.dp)) {
carrierNames.forEachIndexed { index, name ->
Expand Down Expand Up @@ -304,3 +314,34 @@ private fun CarrierToggle(
Text(name, style = MaterialTheme.typography.labelSmall, textAlign = TextAlign.Center)
}
}

/**
* Over the map while circles are added or their tiles drawn (between onAddStart
* and onAddEnd). Shown after 150 ms, as the web sample's overlay is, so that a
* short redraw does not flash; it does not take touches, so the map can still
* be moved while it draws.
*/
@Composable
private fun DrawingOverlay(
text: String,
modifier: Modifier = Modifier,
) {
var visible by remember { mutableStateOf(false) }
LaunchedEffect(Unit) {
delay(150)
visible = true
}
if (!visible) return
Box(modifier.fillMaxSize().background(Color(0x330F172A)), contentAlignment = Alignment.Center) {
Card {
Column(
Modifier.padding(horizontal = 20.dp, vertical = 16.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(10.dp),
) {
CircularProgressIndicator(modifier = Modifier.size(28.dp), strokeWidth = 3.dp)
Text(text, style = MaterialTheme.typography.bodyMedium)
}
}
}
}