mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 21:32:34 +00:00
Extract UserAvatar to its own file.
This commit is contained in:
-27
@@ -57,33 +57,6 @@ fun Avatar(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
|
||||||
private fun UserAvatar(
|
|
||||||
avatarData: AvatarData,
|
|
||||||
modifier: Modifier = Modifier,
|
|
||||||
contentDescription: String? = null,
|
|
||||||
forcedAvatarSize: Dp? = null,
|
|
||||||
hideImage: Boolean = false,
|
|
||||||
) {
|
|
||||||
if (avatarData.url.isNullOrBlank() || hideImage) {
|
|
||||||
InitialLetterAvatar(
|
|
||||||
avatarData = avatarData,
|
|
||||||
avatarType = AvatarType.User,
|
|
||||||
forcedAvatarSize = forcedAvatarSize,
|
|
||||||
modifier = modifier,
|
|
||||||
contentDescription = contentDescription,
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
ImageAvatar(
|
|
||||||
avatarData = avatarData,
|
|
||||||
avatarType = AvatarType.User,
|
|
||||||
forcedAvatarSize = forcedAvatarSize,
|
|
||||||
modifier = modifier,
|
|
||||||
contentDescription = contentDescription,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Preview(group = PreviewGroup.Avatars)
|
@Preview(group = PreviewGroup.Avatars)
|
||||||
@Composable
|
@Composable
|
||||||
internal fun AvatarPreview(@PreviewParameter(AvatarDataProvider::class) avatarData: AvatarData) =
|
internal fun AvatarPreview(@PreviewParameter(AvatarDataProvider::class) avatarData: AvatarData) =
|
||||||
|
|||||||
+39
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2025 New Vector Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||||
|
* Please see LICENSE files in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.libraries.designsystem.components.avatar
|
||||||
|
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.unit.Dp
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
internal fun UserAvatar(
|
||||||
|
avatarData: AvatarData,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
contentDescription: String? = null,
|
||||||
|
forcedAvatarSize: Dp? = null,
|
||||||
|
hideImage: Boolean = false,
|
||||||
|
) {
|
||||||
|
if (avatarData.url.isNullOrBlank() || hideImage) {
|
||||||
|
InitialLetterAvatar(
|
||||||
|
avatarData = avatarData,
|
||||||
|
avatarType = AvatarType.User,
|
||||||
|
forcedAvatarSize = forcedAvatarSize,
|
||||||
|
modifier = modifier,
|
||||||
|
contentDescription = contentDescription,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
ImageAvatar(
|
||||||
|
avatarData = avatarData,
|
||||||
|
avatarType = AvatarType.User,
|
||||||
|
forcedAvatarSize = forcedAvatarSize,
|
||||||
|
modifier = modifier,
|
||||||
|
contentDescription = contentDescription,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user