From 1334014c04cacaebd34166cbd2801fada608317a Mon Sep 17 00:00:00 2001 From: DarkCat09 Date: Tue, 6 Jun 2023 15:50:55 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B5=D0=B1=D0=BE=D0=BB=D1=8C=D1=88?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=B2=20UI=20=D1=8D=D0=BA=D1=80=D0=B0=D0=BD=D0=B0=20?= =?UTF-8?q?=D1=81=D0=B5=D0=BD=D1=81=D0=BE=D1=80=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/ru/nm17/narodmon/ui/pages/Sensors.kt | 57 +++++++------------ app/src/main/res/values/strings.xml | 2 + 2 files changed, 23 insertions(+), 36 deletions(-) diff --git a/app/src/main/java/ru/nm17/narodmon/ui/pages/Sensors.kt b/app/src/main/java/ru/nm17/narodmon/ui/pages/Sensors.kt index 8ff760f..d08d804 100644 --- a/app/src/main/java/ru/nm17/narodmon/ui/pages/Sensors.kt +++ b/app/src/main/java/ru/nm17/narodmon/ui/pages/Sensors.kt @@ -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) }, - ) } \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e6c67e6..037d8ed 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -18,4 +18,6 @@ Все Термометры Камеры + Поиск + Фильтр \ No newline at end of file