From 6fa36255b2b426e805185c5b751a1431fad3d2a3 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Sun, 5 Nov 2023 11:27:15 -0500 Subject: [PATCH] Refining the layout of Author Pictures --- .../amethyst/ui/note/UserProfilePicture.kt | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UserProfilePicture.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UserProfilePicture.kt index 4c8e7020e..d3dd6db22 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UserProfilePicture.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UserProfilePicture.kt @@ -287,31 +287,39 @@ fun BaseUserPicture( innerModifier: Modifier = Modifier, outerModifier: Modifier = remember { Modifier.size(size) } ) { + val myIconSize by remember(size) { + derivedStateOf { + size.div(3.5f) + } + } + Box(outerModifier, contentAlignment = Alignment.TopEnd) { - InnerBaseUserPicture(baseUser, size, accountViewModel, innerModifier) + LoadUserProfilePicture(baseUser) { userProfilePicture -> + InnerUserPicture( + userHex = baseUser.pubkeyHex, + userPicture = userProfilePicture, + size = size, + modifier = innerModifier, + accountViewModel = accountViewModel + ) + } + + ObserveAndDisplayFollowingMark(baseUser.pubkeyHex, myIconSize, accountViewModel) } } @Composable -fun InnerBaseUserPicture( +fun LoadUserProfilePicture( baseUser: User, - size: Dp, - accountViewModel: AccountViewModel, - modifier: Modifier + innerContent: @Composable (String?) -> Unit ) { val userProfile by baseUser.live().profilePictureChanges.observeAsState(baseUser.profilePicture()) - PictureAndFollowingMark( - userHex = baseUser.pubkeyHex, - userPicture = userProfile, - size = size, - modifier = modifier, - accountViewModel = accountViewModel - ) + innerContent(userProfile) } @Composable -fun PictureAndFollowingMark( +fun InnerUserPicture( userHex: String, userPicture: String?, size: Dp, @@ -338,12 +346,6 @@ fun PictureAndFollowingMark( contentScale = ContentScale.Crop, loadProfilePicture = automaticallyShowProfilePicture ) - val myIconSize by remember(size) { - derivedStateOf { - size.div(3.5f) - } - } - ObserveAndDisplayFollowingMark(userHex, myIconSize, accountViewModel) } @Composable @@ -354,9 +356,7 @@ fun ObserveAndDisplayFollowingMark(userHex: String, iconSize: Dp, accountViewMod enter = remember { fadeIn() }, exit = remember { fadeOut() } ) { - Box(contentAlignment = Alignment.TopEnd) { - FollowingIcon(iconSize) - } + FollowingIcon(iconSize) } } }