- Adds picture of the User to the Stream header.
- BugFix for the Click on UserPicture event
This commit is contained in:
@@ -2935,10 +2935,10 @@ private fun DisplayBlankAuthor(size: Dp, modifier: Modifier) {
|
|||||||
@Composable
|
@Composable
|
||||||
fun UserPicture(
|
fun UserPicture(
|
||||||
user: User,
|
user: User,
|
||||||
nav: (String) -> Unit,
|
|
||||||
accountViewModel: AccountViewModel,
|
|
||||||
size: Dp,
|
size: Dp,
|
||||||
pictureModifier: Modifier = Modifier
|
pictureModifier: Modifier = remember { Modifier },
|
||||||
|
accountViewModel: AccountViewModel,
|
||||||
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
val route by remember {
|
val route by remember {
|
||||||
derivedStateOf {
|
derivedStateOf {
|
||||||
@@ -2946,9 +2946,19 @@ fun UserPicture(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ClickableUserPicture(user, size, accountViewModel, pictureModifier) {
|
val scope = rememberCoroutineScope()
|
||||||
nav(route)
|
|
||||||
}
|
ClickableUserPicture(
|
||||||
|
baseUser = user,
|
||||||
|
size = size,
|
||||||
|
accountViewModel = accountViewModel,
|
||||||
|
modifier = pictureModifier,
|
||||||
|
onClick = {
|
||||||
|
scope.launch {
|
||||||
|
nav(route)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalFoundationApi::class)
|
@OptIn(ExperimentalFoundationApi::class)
|
||||||
@@ -2991,7 +3001,7 @@ fun ClickableUserPicture(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Box(modifier = myModifier, contentAlignment = TopEnd) {
|
Box(modifier = myModifier, contentAlignment = TopEnd) {
|
||||||
UserPicture(baseUser, size, accountViewModel, modifier)
|
BaseUserPicture(baseUser, size, accountViewModel, modifier)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3007,12 +3017,12 @@ fun NonClickableUserPicture(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Box(myBoxModifier, contentAlignment = TopEnd) {
|
Box(myBoxModifier, contentAlignment = TopEnd) {
|
||||||
UserPicture(baseUser, size, accountViewModel, modifier)
|
BaseUserPicture(baseUser, size, accountViewModel, modifier)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun UserPicture(
|
fun BaseUserPicture(
|
||||||
baseUser: User,
|
baseUser: User,
|
||||||
size: Dp,
|
size: Dp,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import androidx.compose.foundation.layout.Row
|
|||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material.Divider
|
import androidx.compose.material.Divider
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
@@ -39,7 +38,7 @@ fun UserCompose(
|
|||||||
modifier = overallModifier,
|
modifier = overallModifier,
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
UserPicture(baseUser, nav, accountViewModel, 55.dp)
|
UserPicture(baseUser, 55.dp, accountViewModel = accountViewModel, nav = nav)
|
||||||
|
|
||||||
Column(modifier = Modifier.padding(start = 10.dp).weight(1f)) {
|
Column(modifier = Modifier.padding(start = 10.dp).weight(1f)) {
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ private fun RenderZapNote(
|
|||||||
},
|
},
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
UserPicture(baseAuthor, nav, accountViewModel, 55.dp)
|
UserPicture(baseAuthor, 55.dp, accountViewModel = accountViewModel, nav = nav)
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
modifier = remember {
|
modifier = remember {
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ import com.vitorpamplona.amethyst.ui.components.VideoView
|
|||||||
import com.vitorpamplona.amethyst.ui.navigation.Route
|
import com.vitorpamplona.amethyst.ui.navigation.Route
|
||||||
import com.vitorpamplona.amethyst.ui.note.ChatroomMessageCompose
|
import com.vitorpamplona.amethyst.ui.note.ChatroomMessageCompose
|
||||||
import com.vitorpamplona.amethyst.ui.note.LikeReaction
|
import com.vitorpamplona.amethyst.ui.note.LikeReaction
|
||||||
|
import com.vitorpamplona.amethyst.ui.note.UserPicture
|
||||||
import com.vitorpamplona.amethyst.ui.note.ZapReaction
|
import com.vitorpamplona.amethyst.ui.note.ZapReaction
|
||||||
import com.vitorpamplona.amethyst.ui.screen.NostrChannelFeedViewModel
|
import com.vitorpamplona.amethyst.ui.screen.NostrChannelFeedViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.screen.RefreshingChatroomFeedView
|
import com.vitorpamplona.amethyst.ui.screen.RefreshingChatroomFeedView
|
||||||
@@ -518,7 +519,7 @@ fun ChannelHeader(
|
|||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
var baseChannel by remember { mutableStateOf<Channel?>(LocalCache.channels[channelHex]) }
|
var baseChannel by remember { mutableStateOf(LocalCache.channels[channelHex]) }
|
||||||
|
|
||||||
if (baseChannel == null) {
|
if (baseChannel == null) {
|
||||||
LaunchedEffect(key1 = channelHex) {
|
LaunchedEffect(key1 = channelHex) {
|
||||||
@@ -550,9 +551,11 @@ fun ChannelHeader(
|
|||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
Modifier.fillMaxWidth().clickable {
|
Modifier
|
||||||
nav("Channel/${baseChannel.idHex}")
|
.fillMaxWidth()
|
||||||
}
|
.clickable {
|
||||||
|
nav("Channel/${baseChannel.idHex}")
|
||||||
|
}
|
||||||
) {
|
) {
|
||||||
val channelState by baseChannel.live.observeAsState()
|
val channelState by baseChannel.live.observeAsState()
|
||||||
val channel = remember(channelState) { channelState?.channel } ?: return
|
val channel = remember(channelState) { channelState?.channel } ?: return
|
||||||
@@ -574,6 +577,15 @@ fun ChannelHeader(
|
|||||||
|
|
||||||
Column(modifier = modifier) {
|
Column(modifier = modifier) {
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||||
|
channel.creator?.let {
|
||||||
|
UserPicture(
|
||||||
|
user = it,
|
||||||
|
size = Size35dp,
|
||||||
|
accountViewModel = accountViewModel,
|
||||||
|
nav = nav
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
RobohashAsyncImageProxy(
|
RobohashAsyncImageProxy(
|
||||||
robot = channel.idHex,
|
robot = channel.idHex,
|
||||||
model = channel.profilePicture(),
|
model = channel.profilePicture(),
|
||||||
@@ -581,6 +593,7 @@ fun ChannelHeader(
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.width(Size35dp)
|
.width(Size35dp)
|
||||||
.height(Size35dp)
|
.height(Size35dp)
|
||||||
|
.padding(start = 10.dp)
|
||||||
.clip(shape = CircleShape)
|
.clip(shape = CircleShape)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -592,7 +605,7 @@ fun ChannelHeader(
|
|||||||
) {
|
) {
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||||
Text(
|
Text(
|
||||||
channel.toBestDisplayName(),
|
channel.toBestDisplayName() + channel.idHex.split(":")[2],
|
||||||
fontWeight = FontWeight.Bold,
|
fontWeight = FontWeight.Bold,
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis
|
||||||
|
|||||||
@@ -104,7 +104,6 @@ import com.vitorpamplona.amethyst.ui.theme.placeholderText
|
|||||||
import kotlinx.collections.immutable.toImmutableList
|
import kotlinx.collections.immutable.toImmutableList
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
|
||||||
import java.math.BigDecimal
|
import java.math.BigDecimal
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -116,7 +115,7 @@ fun ProfileScreen(userId: String?, accountViewModel: AccountViewModel, nav: (Str
|
|||||||
if (userBase == null) {
|
if (userBase == null) {
|
||||||
LaunchedEffect(userId) {
|
LaunchedEffect(userId) {
|
||||||
// waits to resolve.
|
// waits to resolve.
|
||||||
withContext(Dispatchers.IO) {
|
launch(Dispatchers.IO) {
|
||||||
val newUserBase = LocalCache.checkGetOrCreateUser(userId)
|
val newUserBase = LocalCache.checkGetOrCreateUser(userId)
|
||||||
if (newUserBase != userBase) {
|
if (newUserBase != userBase) {
|
||||||
userBase = newUserBase
|
userBase = newUserBase
|
||||||
|
|||||||
Reference in New Issue
Block a user