From af79175af7d17cbb6fd7313dbd9c52f06a21dfb4 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 18 Mar 2024 16:46:26 +0100 Subject: [PATCH] Simplification since MatrixUser cannot be null anymore. --- .../impl/components/RoomListTopBar.kt | 23 ++++--------------- .../designsystem/components/Bloom.kt | 5 ++-- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RoomListTopBar.kt b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RoomListTopBar.kt index 272ce01700..301a32a26c 100644 --- a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RoomListTopBar.kt +++ b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RoomListTopBar.kt @@ -21,10 +21,8 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.statusBars import androidx.compose.foundation.layout.statusBarsPadding -import androidx.compose.foundation.shape.CircleShape import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.MaterialTheme import androidx.compose.material3.TopAppBarDefaults @@ -73,7 +71,6 @@ import io.element.android.libraries.designsystem.theme.components.HorizontalDivi import io.element.android.libraries.designsystem.theme.components.Icon import io.element.android.libraries.designsystem.theme.components.IconButton import io.element.android.libraries.designsystem.theme.components.MediumTopAppBar -import io.element.android.libraries.designsystem.theme.components.Surface import io.element.android.libraries.designsystem.theme.components.Text import io.element.android.libraries.matrix.api.core.UserId import io.element.android.libraries.matrix.api.user.MatrixUser @@ -295,7 +292,7 @@ private fun DefaultRoomListTopBar( @Composable private fun NavigationIcon( - avatarData: AvatarData?, + avatarData: AvatarData, showAvatarIndicator: Boolean, onClick: () -> Unit, ) { @@ -304,20 +301,10 @@ private fun NavigationIcon( onClick = onClick, ) { Box { - if (avatarData != null) { - Avatar( - avatarData = avatarData, - contentDescription = stringResource(CommonStrings.common_settings), - ) - } else { - // Placeholder avatar until the avatarData is available - Surface( - modifier = Modifier.size(AvatarSize.CurrentUserTopBar.dp), - shape = CircleShape, - color = ElementTheme.colors.iconSecondary, - content = {} - ) - } + Avatar( + avatarData = avatarData, + contentDescription = stringResource(CommonStrings.common_settings), + ) if (showAvatarIndicator) { RedIndicatorAtom( modifier = Modifier.align(Alignment.TopEnd) diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/Bloom.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/Bloom.kt index ae844a1a45..8558780a22 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/Bloom.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/Bloom.kt @@ -302,7 +302,7 @@ fun Modifier.bloom( /** * Bloom effect modifier for avatars. Applies a bloom effect to the component. * @param avatarData The avatar data to use as the bloom source. - * If the avatar data has a URL it will be used as the bloom source, otherwise the initials will be used. If `null` is passed, no bloom effect will be applied. + * If the avatar data has a URL it will be used as the bloom source, otherwise the initials will be used. * @param background The background color to use for the bloom effect. Since we use blend modes it must be non-transparent. * @param blurSize The size of the bloom effect. If not specified the bloom effect will be the size of the component. * @param offset The offset to use for the bloom effect. If not specified the bloom effect will be centered on the component. @@ -313,7 +313,7 @@ fun Modifier.bloom( * @param alpha The alpha value to apply to the bloom effect. */ fun Modifier.avatarBloom( - avatarData: AvatarData?, + avatarData: AvatarData, background: Color, blurSize: DpSize = DpSize.Unspecified, offset: DpOffset = DpOffset.Unspecified, @@ -327,7 +327,6 @@ fun Modifier.avatarBloom( ) = composed { // Bloom only works on API 29+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) return@composed this - avatarData ?: return@composed this // Request the avatar contents to use as the bloom source val context = LocalContext.current