@Composable public fun Avatar( imageUrl: String, initials: String, modifier: Modifier = Modifier, shape: Shape = ChatTheme.shapes.avatar, textStyle: TextStyle = ChatTheme.typography.title3Bold, placeholderPainter: Painter? = null, contentDescription: String? = null, initialsAvatarOffset: DpOffset = DpOffset(0.dp, 0.dp), onClick: (() -> Unit)? = null, ) { if (LocalInspectionMode.current && imageUrl.isNotBlank()) { ImageAvatar( modifier = modifier, shape = shape, painter = painterResource(id = R.drawable.stream_compose_preview_avatar), contentDescription = contentDescription,onClick = onClick)return}if (imageUrl.isBlank()) {InitialsAvatar(modifier = modifier, initials = initials, shape = shape,textStyle = textStyle,onClick = onClick,avatarOffset = initialsAvatarOffset)return}val painter = rememberStreamImagePainter(data = imageUrl,placeholderPainter = painterResource(id = R.drawable.stream_compose_preview_avatar))if (painter.state is AsyncImagePainter.State.Error)  {InitialsAvatar( modifier = modifier, initials = initials, shape = shape, textStyle = textStyle, onClick = onClick, avatarOffset = initialsAvatarOffset ) } else if (painter.state is AsyncImagePainter.State.Loading && placeholderPainter != null) { ImageAvatar( modifier = modifier, shape = shape, painter = placeholderPainter, contentDescription = contentDescription, onClick = onClick ) } else { ImageAvatar( modifier = modifier, shape = shape, painter = painter, contentDescription = contentDescription, onClick = onClick ) } }
An avatar that renders an image from the provided image URL. In case the image URL was empty or there was an error loading the image, it falls back to the initials avatar.