Skip to content

Commit

Permalink
[Jetcaster]: Change alpha of prev/next buttons. (#1393)
Browse files Browse the repository at this point in the history
Change alpha of previous and next buttons in the player to help indicate
if those actions are possible based on the state of the player (i.e.
previous only possible while playing and next only possible when queue
isn't empty).

Disabled:
<img
src="https://github.com/android/compose-samples/assets/463186/81bf2fcb-c8af-4db3-bf79-421c79b2393f"
width=300 />


Enabled:
<img
src="https://github.com/android/compose-samples/assets/463186/f6cfebbf-e54e-41bf-9813-302536a1cb5e"
width=300 />
  • Loading branch information
arriolac committed May 6, 2024
2 parents 13f5c6e + d2cf6ba commit 2061095
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.layout.ContentScale
Expand Down Expand Up @@ -754,6 +755,7 @@ private fun PlayerButtons(
colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onSurfaceVariant),
modifier = sideButtonsModifier
.clickable(enabled = isPlaying, onClick = onPrevious)
.alpha(if (isPlaying) 1f else 0.25f)
)
Image(
imageVector = Icons.Filled.Replay10,
Expand Down Expand Up @@ -807,6 +809,7 @@ private fun PlayerButtons(
colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onSurfaceVariant),
modifier = sideButtonsModifier
.clickable(enabled = hasNext, onClick = onNext)
.alpha(if (hasNext) 1f else 0.25f)
)
}
}
Expand Down

0 comments on commit 2061095

Please sign in to comment.