Небольшие изменения в UI экрана сенсоров

This commit is contained in:
DarkCat09 2023-06-06 15:50:55 +04:00
parent 06bc8a839e
commit 1334014c04
2 changed files with 23 additions and 36 deletions

View file

@ -3,10 +3,12 @@ package ru.nm17.narodmon.ui.pages
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.material3.AssistChip
import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FilterChip import androidx.compose.material3.SearchBar
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
@ -29,7 +31,8 @@ enum class SensorsFilter {
@ExperimentalMaterial3Api @ExperimentalMaterial3Api
@Composable @Composable
fun SensorsPage(navController: NavController) { 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 scrConfig = LocalConfiguration.current
val mapHeight = scrConfig.screenHeightDp / 3 val mapHeight = scrConfig.screenHeightDp / 3
@ -41,45 +44,27 @@ fun SensorsPage(navController: NavController) {
TileMap(modifier = Modifier.height(mapHeight.dp)) 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( Row(
modifier = Modifier.padding(horizontal = 8.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp), horizontalArrangement = Arrangement.spacedBy(8.dp),
modifier = Modifier.padding(horizontal = 8.dp),
) { ) {
SensorsFilterChip( AssistChip(
name = stringResource(R.string.sensors_filter_all), onClick = { },
checkFilter = { filter == SensorsFilter.All }, label = { Text(text = stringResource(R.string.sensors_filter)) },
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 },
) )
} }
//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) },
)
}

View file

@ -18,4 +18,6 @@
<string name="sensors_filter_all">Все</string> <string name="sensors_filter_all">Все</string>
<string name="sensors_filter_temp">Термометры</string> <string name="sensors_filter_temp">Термометры</string>
<string name="sensors_filter_camera">Камеры</string> <string name="sensors_filter_camera">Камеры</string>
<string name="search">Поиск</string>
<string name="sensors_filter">Фильтр</string>
</resources> </resources>