mirror of
https://github.com/home-assistant/android
synced 2024-10-04 15:19:30 +00:00
Sort entities, add time and headers in wear settings (#1912)
* Sort entities, add time and headers in wear settings * Review comment
This commit is contained in:
parent
1e5534de68
commit
fe3bbdf112
|
@ -64,11 +64,12 @@ fun MainView(
|
|||
var expandedScripts: Boolean by rememberSaveable { mutableStateOf(true) }
|
||||
var expandedSwitches: Boolean by rememberSaveable { mutableStateOf(true) }
|
||||
|
||||
val scenes = entities.filter { it.key.split(".")[0] == "scene" }.values.toList()
|
||||
val scripts = entities.filter { it.key.split(".")[0] == "script" }.values.toList()
|
||||
val lights = entities.filter { it.key.split(".")[0] == "light" }.values.toList()
|
||||
val inputBooleans = entities.filter { it.key.split(".")[0] == "input_boolean" }.values.toList()
|
||||
val switches = entities.filter { it.key.split(".")[0] == "switch" }.values.toList()
|
||||
val entitiesList = entities.values.toList().sortedBy { it.entityId }
|
||||
val scenes = entitiesList.filter { it.entityId.split(".")[0] == "scene" }
|
||||
val scripts = entitiesList.filter { it.entityId.split(".")[0] == "script" }
|
||||
val lights = entitiesList.filter { it.entityId.split(".")[0] == "light" }
|
||||
val inputBooleans = entitiesList.filter { it.entityId.split(".")[0] == "input_boolean" }
|
||||
val switches = entitiesList.filter { it.entityId.split(".")[0] == "switch" }
|
||||
|
||||
val haptic = LocalHapticFeedback.current
|
||||
val context = LocalContext.current
|
||||
|
|
|
@ -17,9 +17,13 @@ import androidx.compose.ui.tooling.preview.Preview
|
|||
import androidx.compose.ui.unit.dp
|
||||
import androidx.wear.compose.material.Chip
|
||||
import androidx.wear.compose.material.ChipDefaults
|
||||
import androidx.wear.compose.material.ExperimentalWearMaterialApi
|
||||
import androidx.wear.compose.material.PositionIndicator
|
||||
import androidx.wear.compose.material.Scaffold
|
||||
import androidx.wear.compose.material.ScalingLazyColumn
|
||||
import androidx.wear.compose.material.ScalingLazyListState
|
||||
import androidx.wear.compose.material.Text
|
||||
import androidx.wear.compose.material.TimeText
|
||||
import androidx.wear.compose.material.ToggleChip
|
||||
import androidx.wear.compose.material.ToggleChipDefaults
|
||||
import androidx.wear.compose.material.rememberScalingLazyListState
|
||||
|
@ -31,6 +35,7 @@ import io.homeassistant.companion.android.util.RotaryEventDispatcher
|
|||
import io.homeassistant.companion.android.util.RotaryEventState
|
||||
import io.homeassistant.companion.android.util.previewFavoritesList
|
||||
|
||||
@ExperimentalWearMaterialApi
|
||||
@Composable
|
||||
fun SettingsView(
|
||||
favorites: List<String>,
|
||||
|
@ -44,12 +49,21 @@ fun SettingsView(
|
|||
) {
|
||||
val scalingLazyListState: ScalingLazyListState = rememberScalingLazyListState()
|
||||
RotaryEventState(scrollState = scalingLazyListState)
|
||||
|
||||
Scaffold(
|
||||
positionIndicator = {
|
||||
if (scalingLazyListState.isScrollInProgress)
|
||||
PositionIndicator(scalingLazyListState = scalingLazyListState)
|
||||
},
|
||||
timeText = {
|
||||
if (!scalingLazyListState.isScrollInProgress)
|
||||
TimeText()
|
||||
}
|
||||
) {
|
||||
ScalingLazyColumn(
|
||||
modifier = Modifier
|
||||
.fillMaxSize(),
|
||||
contentPadding = PaddingValues(
|
||||
top = 40.dp,
|
||||
top = 20.dp,
|
||||
start = 8.dp,
|
||||
end = 8.dp,
|
||||
bottom = 40.dp
|
||||
|
@ -59,7 +73,7 @@ fun SettingsView(
|
|||
state = scalingLazyListState
|
||||
) {
|
||||
item {
|
||||
ListHeader(id = R.string.settings)
|
||||
ListHeader(id = R.string.favorite_settings)
|
||||
}
|
||||
item {
|
||||
Chip(
|
||||
|
@ -82,7 +96,8 @@ fun SettingsView(
|
|||
item {
|
||||
Chip(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth(),
|
||||
.fillMaxWidth()
|
||||
.padding(top = 10.dp),
|
||||
icon = {
|
||||
Image(asset = CommunityMaterial.Icon.cmd_delete)
|
||||
},
|
||||
|
@ -103,7 +118,12 @@ fun SettingsView(
|
|||
enabled = favorites.isNotEmpty()
|
||||
)
|
||||
}
|
||||
|
||||
item {
|
||||
ListHeader(
|
||||
id = R.string.feedback_settings,
|
||||
modifier = Modifier.padding(top = 16.dp)
|
||||
)
|
||||
}
|
||||
item {
|
||||
val haptic = LocalHapticFeedback.current
|
||||
ToggleChip(
|
||||
|
@ -195,8 +215,10 @@ fun SettingsView(
|
|||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ExperimentalWearMaterialApi
|
||||
@Preview
|
||||
@Composable
|
||||
private fun PreviewSettingsView() {
|
||||
|
|
|
@ -49,4 +49,6 @@
|
|||
<string name="toast_message">%1$s was selected</string>
|
||||
<string name="setting_toast_label">Enable Toast Confirmation</string>
|
||||
<string name="setting_haptic_label">Enable Haptic Feeback</string>
|
||||
<string name="feedback_settings">Feedback Settings</string>
|
||||
<string name="favorite_settings">Favorite Settings</string>
|
||||
</resources>
|
Loading…
Reference in a new issue