Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump androidx.wear.compose:compose-material3 from 1.0.0-alpha15 to 1.0.0-alpha19 #4250

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ tools-desugar-jdk-libs = "2.1.2"
watchfaceComplicationsDataSourceKtx = "1.2.1"
wear = "1.3.0"
wear-compose-foundation = "1.3.1"
wear-compose-material = "1.0.0-alpha15"
wear-compose-material = "1.0.0-alpha19"
wear-protolayout = "1.2.0"
wear-tiles = "1.4.0"
wear-tooling = "1.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ fun MainConfigView(
checked = isChecked,
onCheckedChange = onShowTitleClicked,
label = { Text(stringResource(R.string.show_entity_title)) },
selectionControl = { ToggleSwitch(isChecked) },
toggleControl = { ToggleSwitch(isChecked) },
modifier = Modifier.fillMaxWidth(),
enabled = loaded && entity != null,
colors = getToggleButtonColors()
Expand All @@ -147,7 +147,7 @@ fun MainConfigView(
checked = isChecked,
onCheckedChange = onShowUnitClicked,
label = { Text(stringResource(R.string.show_unit_title)) },
selectionControl = { ToggleSwitch(isChecked) },
toggleControl = { ToggleSwitch(isChecked) },
modifier = Modifier.fillMaxWidth(),
enabled = loaded && entity != null,
colors = getToggleButtonColors()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalHapticFeedback
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.wear.compose.material.Switch
import androidx.wear.compose.material.ToggleChip
import androidx.wear.compose.material3.Button
import androidx.wear.compose.material3.LocalContentColor
Expand All @@ -28,7 +29,6 @@ import io.homeassistant.companion.android.common.data.integration.isActive
import io.homeassistant.companion.android.common.util.STATE_UNAVAILABLE
import io.homeassistant.companion.android.theme.getFilledTonalButtonColors
import io.homeassistant.companion.android.theme.wearColorScheme
import io.homeassistant.companion.android.util.ToggleSwitch
import io.homeassistant.companion.android.util.WearToggleChip
import io.homeassistant.companion.android.util.onEntityClickedFeedback
import io.homeassistant.companion.android.util.previewEntity1
Expand Down Expand Up @@ -99,7 +99,7 @@ fun EntityUi(
}
},
enabled = isEnabled,
toggleControl = { ToggleSwitch(isChecked) },
toggleControl = { Switch(checked = isChecked) },
jpelgrom marked this conversation as resolved.
Show resolved Hide resolved
colors = colors
)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fun SelectShortcutsTileView(
colorFilter = ColorFilter.tint(wearColorScheme.onSurface)
)
},
selectionControl = { ToggleCheckbox(isShowShortcutTextEnabled) },
toggleControl = { ToggleCheckbox(isShowShortcutTextEnabled) },
colors = getToggleButtonColors()
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ fun SensorUi(
}
}
},
selectionControl = { ToggleSwitch(isChecked) },
toggleControl = { ToggleSwitch(isChecked) },
colors = getToggleButtonColors()
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private fun FavoriteToggleChip(
overflow = TextOverflow.Ellipsis
)
},
selectionControl = { ToggleSwitch(checked) },
toggleControl = { ToggleSwitch(checked) },
colors = getToggleButtonColors()
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ fun SettingsView(
onCheckedChange = { setFavoritesOnly(it) },
label = { Text(stringResource(commonR.string.only_favorites)) },
enabled = favorites.isNotEmpty(),
selectionControl = { ToggleSwitch(isFavoritesOnly) },
toggleControl = { ToggleSwitch(isFavoritesOnly) },
icon = {
Image(
asset = CommunityMaterial.Icon2.cmd_home_heart,
Expand Down Expand Up @@ -141,7 +141,7 @@ fun SettingsView(
colorFilter = ColorFilter.tint(wearColorScheme.onSurface)
)
},
selectionControl = { ToggleSwitch(isHapticEnabled) },
toggleControl = { ToggleSwitch(isHapticEnabled) },
colors = getToggleButtonColors()
)
}
Expand All @@ -162,7 +162,7 @@ fun SettingsView(
colorFilter = ColorFilter.tint(wearColorScheme.onSurface)
)
},
selectionControl = { ToggleSwitch(isToastEnabled) },
toggleControl = { ToggleSwitch(isToastEnabled) },
colors = getToggleButtonColors()
)
}
Expand Down Expand Up @@ -222,7 +222,7 @@ fun SettingsView(
colorFilter = ColorFilter.tint(wearColorScheme.onSurface)
)
},
selectionControl = { ToggleSwitch(isAssistantAppAllowed) },
toggleControl = { ToggleSwitch(isAssistantAppAllowed) },
colors = getToggleButtonColors()
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import androidx.compose.ui.graphics.Color
import androidx.wear.compose.material3.ButtonDefaults
import androidx.wear.compose.material3.CheckboxDefaults
import androidx.wear.compose.material3.ColorScheme
import androidx.wear.compose.material3.ContentAlpha
import androidx.wear.compose.material3.ExperimentalWearMaterial3Api
import androidx.wear.compose.material3.InlineSliderDefaults
import androidx.wear.compose.material3.SwitchDefaults
Expand Down Expand Up @@ -70,7 +69,7 @@ fun getToggleButtonColors() = ToggleButtonDefaults.toggleButtonColors(
@Composable
fun getFilledTonalButtonColors() = ButtonDefaults.filledTonalButtonColors(
containerColor = wearColorScheme.surfaceDim,
disabledContainerColor = wearColorScheme.surfaceDim.copy(alpha = ContentAlpha.disabled)
disabledContainerColor = wearColorScheme.surfaceDim.copy(alpha = 0.38f)
)

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.wear.compose.material3.Checkbox
import androidx.wear.compose.material3.Switch
import androidx.wear.compose.material3.ToggleControlScope
import io.homeassistant.companion.android.common.R
import io.homeassistant.companion.android.theme.getCheckboxColors
import io.homeassistant.companion.android.theme.getSwitchColors

@Composable
fun ToggleSwitch(isChecked: Boolean) {
fun ToggleControlScope.ToggleSwitch(isChecked: Boolean) {
val description = stringResource(if (isChecked)R.string.enabled else R.string.disabled)
Switch(
checked = isChecked,
modifier = Modifier.semantics {
this.contentDescription = description
},
Expand All @@ -24,10 +24,9 @@ fun ToggleSwitch(isChecked: Boolean) {
}

@Composable
fun ToggleCheckbox(isChecked: Boolean) {
fun ToggleControlScope.ToggleCheckbox(isChecked: Boolean) {
val description = stringResource(if (isChecked) R.string.show else R.string.hide)
Checkbox(
checked = isChecked,
modifier = Modifier.semantics {
this.contentDescription = description
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.unit.LayoutDirection
import androidx.wear.compose.material.ToggleChipColors
import androidx.wear.compose.material.ToggleChipDefaults
import androidx.wear.compose.material3.ContentAlpha
import androidx.wear.compose.material3.contentColorFor
import io.homeassistant.companion.android.common.data.integration.Entity
import io.homeassistant.companion.android.common.data.integration.EntityPosition
Expand Down Expand Up @@ -79,16 +78,16 @@ object WearToggleChip {
checkedEndBackgroundColor
)
var disabledCheckedBackgroundColors = listOf(
checkedStartBackgroundColor.copy(alpha = ContentAlpha.disabled),
checkedEndBackgroundColor.copy(alpha = ContentAlpha.disabled)
checkedStartBackgroundColor.copy(alpha = 0.38f),
checkedEndBackgroundColor.copy(alpha = 0.38f)
)
val uncheckedBackgroundColors = listOf(
uncheckedBackgroundColor,
uncheckedBackgroundColor
)
val disabledUncheckedBackgroundColors = listOf(
uncheckedBackgroundColor.copy(alpha = ContentAlpha.disabled),
uncheckedBackgroundColor.copy(alpha = ContentAlpha.disabled)
uncheckedBackgroundColor.copy(alpha = 0.38f),
uncheckedBackgroundColor.copy(alpha = 0.38f)
)
if (gradientDirection != LayoutDirection.Ltr) {
checkedBackgroundColors = checkedBackgroundColors.reversed()
Expand Down Expand Up @@ -220,17 +219,17 @@ object WearToggleChip {
checkedEndBackgroundColor
)
disabledCheckedBackgroundColors = listOf(
checkedStartBackgroundColor.copy(alpha = ContentAlpha.disabled),
checkedEndBackgroundColor.copy(alpha = ContentAlpha.disabled)
checkedStartBackgroundColor.copy(alpha = 0.38f),
checkedEndBackgroundColor.copy(alpha = 0.38f)
)
} else {
checkedBackgroundColors = listOf(
checkedEndBackgroundColor,
checkedStartBackgroundColor
)
disabledCheckedBackgroundColors = listOf(
checkedEndBackgroundColor.copy(alpha = ContentAlpha.disabled),
checkedStartBackgroundColor.copy(alpha = ContentAlpha.disabled)
checkedEndBackgroundColor.copy(alpha = 0.38f),
checkedStartBackgroundColor.copy(alpha = 0.38f)
)
}
val uncheckedBackgroundColors: List<Color>
Expand All @@ -241,17 +240,17 @@ object WearToggleChip {
uncheckedEndBackgroundColor
)
disabledUncheckedBackgroundColors = listOf(
uncheckedStartBackgroundColor.copy(alpha = ContentAlpha.disabled),
uncheckedEndBackgroundColor.copy(alpha = ContentAlpha.disabled)
uncheckedStartBackgroundColor.copy(alpha = 0.38f),
uncheckedEndBackgroundColor.copy(alpha = 0.38f)
)
} else {
uncheckedBackgroundColors = listOf(
uncheckedEndBackgroundColor,
uncheckedStartBackgroundColor
)
disabledUncheckedBackgroundColors = listOf(
uncheckedEndBackgroundColor.copy(alpha = ContentAlpha.disabled),
uncheckedStartBackgroundColor.copy(alpha = ContentAlpha.disabled)
uncheckedEndBackgroundColor.copy(alpha = 0.38f),
uncheckedStartBackgroundColor.copy(alpha = 0.38f)
)
}

Expand All @@ -269,24 +268,24 @@ object WearToggleChip {
disabledCheckedBackgroundPainter = WearBrushPainter(
Brush.linearGradient(disabledCheckedBackgroundColors)
),
disabledCheckedContentColor = checkedContentColor.copy(alpha = ContentAlpha.disabled),
disabledCheckedContentColor = checkedContentColor.copy(alpha = 0.38f),
disabledCheckedSecondaryContentColor = checkedSecondaryContentColor.copy(
alpha = ContentAlpha.disabled
alpha = 0.38f
),
disabledCheckedIconColor = checkedToggleControlColor.copy(
alpha = ContentAlpha.disabled
alpha = 0.38f
),
disabledUncheckedBackgroundPainter = WearBrushPainter(
Brush.linearGradient(disabledUncheckedBackgroundColors)
),
disabledUncheckedContentColor = uncheckedContentColor.copy(
alpha = ContentAlpha.disabled
alpha = 0.38f
),
disabledUncheckedSecondaryContentColor = uncheckedSecondaryContentColor.copy(
alpha = ContentAlpha.disabled
alpha = 0.38f
),
disabledUncheckedIconColor = uncheckedToggleControlColor.copy(
alpha = ContentAlpha.disabled
alpha = 0.38f
)
)
}
Expand Down