Holds the state of expanded text button between edits and translations.
This commit is contained in:
@@ -68,6 +68,7 @@ fun NotifyRequestDialog(
|
|||||||
Modifier.fillMaxWidth(),
|
Modifier.fillMaxWidth(),
|
||||||
EmptyTagList,
|
EmptyTagList,
|
||||||
background,
|
background,
|
||||||
|
textContent,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
nav,
|
nav,
|
||||||
)
|
)
|
||||||
|
|||||||
+11
-2
@@ -20,6 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.vitorpamplona.amethyst.ui.components
|
package com.vitorpamplona.amethyst.ui.components
|
||||||
|
|
||||||
|
import android.util.LruCache
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
@@ -51,6 +52,10 @@ import com.vitorpamplona.amethyst.ui.theme.ButtonPadding
|
|||||||
import com.vitorpamplona.amethyst.ui.theme.secondaryButtonBackground
|
import com.vitorpamplona.amethyst.ui.theme.secondaryButtonBackground
|
||||||
import com.vitorpamplona.quartz.events.ImmutableListOfLists
|
import com.vitorpamplona.quartz.events.ImmutableListOfLists
|
||||||
|
|
||||||
|
object ShowFullTextCache {
|
||||||
|
val cache = LruCache<String, Boolean>(20)
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ExpandableRichTextViewer(
|
fun ExpandableRichTextViewer(
|
||||||
content: String,
|
content: String,
|
||||||
@@ -58,10 +63,11 @@ fun ExpandableRichTextViewer(
|
|||||||
modifier: Modifier,
|
modifier: Modifier,
|
||||||
tags: ImmutableListOfLists<String>,
|
tags: ImmutableListOfLists<String>,
|
||||||
backgroundColor: MutableState<Color>,
|
backgroundColor: MutableState<Color>,
|
||||||
|
id: String,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: (String) -> Unit,
|
nav: (String) -> Unit,
|
||||||
) {
|
) {
|
||||||
var showFullText by remember { mutableStateOf(false) }
|
var showFullText by remember { mutableStateOf(ShowFullTextCache.cache[id] ?: false) }
|
||||||
|
|
||||||
val whereToCut = remember(content) { ExpandableTextCutOffCalculator.indexToCutOff(content) }
|
val whereToCut = remember(content) { ExpandableTextCutOffCalculator.indexToCutOff(content) }
|
||||||
|
|
||||||
@@ -96,7 +102,10 @@ fun ExpandableRichTextViewer(
|
|||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.background(getGradient(backgroundColor)),
|
.background(getGradient(backgroundColor)),
|
||||||
) {
|
) {
|
||||||
ShowMoreButton { showFullText = !showFullText }
|
ShowMoreButton {
|
||||||
|
showFullText = !showFullText
|
||||||
|
ShowFullTextCache.cache.put(id, showFullText)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -641,6 +641,7 @@ private fun RenderRegularTextNote(
|
|||||||
modifier = HalfTopPadding,
|
modifier = HalfTopPadding,
|
||||||
tags = tags,
|
tags = tags,
|
||||||
backgroundColor = backgroundBubbleColor,
|
backgroundColor = backgroundBubbleColor,
|
||||||
|
id = note.idHex,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
@@ -652,6 +653,7 @@ private fun RenderRegularTextNote(
|
|||||||
modifier = HalfTopPadding,
|
modifier = HalfTopPadding,
|
||||||
tags = EmptyTagList,
|
tags = EmptyTagList,
|
||||||
backgroundColor = backgroundBubbleColor,
|
backgroundColor = backgroundBubbleColor,
|
||||||
|
id = note.idHex,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -474,6 +474,7 @@ fun CrossfadeToDisplayComment(
|
|||||||
tags = EmptyTagList,
|
tags = EmptyTagList,
|
||||||
modifier = textBoxModifier,
|
modifier = textBoxModifier,
|
||||||
backgroundColor = backgroundColor,
|
backgroundColor = backgroundColor,
|
||||||
|
id = comment,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -274,6 +274,7 @@ private fun RenderOptionAfterVote(
|
|||||||
Modifier,
|
Modifier,
|
||||||
tags,
|
tags,
|
||||||
backgroundColor,
|
backgroundColor,
|
||||||
|
poolOption.descriptor,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
nav,
|
nav,
|
||||||
)
|
)
|
||||||
@@ -307,6 +308,7 @@ private fun RenderOptionBeforeVote(
|
|||||||
remember { Modifier.padding(15.dp) },
|
remember { Modifier.padding(15.dp) },
|
||||||
tags,
|
tags,
|
||||||
backgroundColor,
|
backgroundColor,
|
||||||
|
id = description,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
nav,
|
nav,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -234,6 +234,7 @@ fun RenderAppDefinition(
|
|||||||
canPreview = false,
|
canPreview = false,
|
||||||
tags = tags,
|
tags = tags,
|
||||||
backgroundColor = backgroundColor,
|
backgroundColor = backgroundColor,
|
||||||
|
id = note.idHex,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -218,6 +218,7 @@ fun AudioHeader(
|
|||||||
canPreview = true,
|
canPreview = true,
|
||||||
tags = tags,
|
tags = tags,
|
||||||
backgroundColor = background,
|
backgroundColor = background,
|
||||||
|
id = note.idHex,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -182,6 +182,7 @@ fun LongCommunityHeader(
|
|||||||
canPreview = false,
|
canPreview = false,
|
||||||
tags = EmptyTagList,
|
tags = EmptyTagList,
|
||||||
backgroundColor = background,
|
backgroundColor = background,
|
||||||
|
id = baseNote.idHex,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
@@ -189,9 +190,9 @@ fun LongCommunityHeader(
|
|||||||
|
|
||||||
if (summary != null && noteEvent.hasHashtags()) {
|
if (summary != null && noteEvent.hasHashtags()) {
|
||||||
DisplayUncitedHashtags(
|
DisplayUncitedHashtags(
|
||||||
remember(noteEvent) { noteEvent.hashtags().toImmutableList() },
|
hashtags = remember(key1 = noteEvent) { noteEvent.hashtags().toImmutableList() },
|
||||||
summary ?: "",
|
eventContent = summary,
|
||||||
nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,6 +183,7 @@ private fun RenderGitPatchEvent(
|
|||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
tags = tags,
|
tags = tags,
|
||||||
backgroundColor = backgroundColor,
|
backgroundColor = backgroundColor,
|
||||||
|
id = note.idHex,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
@@ -281,6 +282,7 @@ private fun RenderGitIssueEvent(
|
|||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
tags = tags,
|
tags = tags,
|
||||||
backgroundColor = backgroundColor,
|
backgroundColor = backgroundColor,
|
||||||
|
id = note.idHex,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ fun DisplayHighlight(
|
|||||||
remember { Modifier.fillMaxWidth() },
|
remember { Modifier.fillMaxWidth() },
|
||||||
EmptyTagList,
|
EmptyTagList,
|
||||||
backgroundColor,
|
backgroundColor,
|
||||||
|
id = quote,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
nav,
|
nav,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ fun RenderPinListEvent(
|
|||||||
canPreview = true,
|
canPreview = true,
|
||||||
tags = EmptyTagList,
|
tags = EmptyTagList,
|
||||||
backgroundColor = backgroundColor,
|
backgroundColor = backgroundColor,
|
||||||
|
id = baseNote.idHex,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ fun RenderPoll(
|
|||||||
modifier = remember { Modifier.fillMaxWidth() },
|
modifier = remember { Modifier.fillMaxWidth() },
|
||||||
tags = tags,
|
tags = tags,
|
||||||
backgroundColor = backgroundColor,
|
backgroundColor = backgroundColor,
|
||||||
|
id = note.idHex,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ fun RenderPrivateMessage(
|
|||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
tags = tags,
|
tags = tags,
|
||||||
backgroundColor = backgroundColor,
|
backgroundColor = backgroundColor,
|
||||||
|
id = note.idHex,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
@@ -111,6 +112,7 @@ fun RenderPrivateMessage(
|
|||||||
Modifier.fillMaxWidth(),
|
Modifier.fillMaxWidth(),
|
||||||
EmptyTagList,
|
EmptyTagList,
|
||||||
backgroundColor,
|
backgroundColor,
|
||||||
|
id = note.idHex,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
nav,
|
nav,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ fun RenderReport(
|
|||||||
modifier = Modifier,
|
modifier = Modifier,
|
||||||
tags = EmptyTagList,
|
tags = EmptyTagList,
|
||||||
backgroundColor = backgroundColor,
|
backgroundColor = backgroundColor,
|
||||||
|
id = note.idHex,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ fun RenderTextEvent(
|
|||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
tags = tags,
|
tags = tags,
|
||||||
backgroundColor = backgroundColor,
|
backgroundColor = backgroundColor,
|
||||||
|
id = note.idHex,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ fun RenderTextModificationEvent(
|
|||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
tags = EmptyTagList,
|
tags = EmptyTagList,
|
||||||
backgroundColor = backgroundColor,
|
backgroundColor = backgroundColor,
|
||||||
|
id = note.idHex,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -166,6 +166,7 @@ fun VideoDisplay(
|
|||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
tags = tags,
|
tags = tags,
|
||||||
backgroundColor = backgroundColor,
|
backgroundColor = backgroundColor,
|
||||||
|
id = note.idHex,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -811,6 +811,7 @@ fun LongChannelHeader(
|
|||||||
canPreview = false,
|
canPreview = false,
|
||||||
tags = tags,
|
tags = tags,
|
||||||
backgroundColor = background,
|
backgroundColor = background,
|
||||||
|
id = baseChannel.idHex,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1103,6 +1103,7 @@ private fun DrawAdditionalInfo(
|
|||||||
canPreview = false,
|
canPreview = false,
|
||||||
tags = EmptyTagList,
|
tags = EmptyTagList,
|
||||||
backgroundColor = background,
|
backgroundColor = background,
|
||||||
|
id = it,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
|
|||||||
+4
@@ -74,6 +74,7 @@ fun TranslatableRichTextViewer(
|
|||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
tags: ImmutableListOfLists<String>,
|
tags: ImmutableListOfLists<String>,
|
||||||
backgroundColor: MutableState<Color>,
|
backgroundColor: MutableState<Color>,
|
||||||
|
id: String,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: (String) -> Unit,
|
nav: (String) -> Unit,
|
||||||
) {
|
) {
|
||||||
@@ -98,6 +99,7 @@ fun TranslatableRichTextViewer(
|
|||||||
modifier,
|
modifier,
|
||||||
tags,
|
tags,
|
||||||
backgroundColor,
|
backgroundColor,
|
||||||
|
id,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
nav,
|
nav,
|
||||||
)
|
)
|
||||||
@@ -112,6 +114,7 @@ private fun RenderText(
|
|||||||
modifier: Modifier,
|
modifier: Modifier,
|
||||||
tags: ImmutableListOfLists<String>,
|
tags: ImmutableListOfLists<String>,
|
||||||
backgroundColor: MutableState<Color>,
|
backgroundColor: MutableState<Color>,
|
||||||
|
id: String,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: (String) -> Unit,
|
nav: (String) -> Unit,
|
||||||
) {
|
) {
|
||||||
@@ -130,6 +133,7 @@ private fun RenderText(
|
|||||||
modifier,
|
modifier,
|
||||||
tags,
|
tags,
|
||||||
backgroundColor,
|
backgroundColor,
|
||||||
|
id,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
nav,
|
nav,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user