From d6f8c13c3f1c9b0480c28778c0dccd86ef6ce0a0 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 24 Apr 2026 12:08:19 +0200 Subject: [PATCH] MediaPlayerControllerView: Use IconButton instead of Box and remove the clipping. --- .../local/player/MediaPlayerControllerView.kt | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/libraries/mediaviewer/impl/src/main/kotlin/io/element/android/libraries/mediaviewer/impl/local/player/MediaPlayerControllerView.kt b/libraries/mediaviewer/impl/src/main/kotlin/io/element/android/libraries/mediaviewer/impl/local/player/MediaPlayerControllerView.kt index b83c598c10..b06b97f491 100644 --- a/libraries/mediaviewer/impl/src/main/kotlin/io/element/android/libraries/mediaviewer/impl/local/player/MediaPlayerControllerView.kt +++ b/libraries/mediaviewer/impl/src/main/kotlin/io/element/android/libraries/mediaviewer/impl/local/player/MediaPlayerControllerView.kt @@ -12,13 +12,12 @@ import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeOut import androidx.compose.foundation.background -import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.widthIn -import androidx.compose.foundation.shape.CircleShape +import androidx.compose.material3.IconButtonDefaults import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue @@ -28,7 +27,6 @@ import androidx.compose.runtime.rememberUpdatedState import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.PreviewParameter @@ -91,33 +89,31 @@ fun MediaPlayerControllerView( .widthIn(max = 480.dp), verticalAlignment = Alignment.CenterVertically, ) { - val bgColor = if (state.isPlaying) { - ElementTheme.colors.bgCanvasDefault + val colors = if (state.isPlaying) { + IconButtonDefaults.iconButtonColors( + containerColor = ElementTheme.colors.bgCanvasDefault, + contentColor = ElementTheme.colors.iconPrimary, + ) } else { - ElementTheme.colors.textPrimary + IconButtonDefaults.iconButtonColors( + containerColor = ElementTheme.colors.iconPrimary, + contentColor = ElementTheme.colors.iconOnSolidPrimary, + ) } - Box( + IconButton( modifier = Modifier - .size(36.dp) - .background( - color = bgColor, - shape = CircleShape, - ) - .clip(CircleShape) - .clickable { onTogglePlay() } - .padding(8.dp), - contentAlignment = Alignment.Center, + .size(36.dp), + onClick = onTogglePlay, + colors = colors, ) { if (state.isPlaying) { Icon( imageVector = CompoundIcons.PauseSolid(), - tint = ElementTheme.colors.iconPrimary, contentDescription = stringResource(CommonStrings.a11y_pause) ) } else { Icon( imageVector = CompoundIcons.PlaySolid(), - tint = ElementTheme.colors.iconOnSolidPrimary, contentDescription = stringResource(CommonStrings.a11y_play) ) }