dc09-sensors2 #5

Merged
nm17 merged 28 commits from dc09-sensors2 into master 2023-06-18 13:15:53 +03:00
Showing only changes of commit d1e7b60378 - Show all commits

View file

@ -10,7 +10,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.AssistChip
import androidx.compose.material3.Card
import androidx.compose.material3.Checkbox
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FilterChip
import androidx.compose.material3.ModalBottomSheet
@ -21,7 +21,9 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.VerticalAlignmentLine
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.res.stringResource
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.TileMap
enum class SensorsFilter {
All, Thermometer, Camera,
}
data class SensorFilter(val stringRes: Int, val code: Int, var enabled: Boolean = false)
@ExperimentalMaterial3Api
@Composable
@ -44,31 +44,37 @@ fun SensorsPage(navController: NavController) {
var filterShown by remember { mutableStateOf(false) }
var filterMine by remember { mutableStateOf(false) }
val filterItems = listOf(
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 filterItems = remember {
mutableListOf(
/* TODO:
* Заменить `code` на настоящее значение
* либо динамически его подгружать из ответа АПИ
* (см. /appInit, ключ в жсоне: types.type) */
SensorFilter(R.string.filter_temp, 0),
SensorFilter(R.string.filter_temp_water, 1),
SensorFilter(R.string.filter_temp_ground, 2),
SensorFilter(R.string.filter_temp_dew_point, 3),
SensorFilter(R.string.filter_humidity, 4),
SensorFilter(R.string.filter_pressure, 5),
SensorFilter(R.string.filter_lightness, 6),
SensorFilter(R.string.filter_uv, 7),
SensorFilter(R.string.filter_radiation, 8),
SensorFilter(R.string.filter_rainfall, 9),
SensorFilter(R.string.filter_dust, 10),
SensorFilter(R.string.filter_wind_speed, 11),
SensorFilter(R.string.filter_wind_direction, 12),
SensorFilter(R.string.filter_concentration, 13),
SensorFilter(R.string.filter_power, 14),
SensorFilter(R.string.filter_voltage, 15),
SensorFilter(R.string.filter_amperage, 16),
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 mapHeight = scrConfig.screenHeightDp / 3
@ -125,19 +131,22 @@ fun SensorsPage(navController: NavController) {
modifier = Modifier.padding(horizontal = 4.dp),
) {
items(filterItems) {
Card(
modifier = Modifier
.fillMaxWidth()
.clickable { }
Row(
verticalAlignment = Alignment.CenterVertically,
) {
Text(
text = it,
fontSize = 18.sp,
modifier = Modifier.padding(
horizontal = 8.dp,
vertical = 16.dp,
),
Checkbox(
checked = it.enabled,
onCheckedChange = { checked -> it.enabled = checked },
)
Text(
text = stringResource(id = it.stringRes),
modifier = Modifier.clickable {
it.enabled = !it.enabled
}
)
Text(text = it.toString())
}
}
}