Skip to content

[Rally] Content description, tabs, and grouping views #400

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

Merged
merged 4 commits into from
Feb 17, 2021
Merged
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
Original file line number Diff line number Diff line change
@@ -39,6 +39,8 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.unit.dp
import com.example.compose.rally.R
import java.text.DecimalFormat
@@ -79,8 +81,15 @@ private fun BaseRow(
amount: Float,
negative: Boolean
) {
val dollarSign = if (negative) "–$ " else "$ "
val formattedAmount = formatAmount(amount)
Row(
modifier = Modifier.height(68.dp),
modifier = Modifier
.height(68.dp)
.clearAndSetSemantics {
contentDescription =
"$title account ending in ${subtitle.takeLast(4)}, current balance $dollarSign$formattedAmount"
},
verticalAlignment = Alignment.CenterVertically
) {
val typography = MaterialTheme.typography
@@ -100,14 +109,12 @@ private fun BaseRow(
horizontalArrangement = Arrangement.SpaceBetween
) {
Text(
text = if (negative) "–$ " else "$ ",
text = dollarSign,
style = typography.h6,
modifier = Modifier.align(Alignment.CenterVertically)
)
Text(
text = formatAmount(
amount
),
text = formattedAmount,
style = typography.h6,
modifier = Modifier.align(Alignment.CenterVertically)
)
Original file line number Diff line number Diff line change
@@ -40,6 +40,8 @@ import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.example.compose.rally.RallyScreen
@@ -96,6 +98,7 @@ private fun RallyTab(
.selectable(
selected = selected,
onClick = onSelected,
role = Role.Tab,
interactionSource = remember { MutableInteractionSource() },
indication = rememberRipple(
bounded = false,
@@ -104,10 +107,10 @@ private fun RallyTab(
)
)
) {
Icon(imageVector = icon, contentDescription = null, tint = tabTintColor)
Icon(imageVector = icon, contentDescription = text, tint = tabTintColor)
if (selected) {
Spacer(Modifier.width(12.dp))
Text(text, color = tabTintColor)
Text(text, color = tabTintColor, modifier = Modifier.clearAndSetSemantics {})
}
}
}
Original file line number Diff line number Diff line change
@@ -44,6 +44,8 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.dp
import com.example.compose.rally.R
import com.example.compose.rally.RallyScreen
@@ -128,7 +130,13 @@ private fun AlertHeader(onClickSeeAll: () -> Unit) {
@Composable
private fun AlertItem(message: String) {
Row(
modifier = Modifier.padding(RallyDefaultPadding),
modifier = Modifier
.padding(RallyDefaultPadding)
// Regard the whole row as one semantics node. This way each row will receive focus as
// a whole and the focus bounds will be around the whole row content. The semantics
// properties of the descendants will be merged. If we'd use clearAndSetSemantics instead,
// we'd have to define the semantics properties explicitly.
.semantics(mergeDescendants = true) {},
horizontalArrangement = Arrangement.SpaceBetween
) {
Text(
@@ -138,9 +146,11 @@ private fun AlertItem(message: String) {
)
IconButton(
onClick = {},
modifier = Modifier.align(Alignment.Top)
modifier = Modifier
.align(Alignment.Top)
.clearAndSetSemantics {}
) {
Icon(Icons.Filled.Sort, contentDescription = stringResource(id = R.string.sort))
Icon(Icons.Filled.Sort, contentDescription = null)
}
}
}
@@ -193,6 +203,7 @@ private fun <T> OverViewDivider(
}
}
}

/**
* The Accounts card within the Rally Overview screen.
*/
@@ -217,6 +228,7 @@ private fun AccountsCard(onScreenChange: (RallyScreen) -> Unit) {
)
}
}

/**
* The Bills card within the Rally Overview screen.
*/