Adds the full list of URLs to the Desktop app
This commit is contained in:
+7
-6
@@ -44,7 +44,8 @@ import androidx.compose.ui.text.style.TextDecoration
|
|||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.text.withStyle
|
import androidx.compose.ui.text.withStyle
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.vitorpamplona.amethyst.commons.richtext.RichTextParser
|
import com.vitorpamplona.amethyst.commons.richtext.UrlParser
|
||||||
|
import com.vitorpamplona.amethyst.commons.richtext.Urls
|
||||||
import com.vitorpamplona.amethyst.commons.ui.components.UserAvatar
|
import com.vitorpamplona.amethyst.commons.ui.components.UserAvatar
|
||||||
import com.vitorpamplona.amethyst.commons.util.toTimeAgo
|
import com.vitorpamplona.amethyst.commons.util.toTimeAgo
|
||||||
|
|
||||||
@@ -71,8 +72,7 @@ fun NoteCard(
|
|||||||
onClick: (() -> Unit)? = null,
|
onClick: (() -> Unit)? = null,
|
||||||
onAuthorClick: ((String) -> Unit)? = null,
|
onAuthorClick: ((String) -> Unit)? = null,
|
||||||
) {
|
) {
|
||||||
val richTextParser = remember { RichTextParser() }
|
val urls = remember(note.content) { UrlParser().parseValidUrls(note.content) }
|
||||||
val urls = remember(note.content) { richTextParser.parseValidUrls(note.content) }
|
|
||||||
|
|
||||||
Card(
|
Card(
|
||||||
modifier = modifier.fillMaxWidth(),
|
modifier = modifier.fillMaxWidth(),
|
||||||
@@ -154,11 +154,11 @@ fun NoteCard(
|
|||||||
@Composable
|
@Composable
|
||||||
fun RichTextContent(
|
fun RichTextContent(
|
||||||
content: String,
|
content: String,
|
||||||
urls: Set<String>,
|
urls: Urls,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
maxLines: Int = 10,
|
maxLines: Int = 10,
|
||||||
) {
|
) {
|
||||||
if (urls.isEmpty()) {
|
if (urls.withScheme.isEmpty()) {
|
||||||
Text(
|
Text(
|
||||||
text = content,
|
text = content,
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
@@ -171,7 +171,8 @@ fun RichTextContent(
|
|||||||
val annotatedText =
|
val annotatedText =
|
||||||
buildAnnotatedString {
|
buildAnnotatedString {
|
||||||
var lastIndex = 0
|
var lastIndex = 0
|
||||||
val sortedUrls = urls.sortedBy { content.indexOf(it) }
|
// TODO: User the other urls.
|
||||||
|
val sortedUrls = urls.withScheme.sortedBy { content.indexOf(it) }
|
||||||
|
|
||||||
for (url in sortedUrls) {
|
for (url in sortedUrls) {
|
||||||
val startIndex = content.indexOf(url, lastIndex)
|
val startIndex = content.indexOf(url, lastIndex)
|
||||||
|
|||||||
Reference in New Issue
Block a user