Небольшие изменения в UI экрана сенсоров
This commit is contained in:
parent
06bc8a839e
commit
1334014c04
2 changed files with 23 additions and 36 deletions
|
@ -3,10 +3,12 @@ package ru.nm17.narodmon.ui.pages
|
|||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.AssistChip
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.FilterChip
|
||||
import androidx.compose.material3.SearchBar
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
|
@ -29,7 +31,8 @@ enum class SensorsFilter {
|
|||
@ExperimentalMaterial3Api
|
||||
@Composable
|
||||
fun SensorsPage(navController: NavController) {
|
||||
var filter by remember { mutableStateOf(SensorsFilter.All) }
|
||||
var searchQuery by remember { mutableStateOf("") }
|
||||
var searchActive by remember { mutableStateOf(false) }
|
||||
|
||||
val scrConfig = LocalConfiguration.current
|
||||
val mapHeight = scrConfig.screenHeightDp / 3
|
||||
|
@ -41,45 +44,27 @@ fun SensorsPage(navController: NavController) {
|
|||
|
||||
TileMap(modifier = Modifier.height(mapHeight.dp))
|
||||
|
||||
SearchBar(
|
||||
query = searchQuery,
|
||||
active = searchActive,
|
||||
onActiveChange = { active -> searchActive = active },
|
||||
onQueryChange = { query -> searchQuery = query },
|
||||
onSearch = { searchActive = false },
|
||||
placeholder = { Text(stringResource(R.string.search)) },
|
||||
modifier = Modifier
|
||||
//.padding(horizontal = 8.dp)
|
||||
.fillMaxWidth()
|
||||
) {}
|
||||
|
||||
Row(
|
||||
modifier = Modifier.padding(horizontal = 8.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
modifier = Modifier.padding(horizontal = 8.dp),
|
||||
) {
|
||||
SensorsFilterChip(
|
||||
name = stringResource(R.string.sensors_filter_all),
|
||||
checkFilter = { filter == SensorsFilter.All },
|
||||
updateFilter = { filter = SensorsFilter.All },
|
||||
)
|
||||
|
||||
SensorsFilterChip(
|
||||
name = stringResource(R.string.sensors_filter_temp),
|
||||
checkFilter = { filter == SensorsFilter.Thermometer },
|
||||
updateFilter = { filter = SensorsFilter.Thermometer },
|
||||
)
|
||||
|
||||
SensorsFilterChip(
|
||||
name = stringResource(R.string.sensors_filter_camera),
|
||||
checkFilter = { filter == SensorsFilter.Camera },
|
||||
updateFilter = { filter = SensorsFilter.Camera },
|
||||
AssistChip(
|
||||
onClick = { },
|
||||
label = { Text(text = stringResource(R.string.sensors_filter)) },
|
||||
)
|
||||
}
|
||||
|
||||
//Text(mapVM.state.scroll.toString())
|
||||
//Text(mapVM.state.scale.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun SensorsFilterChip(
|
||||
name: String,
|
||||
checkFilter: () -> Boolean,
|
||||
updateFilter: () -> Unit,
|
||||
) {
|
||||
FilterChip(
|
||||
selected = checkFilter(),
|
||||
onClick = updateFilter,
|
||||
label = { Text(name) },
|
||||
)
|
||||
}
|
|
@ -18,4 +18,6 @@
|
|||
<string name="sensors_filter_all">Все</string>
|
||||
<string name="sensors_filter_temp">Термометры</string>
|
||||
<string name="sensors_filter_camera">Камеры</string>
|
||||
<string name="search">Поиск</string>
|
||||
<string name="sensors_filter">Фильтр</string>
|
||||
</resources>
|
Loading…
Add table
Reference in a new issue