Добавлен BottomSheet для фильтров и строки

This commit is contained in:
DarkCat09 2023-06-06 17:12:20 +04:00
parent 1334014c04
commit 3a873725f2
2 changed files with 74 additions and 4 deletions

View file

@ -8,6 +8,8 @@ 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.AssistChip
import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FilterChip
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.SearchBar 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
@ -34,6 +36,35 @@ fun SensorsPage(navController: NavController) {
var searchQuery by remember { mutableStateOf("") } var searchQuery by remember { mutableStateOf("") }
var searchActive by remember { mutableStateOf(false) } var searchActive by remember { mutableStateOf(false) }
var filterShown by remember { mutableStateOf(false) }
var filterMine by remember { mutableStateOf(false) }
val filterItems = listOf<String>(
stringResource(R.string.filter_temp),
stringResource(R.string.filter_temp_water),
stringResource(R.string.filter_temp_ground),
stringResource(R.string.filter_temp_dew_point),
stringResource(R.string.filter_humidity),
stringResource(R.string.filter_pressure),
stringResource(R.string.filter_lightness),
stringResource(R.string.filter_uv),
stringResource(R.string.filter_radiation),
stringResource(R.string.filter_rainfall),
stringResource(R.string.filter_dust),
stringResource(R.string.filter_wind_speed),
stringResource(R.string.filter_wind_direction),
stringResource(R.string.filter_concentration),
stringResource(R.string.filter_power),
stringResource(R.string.filter_voltage),
stringResource(R.string.filter_amperage),
stringResource(R.string.filter_energy),
stringResource(R.string.filter_battery),
stringResource(R.string.filter_rxtx),
stringResource(R.string.filter_signal),
stringResource(R.string.filter_water_meter),
stringResource(R.string.filter_time),
)
val scrConfig = LocalConfiguration.current val scrConfig = LocalConfiguration.current
val mapHeight = scrConfig.screenHeightDp / 3 val mapHeight = scrConfig.screenHeightDp / 3
@ -61,10 +92,27 @@ fun SensorsPage(navController: NavController) {
modifier = Modifier.padding(horizontal = 8.dp), modifier = Modifier.padding(horizontal = 8.dp),
) { ) {
AssistChip( AssistChip(
onClick = { }, onClick = { filterShown = true },
label = { Text(text = stringResource(R.string.sensors_filter)) }, label = { Text(text = stringResource(R.string.sensors_filter)) },
) )
AssistChip(
onClick = { },
label = { Text(text = stringResource(R.string.sensors_sorting)) },
)
FilterChip(
selected = filterMine,
onClick = { filterMine = !filterMine },
label = { Text(text = stringResource(R.string.sensors_mine)) },
)
} }
} }
} }
if (filterShown) {
ModalBottomSheet(onDismissRequest = { filterShown = false }) {
Text(text = "Hello")
}
}
} }

View file

@ -15,9 +15,31 @@
<string name="agreement_dialog_title">Примите необходимые соглашения</string> <string name="agreement_dialog_title">Примите необходимые соглашения</string>
<string name="sensors_page_title">Сенсоры</string> <string name="sensors_page_title">Сенсоры</string>
<string name="waiting_for_user_agreement">Ожидаю соглашение пользователя</string> <string name="waiting_for_user_agreement">Ожидаю соглашение пользователя</string>
<string name="sensors_filter_all">Все</string>
<string name="sensors_filter_temp">Термометры</string>
<string name="sensors_filter_camera">Камеры</string>
<string name="search">Поиск</string> <string name="search">Поиск</string>
<string name="sensors_filter">Фильтр</string> <string name="sensors_filter">Фильтр</string>
<string name="sensors_sorting">Сортировка</string>
<string name="sensors_mine">Мои</string>
<string name="filter_temp_dew_point">Температура точки росы</string>
<string name="filter_temp">Температура воздуха</string>
<string name="filter_temp_water">Температура воды</string>
<string name="filter_temp_ground">Температура почвы</string>
<string name="filter_humidity">Влажность</string>
<string name="filter_pressure">Давление</string>
<string name="filter_lightness">Освещённость</string>
<string name="filter_uv">УФ-индекс</string>
<string name="filter_radiation">Радиация</string>
<string name="filter_rainfall">Осадки</string>
<string name="filter_dust">Запылённость</string>
<string name="filter_wind_speed">Скорость ветра</string>
<string name="filter_wind_direction">Направление ветра</string>
<string name="filter_concentration">Концентрация</string>
<string name="filter_power">Мощность</string>
<string name="filter_voltage">Напряжение</string>
<string name="filter_amperage">Сила тока</string>
<string name="filter_energy">Энергия</string>
<string name="filter_battery">% батареи</string>
<string name="filter_rxtx">Rx/Tx трафик</string>
<string name="filter_signal">Сигнал в dBm</string>
<string name="filter_water_meter">Счётчик воды</string>
<string name="filter_time">Время работы</string>
</resources> </resources>