feat: 收藏楼层提示
This commit is contained in:
parent
a5e365a9d9
commit
70907c211c
|
|
@ -118,6 +118,7 @@ import com.huanchengfly.tieba.post.ui.page.destinations.ForumPageDestination
|
|||
import com.huanchengfly.tieba.post.ui.page.destinations.ReplyPageDestination
|
||||
import com.huanchengfly.tieba.post.ui.page.destinations.SubPostsSheetPageDestination
|
||||
import com.huanchengfly.tieba.post.ui.page.destinations.ThreadPageDestination
|
||||
import com.huanchengfly.tieba.post.ui.widgets.Chip
|
||||
import com.huanchengfly.tieba.post.ui.widgets.compose.Avatar
|
||||
import com.huanchengfly.tieba.post.ui.widgets.compose.BackNavigationIcon
|
||||
import com.huanchengfly.tieba.post.ui.widgets.compose.Button
|
||||
|
|
@ -916,6 +917,42 @@ fun ThreadPage(
|
|||
postHolder = firstPost!!,
|
||||
contentRenders = firstPostContentRenders,
|
||||
immersiveMode = isImmersiveMode,
|
||||
isCollected = {
|
||||
it.id == thread?.get { collectMarkPid }
|
||||
?.toLongOrNull()
|
||||
},
|
||||
showSubPosts = false,
|
||||
onReplyClick = {
|
||||
navigator.navigate(
|
||||
ReplyPageDestination(
|
||||
forumId = curForumId ?: 0,
|
||||
forumName = forum?.get { name }
|
||||
.orEmpty(),
|
||||
threadId = threadId,
|
||||
)
|
||||
)
|
||||
},
|
||||
onMenuCopyClick = {
|
||||
TiebaUtil.copyText(
|
||||
context,
|
||||
it.content.plainText
|
||||
)
|
||||
},
|
||||
onMenuReportClick = {
|
||||
TiebaUtil.reportPost(
|
||||
context,
|
||||
it.id.toString()
|
||||
)
|
||||
},
|
||||
onMenuFavoriteClick = {
|
||||
viewModel.send(
|
||||
ThreadUiIntent.AddFavorite(
|
||||
threadId,
|
||||
it.id,
|
||||
it.floor
|
||||
)
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
VerticalDivider(
|
||||
|
|
@ -1421,7 +1458,7 @@ fun PostCard(
|
|||
if (isCollected(post)) {
|
||||
Text(text = stringResource(id = R.string.title_collect_on))
|
||||
} else {
|
||||
Text(text = stringResource(id = R.string.title_collect))
|
||||
Text(text = stringResource(id = R.string.title_collect_floor))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1507,6 +1544,20 @@ fun PostCard(
|
|||
)
|
||||
}
|
||||
|
||||
if (isCollected(post)) {
|
||||
Chip(
|
||||
text = stringResource(id = R.string.title_collected_floor),
|
||||
invertColor = true,
|
||||
icon = {
|
||||
Icon(
|
||||
imageVector = Icons.Rounded.Star,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(16.dp)
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
contentRenders.forEach { it.Render() }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,14 @@ package com.huanchengfly.tieba.post.ui.widgets
|
|||
|
||||
import androidx.compose.animation.animateColorAsState
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Shape
|
||||
|
|
@ -16,13 +19,15 @@ import androidx.compose.ui.unit.sp
|
|||
import com.huanchengfly.tieba.post.ui.common.theme.compose.ExtendedTheme
|
||||
import com.huanchengfly.tieba.post.ui.common.theme.compose.invertChipBackground
|
||||
import com.huanchengfly.tieba.post.ui.common.theme.compose.invertChipContent
|
||||
import com.huanchengfly.tieba.post.ui.widgets.compose.ProvideContentColor
|
||||
|
||||
@Composable
|
||||
fun Chip(
|
||||
text: String,
|
||||
modifier: Modifier = Modifier,
|
||||
icon: @Composable (() -> Unit)? = null,
|
||||
invertColor: Boolean = false,
|
||||
shape: Shape = RoundedCornerShape(100)
|
||||
shape: Shape = RoundedCornerShape(100),
|
||||
) {
|
||||
val color =
|
||||
if (invertColor) ExtendedTheme.colors.invertChipContent else ExtendedTheme.colors.onChip
|
||||
|
|
@ -35,14 +40,21 @@ fun Chip(
|
|||
label = "ChipBackgroundColor"
|
||||
)
|
||||
|
||||
Text(
|
||||
color = animatedColor,
|
||||
fontSize = 12.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
text = text,
|
||||
modifier = modifier
|
||||
.clip(shape)
|
||||
.background(color = animatedBackgroundColor)
|
||||
.padding(horizontal = 16.dp, vertical = 4.dp)
|
||||
)
|
||||
ProvideContentColor(color = animatedColor) {
|
||||
Row(
|
||||
modifier = modifier
|
||||
.clip(shape)
|
||||
.background(color = animatedBackgroundColor)
|
||||
.padding(horizontal = 16.dp, vertical = 4.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
icon?.invoke()
|
||||
Text(
|
||||
fontSize = 12.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
text = text
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -697,4 +697,6 @@
|
|||
<string name="title_image_watermark_forum_name">显示吧名</string>
|
||||
<string name="title_modify_username">修改用户名</string>
|
||||
<string name="btn_reply">回复</string>
|
||||
<string name="title_collect_floor">收藏到此楼</string>
|
||||
<string name="title_collected_floor">已收藏到本楼</string>
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Reference in New Issue