dc09-sensors2 #5
2 changed files with 74 additions and 30 deletions
|
@ -59,6 +59,9 @@ fun SensorsPage(navController: NavController) {
|
||||||
|
|
||||||
var sortingShow by remember { mutableStateOf(false) }
|
var sortingShow by remember { mutableStateOf(false) }
|
||||||
var sortingType by remember { mutableStateOf(SortingType.DISTANCE) }
|
var sortingType by remember { mutableStateOf(SortingType.DISTANCE) }
|
||||||
|
var sortingDesc by remember { mutableStateOf(false) }
|
||||||
|
var sortingMine by remember { mutableStateOf(false) }
|
||||||
|
var sortingFav by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
val sortingTypes = remember {
|
val sortingTypes = remember {
|
||||||
listOf(
|
listOf(
|
||||||
|
@ -165,22 +168,11 @@ fun SensorsPage(navController: NavController) {
|
||||||
modifier = Modifier.padding(horizontal = 4.dp),
|
modifier = Modifier.padding(horizontal = 4.dp),
|
||||||
) {
|
) {
|
||||||
items(filterItems) {
|
items(filterItems) {
|
||||||
Row(
|
FilterCheckbox(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
) {
|
|
||||||
Checkbox(
|
|
||||||
checked = it.enabled.value,
|
checked = it.enabled.value,
|
||||||
onCheckedChange = { checked ->
|
onCheckedChange = { it.enabled.value = !it.enabled.value },
|
||||||
it.enabled.value = checked
|
stringRes = it.stringRes,
|
||||||
},
|
|
||||||
)
|
)
|
||||||
Text(
|
|
||||||
text = stringResource(id = it.stringRes),
|
|
||||||
modifier = Modifier.clickable {
|
|
||||||
it.enabled.value = !it.enabled.value
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -192,22 +184,71 @@ fun SensorsPage(navController: NavController) {
|
||||||
modifier = Modifier.padding(horizontal = 4.dp),
|
modifier = Modifier.padding(horizontal = 4.dp),
|
||||||
) {
|
) {
|
||||||
items (sortingTypes) {
|
items (sortingTypes) {
|
||||||
Row (
|
FilterRadioButton(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
) {
|
|
||||||
RadioButton(
|
|
||||||
selected = (sortingType == it.sortingType),
|
selected = (sortingType == it.sortingType),
|
||||||
onClick = { sortingType = it.sortingType },
|
onClick = { sortingType = it.sortingType },
|
||||||
)
|
stringRes = it.stringRes,
|
||||||
Text(
|
|
||||||
text = stringResource(id = it.stringRes),
|
|
||||||
modifier = Modifier.clickable {
|
|
||||||
sortingType = it.sortingType
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
item {
|
||||||
|
FilterCheckbox(
|
||||||
|
checked = sortingDesc,
|
||||||
|
onCheckedChange = { sortingDesc = !sortingDesc },
|
||||||
|
stringRes = R.string.sort_option_desc,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
item {
|
||||||
|
FilterCheckbox(
|
||||||
|
checked = sortingFav,
|
||||||
|
onCheckedChange = { sortingFav = !sortingFav },
|
||||||
|
stringRes = R.string.sort_option_fav,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
item {
|
||||||
|
FilterCheckbox(
|
||||||
|
checked = sortingMine,
|
||||||
|
onCheckedChange = { sortingMine = !sortingMine },
|
||||||
|
stringRes = R.string.sort_option_mine,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ExperimentalMaterial3Api
|
||||||
|
@Composable
|
||||||
|
fun FilterCheckbox(checked: Boolean, onCheckedChange: () -> Unit, stringRes: Int) {
|
||||||
|
Row(
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
) {
|
||||||
|
Checkbox(
|
||||||
|
checked = checked,
|
||||||
|
onCheckedChange = { onCheckedChange() },
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
text = stringResource(id = stringRes),
|
||||||
|
modifier = Modifier.clickable { onCheckedChange() },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExperimentalMaterial3Api
|
||||||
|
@Composable
|
||||||
|
fun FilterRadioButton(selected: Boolean, onClick: () -> Unit, stringRes: Int) {
|
||||||
|
Row (
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
) {
|
||||||
|
RadioButton(
|
||||||
|
selected = selected,
|
||||||
|
onClick = onClick,
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
text = stringResource(id = stringRes),
|
||||||
|
modifier = Modifier.clickable { onClick() },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
|
@ -48,4 +48,7 @@
|
||||||
<string name="sort_update_time">Время последнего обновления</string>
|
<string name="sort_update_time">Время последнего обновления</string>
|
||||||
<string name="sort_name">Название</string>
|
<string name="sort_name">Название</string>
|
||||||
<string name="sort_value">Данные</string>
|
<string name="sort_value">Данные</string>
|
||||||
|
<string name="sort_option_desc">По убыванию</string>
|
||||||
|
<string name="sort_option_fav">Избранные сверху</string>
|
||||||
|
<string name="sort_option_mine">Мои датчики сверху</string>
|
||||||
</resources>
|
</resources>
|
Loading…
Add table
Reference in a new issue