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