diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt index b9baaad6f..9d97ef9cc 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt @@ -109,7 +109,7 @@ fun NoteCompose(baseNote: Note, modifier: Modifier = Modifier, isInnerNote: Bool Column(modifier = Modifier.padding(start = if (!isInnerNote) 10.dp else 0.dp) .clickable(onClick = { - note?.let { + note.let { navController.navigate("Note/${note.idHex}") } }) @@ -133,7 +133,7 @@ fun NoteCompose(baseNote: Note, modifier: Modifier = Modifier, isInnerNote: Bool } if (note.event is TextNoteEvent && (note.replyTo != null || note.mentions != null)) { - ReplyInformation(note.replyTo, note.mentions) + ReplyInformation(note.replyTo, note.mentions, navController) } if (note.event is ReactionEvent || note.event is RepostEvent) { diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReplyInformation.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReplyInformation.kt index 273e46b5d..49f11f524 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReplyInformation.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReplyInformation.kt @@ -1,61 +1,65 @@ package com.vitorpamplona.amethyst.ui.note +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.foundation.text.ClickableText +import androidx.compose.material.LocalTextStyle import androidx.compose.material.MaterialTheme import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.livedata.observeAsState +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.text.AnnotatedString +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import androidx.navigation.NavController import com.google.accompanist.flowlayout.FlowRow import com.vitorpamplona.amethyst.model.Note import com.vitorpamplona.amethyst.model.User @Composable -fun ReplyInformation(replyTo: MutableList?, mentions: List?) { +fun ReplyInformation(replyTo: MutableList?, mentions: List?, navController: NavController) { FlowRow() { - /* - if (replyTo != null && replyTo.isNotEmpty()) { - Text( - " in reply to ", - fontSize = 13.sp, - color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f) - ) - replyTo.toSet().forEachIndexed { idx, note -> - val innerNoteState by note.live.observeAsState() - Text( - "${innerNoteState?.note?.idDisplayHex}${if (idx < replyTo.size - 1) ", " else ""}", - fontSize = 13.sp, - color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f) - ) - } - } - */ if (mentions != null && mentions.isNotEmpty()) { - Text( - "replying to ", - fontSize = 13.sp, - color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f) - ) - mentions.toSet().forEachIndexed { idx, user -> - val innerUserState by user.live.observeAsState() + if (replyTo != null && replyTo.isNotEmpty()) { Text( - "${innerUserState?.user?.toBestDisplayName()}", + "replying to ", fontSize = 13.sp, color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f) ) - if (idx < mentions.size - 2) { - Text( - ", ", - fontSize = 13.sp, - color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f) - ) - } else if (idx < mentions.size - 1) { - Text( - " and ", - fontSize = 13.sp, - color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f) - ) + mentions.toSet().forEachIndexed { idx, user -> + val innerUserState by user.live.observeAsState() + val innerUser = innerUserState?.user + + innerUser?.let { myUser -> + ClickableText( + AnnotatedString("@${myUser.toBestDisplayName()}"), + style = LocalTextStyle.current.copy(color = MaterialTheme.colors.primary.copy(alpha = 0.52f), fontSize = 13.sp), + onClick = { + navController.navigate("User/${myUser.pubkeyHex}") + } + ) + + if (idx < mentions.size - 2) { + Text( + ", ", + fontSize = 13.sp, + color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f) + ) + } else if (idx < mentions.size - 1) { + Text( + " and ", + fontSize = 13.sp, + color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f) + ) + } + } } } }