Фильтр: Card-ы заменены на CheckBox+Text, создан датакласс для фильтров
This commit is contained in:
parent
2a318d551c
commit
d1e7b60378
1 changed files with 49 additions and 40 deletions
|
@ -10,7 +10,7 @@ import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
import androidx.compose.material3.AssistChip
|
import androidx.compose.material3.AssistChip
|
||||||
import androidx.compose.material3.Card
|
import androidx.compose.material3.Checkbox
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.FilterChip
|
import androidx.compose.material3.FilterChip
|
||||||
import androidx.compose.material3.ModalBottomSheet
|
import androidx.compose.material3.ModalBottomSheet
|
||||||
|
@ -21,7 +21,9 @@ import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.layout.VerticalAlignmentLine
|
||||||
import androidx.compose.ui.platform.LocalConfiguration
|
import androidx.compose.ui.platform.LocalConfiguration
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
@ -31,9 +33,7 @@ import ru.nm17.narodmon.R
|
||||||
import ru.nm17.narodmon.ui.elements.GenericNavScaffold
|
import ru.nm17.narodmon.ui.elements.GenericNavScaffold
|
||||||
import ru.nm17.narodmon.ui.elements.TileMap
|
import ru.nm17.narodmon.ui.elements.TileMap
|
||||||
|
|
||||||
enum class SensorsFilter {
|
data class SensorFilter(val stringRes: Int, val code: Int, var enabled: Boolean = false)
|
||||||
All, Thermometer, Camera,
|
|
||||||
}
|
|
||||||
|
|
||||||
@ExperimentalMaterial3Api
|
@ExperimentalMaterial3Api
|
||||||
@Composable
|
@Composable
|
||||||
|
@ -44,31 +44,37 @@ fun SensorsPage(navController: NavController) {
|
||||||
var filterShown by remember { mutableStateOf(false) }
|
var filterShown by remember { mutableStateOf(false) }
|
||||||
var filterMine by remember { mutableStateOf(false) }
|
var filterMine by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
val filterItems = listOf(
|
val filterItems = remember {
|
||||||
stringResource(R.string.filter_temp),
|
mutableListOf(
|
||||||
stringResource(R.string.filter_temp_water),
|
/* TODO:
|
||||||
stringResource(R.string.filter_temp_ground),
|
* Заменить `code` на настоящее значение
|
||||||
stringResource(R.string.filter_temp_dew_point),
|
* либо динамически его подгружать из ответа АПИ
|
||||||
stringResource(R.string.filter_humidity),
|
* (см. /appInit, ключ в жсоне: types.type) */
|
||||||
stringResource(R.string.filter_pressure),
|
SensorFilter(R.string.filter_temp, 0),
|
||||||
stringResource(R.string.filter_lightness),
|
SensorFilter(R.string.filter_temp_water, 1),
|
||||||
stringResource(R.string.filter_uv),
|
SensorFilter(R.string.filter_temp_ground, 2),
|
||||||
stringResource(R.string.filter_radiation),
|
SensorFilter(R.string.filter_temp_dew_point, 3),
|
||||||
stringResource(R.string.filter_rainfall),
|
SensorFilter(R.string.filter_humidity, 4),
|
||||||
stringResource(R.string.filter_dust),
|
SensorFilter(R.string.filter_pressure, 5),
|
||||||
stringResource(R.string.filter_wind_speed),
|
SensorFilter(R.string.filter_lightness, 6),
|
||||||
stringResource(R.string.filter_wind_direction),
|
SensorFilter(R.string.filter_uv, 7),
|
||||||
stringResource(R.string.filter_concentration),
|
SensorFilter(R.string.filter_radiation, 8),
|
||||||
stringResource(R.string.filter_power),
|
SensorFilter(R.string.filter_rainfall, 9),
|
||||||
stringResource(R.string.filter_voltage),
|
SensorFilter(R.string.filter_dust, 10),
|
||||||
stringResource(R.string.filter_amperage),
|
SensorFilter(R.string.filter_wind_speed, 11),
|
||||||
stringResource(R.string.filter_energy),
|
SensorFilter(R.string.filter_wind_direction, 12),
|
||||||
stringResource(R.string.filter_battery),
|
SensorFilter(R.string.filter_concentration, 13),
|
||||||
stringResource(R.string.filter_rxtx),
|
SensorFilter(R.string.filter_power, 14),
|
||||||
stringResource(R.string.filter_signal),
|
SensorFilter(R.string.filter_voltage, 15),
|
||||||
stringResource(R.string.filter_water_meter),
|
SensorFilter(R.string.filter_amperage, 16),
|
||||||
stringResource(R.string.filter_time),
|
SensorFilter(R.string.filter_energy, 17),
|
||||||
)
|
SensorFilter(R.string.filter_battery, 18),
|
||||||
|
SensorFilter(R.string.filter_rxtx, 19),
|
||||||
|
SensorFilter(R.string.filter_signal, 20),
|
||||||
|
SensorFilter(R.string.filter_water_meter, 21),
|
||||||
|
SensorFilter(R.string.filter_time, 22),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
val scrConfig = LocalConfiguration.current
|
val scrConfig = LocalConfiguration.current
|
||||||
val mapHeight = scrConfig.screenHeightDp / 3
|
val mapHeight = scrConfig.screenHeightDp / 3
|
||||||
|
@ -125,19 +131,22 @@ fun SensorsPage(navController: NavController) {
|
||||||
modifier = Modifier.padding(horizontal = 4.dp),
|
modifier = Modifier.padding(horizontal = 4.dp),
|
||||||
) {
|
) {
|
||||||
items(filterItems) {
|
items(filterItems) {
|
||||||
Card(
|
Row(
|
||||||
modifier = Modifier
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
.fillMaxWidth()
|
|
||||||
.clickable { }
|
|
||||||
) {
|
) {
|
||||||
Text(
|
Checkbox(
|
||||||
text = it,
|
checked = it.enabled,
|
||||||
fontSize = 18.sp,
|
onCheckedChange = { checked -> it.enabled = checked },
|
||||||
modifier = Modifier.padding(
|
|
||||||
horizontal = 8.dp,
|
|
||||||
vertical = 16.dp,
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Text(
|
||||||
|
text = stringResource(id = it.stringRes),
|
||||||
|
modifier = Modifier.clickable {
|
||||||
|
it.enabled = !it.enabled
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
Text(text = it.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue