Skip to content

Commit

Permalink
[Jetcaster] Add on click label to podcast follow button
Browse files Browse the repository at this point in the history
  • Loading branch information
JolandaVerhoef committed Jul 16, 2021
1 parent 89e4437 commit 6a6aa57
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.onClick
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.dp
import com.example.jetcaster.R

Expand All @@ -42,9 +44,12 @@ fun ToggleFollowPodcastIconButton(
onClick: () -> Unit,
modifier: Modifier = Modifier
) {
val clickLabel = stringResource(if (isFollowed) R.string.cd_unfollow else R.string.cd_follow)
IconButton(
onClick = onClick,
modifier = modifier
modifier = modifier.semantics {
onClick(label = clickLabel, action = null)
}
) {
Icon(
// TODO: think about animating these icons
Expand All @@ -53,8 +58,8 @@ fun ToggleFollowPodcastIconButton(
else -> Icons.Default.Add
},
contentDescription = when {
isFollowed -> stringResource(R.string.cd_unfollow)
else -> stringResource(R.string.cd_follow)
isFollowed -> stringResource(R.string.cd_following)
else -> stringResource(R.string.cd_not_following)
},
tint = animateColorAsState(
when {
Expand Down
2 changes: 2 additions & 0 deletions Jetcaster/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,7 @@
<string name="cd_play">Play</string>
<string name="cd_unfollow">Unfollow</string>
<string name="cd_follow">Follow</string>
<string name="cd_following">Following</string>
<string name="cd_not_following">Not following</string>

</resources>

0 comments on commit 6a6aa57

Please sign in to comment.