mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-20 14:01:22 +02:00
Declaring observers directly into the Picture Compose
This commit is contained in:
@@ -177,7 +177,11 @@ fun NoteCompose(
|
|||||||
.height(30.dp)
|
.height(30.dp)
|
||||||
.clip(shape = CircleShape)
|
.clip(shape = CircleShape)
|
||||||
.background(MaterialTheme.colors.background)
|
.background(MaterialTheme.colors.background)
|
||||||
.border(2.dp, MaterialTheme.colors.background, CircleShape)
|
.border(
|
||||||
|
2.dp,
|
||||||
|
MaterialTheme.colors.background,
|
||||||
|
CircleShape
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -278,6 +282,9 @@ fun UserPicture(
|
|||||||
pictureModifier: Modifier = Modifier,
|
pictureModifier: Modifier = Modifier,
|
||||||
onClick: (() -> Unit)? = null
|
onClick: (() -> Unit)? = null
|
||||||
) {
|
) {
|
||||||
|
val accountState by userAccount.live.observeAsState()
|
||||||
|
val accountUser = accountState?.user ?: return
|
||||||
|
|
||||||
Box(
|
Box(
|
||||||
Modifier
|
Modifier
|
||||||
.width(size)
|
.width(size)
|
||||||
@@ -293,10 +300,13 @@ fun UserPicture(
|
|||||||
.background(MaterialTheme.colors.background)
|
.background(MaterialTheme.colors.background)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
val userState by user.live.observeAsState()
|
||||||
|
val userLive = userState?.user ?: return
|
||||||
|
|
||||||
AsyncImage(
|
AsyncImage(
|
||||||
model = user.profilePicture(),
|
model = userLive.profilePicture(),
|
||||||
contentDescription = "Profile Image",
|
contentDescription = "Profile Image",
|
||||||
placeholder = rememberAsyncImagePainter("https://robohash.org/${user.pubkeyHex}.png"),
|
placeholder = rememberAsyncImagePainter("https://robohash.org/${userLive.pubkeyHex}.png"),
|
||||||
modifier = pictureModifier
|
modifier = pictureModifier
|
||||||
.fillMaxSize(1f)
|
.fillMaxSize(1f)
|
||||||
.clip(shape = CircleShape)
|
.clip(shape = CircleShape)
|
||||||
@@ -310,21 +320,23 @@ fun UserPicture(
|
|||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if (userAccount.isFollowing(user) || user == userAccount) {
|
if (accountUser.isFollowing(userLive) || userLive == accountUser) {
|
||||||
Box(Modifier
|
Box(
|
||||||
.width(size.div(3.5f))
|
Modifier
|
||||||
.height(size.div(3.5f))
|
.width(size.div(3.5f))
|
||||||
.align(Alignment.TopEnd),
|
.height(size.div(3.5f))
|
||||||
|
.align(Alignment.TopEnd),
|
||||||
contentAlignment = Alignment.Center
|
contentAlignment = Alignment.Center
|
||||||
) {
|
) {
|
||||||
// Background for the transparent checkmark
|
// Background for the transparent checkmark
|
||||||
Text(
|
Text(
|
||||||
"x",
|
"x",
|
||||||
Modifier
|
Modifier
|
||||||
.padding(4.dp).fillMaxSize()
|
.padding(4.dp)
|
||||||
.align(Alignment.Center)
|
.fillMaxSize()
|
||||||
.background(MaterialTheme.colors.background)
|
.align(Alignment.Center)
|
||||||
.clip(shape = CircleShape)
|
.background(MaterialTheme.colors.background)
|
||||||
|
.clip(shape = CircleShape)
|
||||||
)
|
)
|
||||||
|
|
||||||
Icon(
|
Icon(
|
||||||
|
Reference in New Issue
Block a user