Skip to content
Open
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
3 changes: 3 additions & 0 deletions .Jules/palette.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 2024-10-04 - Dynamic Content Descriptions & Button Roles in Compose
**Learning:** Found that custom composable buttons using `.clickable` need an explicit `role = Role.Button` so screen readers identify them as interactive elements. Additionally, toggle buttons often use static descriptions (e.g., "Mute") regardless of state, which is confusing for a11y users.
**Action:** Always verify `role = Role.Button` is set on custom `.clickable` components and ensure stateful buttons have dynamic `contentDescription`s (e.g., "Unmute" vs "Mute") reflecting the action to be performed.
8 changes: 4 additions & 4 deletions app/src/main/java/com/example/reddittube/ui/main/VideoPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@ Box(
) {
Icon(
if (isRotationLocked) Icons.Default.Lock else Icons.Default.LockOpen,
contentDescription = "Rotation",
contentDescription = if (isRotationLocked) "Unlock rotation" else "Lock rotation",
tint = if (isRotationLocked) BrandRed else Color.White,
modifier = Modifier.size(14.dp)
)
Expand All @@ -1001,7 +1001,7 @@ Box(
) {
Icon(
if (isMuted) Icons.AutoMirrored.Filled.VolumeOff else Icons.AutoMirrored.Filled.VolumeUp,
contentDescription = "Mute",
contentDescription = if (isMuted) "Unmute" else "Mute",
tint = if (isMuted) BrandRed else Color.White,
modifier = Modifier.size(14.dp)
)
Expand All @@ -1017,7 +1017,7 @@ Box(
) {
Icon(
Icons.Default.SkipNext,
contentDescription = "Auto-next",
contentDescription = if (autoNextEnabled) "Disable auto-next" else "Enable auto-next",
tint = if (autoNextEnabled) Color.White else TextMuted,
modifier = Modifier.size(14.dp)
)
Expand All @@ -1034,7 +1034,7 @@ Box(
) {
Icon(
Icons.Default.Repeat,
contentDescription = "Loop video",
contentDescription = if (isLoopEnabled) "Disable loop video" else "Enable loop video",
tint = if (isLoopEnabled) Color.White else TextMuted,
modifier = Modifier.size(14.dp)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
Expand All @@ -30,7 +31,7 @@ fun MinimalButton(
modifier = modifier
.clip(RoundedCornerShape(16.dp))
.background(Color.White.copy(alpha = 0.12f))
.clickable(onClick = onClick)
.clickable(onClick = onClick, role = Role.Button)
.padding(horizontal = 10.dp, vertical = 6.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center
Expand Down
Loading