From 28cbbb7324815900e391de5d97289c66f99e24f0 Mon Sep 17 00:00:00 2001 From: seiko <605590140@qq.com> Date: Fri, 31 Dec 2021 15:02:24 +0800 Subject: [PATCH] add enable parameter to SelectionContainer --- .../component/status/SelectionContainer.kt | 5 +++++ .../twiderex/component/status/StatusText.kt | 16 ++-------------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/common/src/commonMain/kotlin/com/twidere/twiderex/component/status/SelectionContainer.kt b/common/src/commonMain/kotlin/com/twidere/twiderex/component/status/SelectionContainer.kt index dd12ed893..66a6337ba 100644 --- a/common/src/commonMain/kotlin/com/twidere/twiderex/component/status/SelectionContainer.kt +++ b/common/src/commonMain/kotlin/com/twidere/twiderex/component/status/SelectionContainer.kt @@ -45,8 +45,13 @@ class PositionWrapper { @Composable fun SelectionContainer( modifier: Modifier = Modifier, + enable: Boolean = true, content: @Composable (PositionWrapper?) -> Unit, ) { + if (!enable) { + content.invoke(null) + return + } val positionWrapper = remember { if (currentPlatform != Platform.Android) PositionWrapper() else null } diff --git a/common/src/commonMain/kotlin/com/twidere/twiderex/component/status/StatusText.kt b/common/src/commonMain/kotlin/com/twidere/twiderex/component/status/StatusText.kt index e0b95fdbc..2e414d500 100644 --- a/common/src/commonMain/kotlin/com/twidere/twiderex/component/status/StatusText.kt +++ b/common/src/commonMain/kotlin/com/twidere/twiderex/component/status/StatusText.kt @@ -86,19 +86,7 @@ fun ColumnScope.StatusText( } AnimatedVisibility(visible = expanded) { Column { - if (isSelectionAble) { - SelectionContainer { - HtmlText( - modifier = Modifier.fillMaxWidth(), - htmlText = status.htmlText, - maxLines = maxLines, - linkResolver = { href -> - status.resolveLink(href) - }, - positionWrapper = it - ) - } - } else { + SelectionContainer(enable = isSelectionAble) { HtmlText( modifier = Modifier.fillMaxWidth(), htmlText = status.htmlText, @@ -106,7 +94,7 @@ fun ColumnScope.StatusText( linkResolver = { href -> status.resolveLink(href) }, - positionWrapper = null + positionWrapper = it ) } if (showMastodonPoll && status.platformType == PlatformType.Mastodon && status.poll != null) {