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