Browse Source

Simplification since MatrixUser cannot be null anymore.

pull/2565/head
Benoit Marty 6 months ago
parent
commit
a51855a171
  1. 15
      features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RoomListTopBar.kt
  2. 5
      libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/Bloom.kt

15
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.WindowInsets
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.statusBars import androidx.compose.foundation.layout.statusBars
import androidx.compose.foundation.layout.statusBarsPadding import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.TopAppBarDefaults 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.Icon
import io.element.android.libraries.designsystem.theme.components.IconButton 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.MediumTopAppBar
import io.element.android.libraries.designsystem.theme.components.Surface
import io.element.android.libraries.designsystem.theme.components.Text 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.core.UserId
import io.element.android.libraries.matrix.api.user.MatrixUser import io.element.android.libraries.matrix.api.user.MatrixUser
@ -295,7 +292,7 @@ private fun DefaultRoomListTopBar(
@Composable @Composable
private fun NavigationIcon( private fun NavigationIcon(
avatarData: AvatarData?, avatarData: AvatarData,
showAvatarIndicator: Boolean, showAvatarIndicator: Boolean,
onClick: () -> Unit, onClick: () -> Unit,
) { ) {
@ -304,20 +301,10 @@ private fun NavigationIcon(
onClick = onClick, onClick = onClick,
) { ) {
Box { Box {
if (avatarData != null) {
Avatar( Avatar(
avatarData = avatarData, avatarData = avatarData,
contentDescription = stringResource(CommonStrings.common_settings), 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 = {}
)
}
if (showAvatarIndicator) { if (showAvatarIndicator) {
RedIndicatorAtom( RedIndicatorAtom(
modifier = Modifier.align(Alignment.TopEnd) modifier = Modifier.align(Alignment.TopEnd)

5
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. * Bloom effect modifier for avatars. Applies a bloom effect to the component.
* @param avatarData The avatar data to use as the bloom source. * @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 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 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. * @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. * @param alpha The alpha value to apply to the bloom effect.
*/ */
fun Modifier.avatarBloom( fun Modifier.avatarBloom(
avatarData: AvatarData?, avatarData: AvatarData,
background: Color, background: Color,
blurSize: DpSize = DpSize.Unspecified, blurSize: DpSize = DpSize.Unspecified,
offset: DpOffset = DpOffset.Unspecified, offset: DpOffset = DpOffset.Unspecified,
@ -327,7 +327,6 @@ fun Modifier.avatarBloom(
) = composed { ) = composed {
// Bloom only works on API 29+ // Bloom only works on API 29+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) return@composed this 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 // Request the avatar contents to use as the bloom source
val context = LocalContext.current val context = LocalContext.current

Loading…
Cancel
Save