RichContent on note preview

This commit is contained in:
Kgothatso Ngako
2026-05-03 23:05:49 +02:00
parent 4c5e1d5f1b
commit d76d36fac9
4 changed files with 34 additions and 10 deletions

View File

@@ -7,6 +7,7 @@ import ac.cord.auxiliary.compose.database.model.Profile
import ac.cord.auxiliary.compose.database.model.QuotedRelation
import ac.cord.auxiliary.compose.database.model.RepostedRelation
import ac.cord.auxiliary.compose.extensions.toFormattedTimeAndDateString
import ac.cord.auxiliary.compose.ui.composable.widgets.content.RichContent
import ac.cord.auxiliary.compose.ui.composable.widgets.profile.ProfileAvatar
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
@@ -25,6 +26,7 @@ import androidx.room3.Embedded
import androidx.room3.Ignore
import androidx.room3.Junction
import androidx.room3.Relation
import com.vitorpamplona.quartz.nip01Core.core.HexKey
data class LocalNostrEvent(
@Embedded val nostrEvent: NostrEvent,
@@ -64,7 +66,9 @@ data class LocalNostrEvent(
val mentionedProfiles: List<LocalMention> = emptyList(),
) {
@Composable
fun RenderNotePreview() {
fun RenderNotePreview(
onNavigateToEvent: (HexKey) -> Unit
) {
Column {
Row(
modifier = Modifier.fillMaxWidth().padding(12.dp),
@@ -94,14 +98,15 @@ data class LocalNostrEvent(
}
}
}
Text(
RichContent(
modifier = Modifier.fillMaxWidth().padding(
horizontal = 20.dp
),
style = MaterialTheme.typography.labelSmall,
textAlign = TextAlign.Start,
overflow = TextOverflow.Ellipsis,
text = nostrEvent.content
nostrEvent = nostrEvent,
localQuotedNostrEvent = localQuotedNostrEvent,
mentionedProfiles = mentionedProfiles,
onNavigateToEvent = onNavigateToEvent
)
Row(
modifier = Modifier.fillMaxWidth().padding(20.dp),

View File

@@ -67,6 +67,7 @@ fun WriteNewNoteScreen(
replyToNostrEventId: HexKey?,
quotedNostrEventId: HexKey?,
onNostrEventPublished: () -> Unit,
onNavigateToNostrEvent: (HexKey) -> Unit,
nostrRepository: NostrRepository
) {
val writeNewNoteViewModel: WriteNewNoteViewModel = viewModel (
@@ -106,7 +107,9 @@ fun WriteNewNoteScreen(
item {
if (writeNewNoteUIState.inReplyToNostrEvent?.nostrEvent?.kind == TextNoteEvent.KIND) {
writeNewNoteUIState.inReplyToNostrEvent.RenderNotePreview()
writeNewNoteUIState.inReplyToNostrEvent.RenderNotePreview(
onNavigateToEvent = onNavigateToNostrEvent
)
} else {
Spacer(
modifier = Modifier.height(1.dp)
@@ -248,7 +251,9 @@ fun WriteNewNoteScreen(
top = 10.dp
)
) {
writeNewNoteUIState.quotedNostrEvent.RenderNotePreview()
writeNewNoteUIState.quotedNostrEvent.RenderNotePreview(
onNavigateToEvent = onNavigateToNostrEvent
)
}
}
}
@@ -295,7 +300,9 @@ fun WriteNewNoteScreen(
if (writeNewNoteUIState.inReplyToNostrEvent?.nostrEvent?.kind == TextNoteEvent.KIND) {
Card {
writeNewNoteUIState.inReplyToNostrEvent.RenderNotePreview()
writeNewNoteUIState.inReplyToNostrEvent.RenderNotePreview(
onNavigateToEvent = onNavigateToNostrEvent
)
}
@@ -375,7 +382,9 @@ fun WriteNewNoteScreen(
if (writeNewNoteUIState.quotedNostrEvent?.nostrEvent?.kind == TextNoteEvent.KIND) {
Card {
writeNewNoteUIState.quotedNostrEvent.RenderNotePreview()
writeNewNoteUIState.quotedNostrEvent.RenderNotePreview(
onNavigateToEvent = onNavigateToNostrEvent
)
}
}
@@ -499,6 +508,7 @@ It has survived not only five centuries, but also the leap into electronic types
)
),
onNostrEventPublished = {},
onNavigateToNostrEvent = {},
nostrRepository = NostrRepository.NO_OP_NOSTR_REPOSITORY)
}
}

View File

@@ -251,6 +251,13 @@ fun AuxNavHost(
navController.popBackStack()
}
},
onNavigateToNostrEvent = { hexKey ->
navController.navigate(
route = NostrEventDetailRoute(
nostrEventId = hexKey
)
)
},
nostrRepository = databaseNostrRepository
)
}

View File

@@ -364,7 +364,9 @@ fun TextNoteEventDetail(
items = inReplyToFeedListUIState.localNostrEvents,
key = { e -> "reply-${e.nostrEvent.id}" }
) { localNostrEvent ->
localNostrEvent.RenderNotePreview()
localNostrEvent.RenderNotePreview(
onNavigateToEvent = onNavigateToNostrEvent
)
}
}
}