Skip to content

Commit 643a1f3

Browse files
committed
Expose selected state for pill tabs
- Replace custom tab click handling with selectable semantics - Group pill tabs as a selectable set for accessibility services - Preserve existing tab behavior while exposing selected state to TalkBack 🤖 Auto-generated
1 parent 242effa commit 643a1f3

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

  • app/src/main/java/com/enaboapps/switchify/components

app/src/main/java/com/enaboapps/switchify/components/PillTabRow.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import androidx.compose.animation.fadeOut
99
import androidx.compose.animation.slideInVertically
1010
import androidx.compose.animation.togetherWith
1111
import androidx.compose.foundation.background
12-
import androidx.compose.foundation.clickable
1312
import androidx.compose.foundation.layout.Arrangement
1413
import androidx.compose.foundation.layout.Box
1514
import androidx.compose.foundation.layout.BoxWithConstraints
@@ -22,6 +21,8 @@ import androidx.compose.foundation.layout.offset
2221
import androidx.compose.foundation.layout.padding
2322
import androidx.compose.foundation.layout.size
2423
import androidx.compose.foundation.layout.width
24+
import androidx.compose.foundation.selection.selectable
25+
import androidx.compose.foundation.selection.selectableGroup
2526
import androidx.compose.foundation.shape.RoundedCornerShape
2627
import androidx.compose.material3.Icon
2728
import androidx.compose.material3.MaterialTheme
@@ -96,7 +97,11 @@ fun PillTabRow(
9697
)
9798
)
9899

99-
Row(modifier = Modifier.fillMaxSize()) {
100+
Row(
101+
modifier = Modifier
102+
.fillMaxSize()
103+
.selectableGroup()
104+
) {
100105
tabs.forEachIndexed { index, tab ->
101106
val selected = index == selectedIndex
102107
val contentColor = when {
@@ -110,7 +115,8 @@ fun PillTabRow(
110115
.fillMaxHeight()
111116
.padding(IndicatorPadding)
112117
.clip(IndicatorShape)
113-
.clickable(
118+
.selectable(
119+
selected = selected,
114120
enabled = enabled,
115121
role = Role.Tab,
116122
onClick = { onTabSelected(index) }

0 commit comments

Comments
 (0)