dc09-sensors #4
2 changed files with 22 additions and 4 deletions
|
@ -9,15 +9,19 @@ import androidx.compose.material3.ExperimentalMaterial3Api
|
|||
import androidx.compose.material3.FilterChip
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.platform.LocalConfiguration
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.navigation.NavController
|
||||
import ovh.plrapps.mapcompose.api.scale
|
||||
import ovh.plrapps.mapcompose.api.setScroll
|
||||
import ovh.plrapps.mapcompose.ui.MapUI
|
||||
import ru.nm17.narodmon.R
|
||||
import ru.nm17.narodmon.ui.elements.GenericNavScaffold
|
||||
|
@ -34,14 +38,20 @@ fun SensorsPage(navController: NavController) {
|
|||
var filter by remember { mutableStateOf(SensorsFilter.All) }
|
||||
|
||||
val scrConfig = LocalConfiguration.current
|
||||
val scrHalfHeight = scrConfig.screenHeightDp / 2
|
||||
val mapHeight = scrConfig.screenHeightDp / 3
|
||||
|
||||
LaunchedEffect(mapVM) {
|
||||
// TODO: Подгружать сохранённую позицию
|
||||
mapVM.state.setScroll(Offset(28702.6F, 14787.6F))
|
||||
mapVM.state.scale = 1.4658884F
|
||||
}
|
||||
|
||||
GenericNavScaffold(
|
||||
title = { Text(text = stringResource(R.string.sensors_page_title)) }
|
||||
) {
|
||||
Column(modifier = Modifier.padding(it)) {
|
||||
|
||||
MapUI(state = mapVM.state, modifier = Modifier.height(scrHalfHeight.dp))
|
||||
MapUI(state = mapVM.state, modifier = Modifier.height(mapHeight.dp))
|
||||
|
||||
Row(
|
||||
modifier = Modifier.padding(horizontal = 8.dp),
|
||||
|
@ -65,6 +75,9 @@ fun SensorsPage(navController: NavController) {
|
|||
updateFilter = { filter = SensorsFilter.Camera },
|
||||
)
|
||||
}
|
||||
|
||||
//Text(mapVM.state.scroll.toString())
|
||||
//Text(mapVM.state.scale.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import ovh.plrapps.mapcompose.api.addLayer
|
|||
import ovh.plrapps.mapcompose.core.TileStreamProvider
|
||||
import ovh.plrapps.mapcompose.ui.state.MapState
|
||||
import java.io.InputStream
|
||||
import java.net.URL
|
||||
|
||||
class MapViewModel : ViewModel() {
|
||||
private val client = HttpClient(CIO)
|
||||
|
@ -21,8 +20,14 @@ class MapViewModel : ViewModel() {
|
|||
requestTile(row, col, zoom)
|
||||
}
|
||||
|
||||
private val mapSize = 32768
|
||||
val state: MapState by mutableStateOf(
|
||||
MapState(4, 4096, 4096).apply {
|
||||
MapState(
|
||||
levelCount = 8,
|
||||
fullWidth = mapSize,
|
||||
fullHeight = mapSize,
|
||||
workerCount = 16,
|
||||
).apply {
|
||||
addLayer(tileStreamProvider)
|
||||
}
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue