feat: 收藏中已被删除贴子提示

This commit is contained in:
HuanCheng65 2023-07-24 12:05:49 +08:00
parent c7c646d7de
commit 2edb341451
No known key found for this signature in database
GPG Key ID: 5EC9DD60A32C7360
3 changed files with 110 additions and 102 deletions

View File

@ -32,7 +32,6 @@ import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.ExperimentalTextApi
import androidx.compose.ui.text.Placeholder
import androidx.compose.ui.text.PlaceholderVerticalAlign
import androidx.compose.ui.text.TextMeasurer
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.font.FontWeight
@ -138,8 +137,6 @@ fun ThreadStorePage(
)
}
) { contentPaddings ->
val textMeasurer = rememberTextMeasurer()
StateScreen(
isEmpty = data.isEmpty(),
isError = isError,
@ -171,16 +168,15 @@ fun ThreadStorePage(
items = data,
key = { it.threadId }
) { info ->
LongClickMenu(
menuContent = {
DropdownMenuItem(onClick = {
viewModel.send(
ThreadStoreUiIntent.Delete(
info.threadId
StoreItem(
info = info,
onUserClick = {
info.author.lzUid?.let {
UserActivity.launch(
context,
it,
StringUtil.getAvatarUrl(info.author.userPortrait)
)
)
}) {
Text(text = stringResource(id = R.string.title_collect_on))
}
},
onClick = {
@ -196,22 +192,15 @@ fun ThreadStorePage(
)
)
)
}
) {
StoreItem(
info = info,
onUserClick = {
info.author.lzUid?.let {
UserActivity.launch(
context,
it,
StringUtil.getAvatarUrl(info.author.userPortrait)
)
}
},
textMeasurer = textMeasurer
onDelete = {
viewModel.send(
ThreadStoreUiIntent.Delete(
info.threadId
)
)
}
)
}
}
}
@ -233,12 +222,21 @@ fun ThreadStorePage(
private fun StoreItem(
info: ThreadStoreBean.ThreadStoreInfo,
onUserClick: () -> Unit,
onDelete: () -> Unit,
onClick: () -> Unit,
modifier: Modifier = Modifier,
textMeasurer: TextMeasurer = rememberTextMeasurer()
) {
val hasUpdate = info.count != "0" && info.postNo != "0"
var width = 0
var height = 0
val hasUpdate = remember(info) { info.count != "0" && info.postNo != "0" }
val isDeleted = remember(info) { info.isDeleted == "1" }
val textMeasurer = rememberTextMeasurer()
LongClickMenu(
menuContent = {
DropdownMenuItem(onClick = onDelete) {
Text(text = stringResource(id = R.string.title_collect_on))
}
},
onClick = onClick
) {
Column(
modifier = modifier
.padding(16.dp),
@ -277,19 +275,18 @@ private fun StoreItem(
id = R.string.tip_thread_store_update,
info.postNo
)
if (hasUpdate) {
val result = textMeasurer.measure(
val result = remember {
textMeasurer.measure(
AnnotatedString(updateTip),
style = UpdateTipTextStyle
)
width =
result.size.width.pxToSp() + 12F.dpToPxFloat().pxToSp() * 2 + 1
height = result.size.height.pxToSp() + 4F.dpToPxFloat().pxToSp() * 2
).size
}
val width = result.width.pxToSp() + 12F.dpToPxFloat().pxToSp() * 2 + 1
val height = result.height.pxToSp() + 4F.dpToPxFloat().pxToSp() * 2
Text(
text = title,
fontSize = 15.sp,
color = ExtendedTheme.colors.text,
color = if (isDeleted) ExtendedTheme.colors.textDisabled else ExtendedTheme.colors.text,
inlineContent = mapOf(
"Update" to InlineTextContent(
placeholder = Placeholder(
@ -318,5 +315,13 @@ private fun StoreItem(
)
)
)
if (isDeleted) {
Text(
text = stringResource(id = R.string.tip_thread_store_deleted),
fontSize = 12.sp,
color = ExtendedTheme.colors.textDisabled
)
}
}
}
}

View File

@ -110,12 +110,13 @@ fun ClickMenu(
fun LongClickMenu(
menuContent: @Composable (ColumnScope.() -> Unit),
modifier: Modifier = Modifier,
enabled: Boolean = true,
menuState: MenuState = rememberMenuState(),
onClick: (() -> Unit)? = null,
shape: Shape = RoundedCornerShape(14.dp),
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
indication: Indication? = LocalIndication.current,
content: @Composable () -> Unit
content: @Composable () -> Unit,
) {
LaunchedEffect(key1 = null) {
launch {
@ -138,6 +139,7 @@ fun LongClickMenu(
.combinedClickable(
interactionSource = interactionSource,
indication = indication,
enabled = enabled,
onLongClick = {
menuState.expanded = true
}

View File

@ -708,4 +708,5 @@
<string name="btn_open_origin_thread">查看原贴</string>
<string name="tip_blocked_thread">由于你的屏蔽设置,该贴已被屏蔽</string>
<string name="desc_picture">图片</string>
<string name="tip_thread_store_deleted">该贴已被删除</string>
</resources>