feat(SearchPost): 跳转原贴

This commit is contained in:
HuanCheng65 2024-01-29 12:56:34 +08:00
parent 1761507ba3
commit f310f58828
No known key found for this signature in database
GPG Key ID: 5EC9DD60A32C7360
5 changed files with 73 additions and 13 deletions

View File

@ -35,6 +35,7 @@ data class SearchThreadBean(
data class ThreadInfoBean(
val tid: String,
val pid: String,
val cid: String,
val title: String,
val content: String,
val time: String,
@ -74,18 +75,22 @@ data class SearchThreadBean(
@Serializable
data class MediaInfo(
val type: String,
val size: String,
val size: String? = null,
val width: String,
val height: String,
@SerialName("water_pic")
@SerializedName("water_pic")
val waterPic: String,
val waterPic: String? = null,
@SerialName("small_pic")
@SerializedName("small_pic")
val smallPic: String,
val smallPic: String? = null,
@SerialName("big_pic")
@SerializedName("big_pic")
val bigPic: String,
val bigPic: String? = null,
val src: String? = null,
val vsrc: String? = null,
val vhsrc: String? = null,
val vpic: String? = null,
)
@Immutable

View File

@ -47,6 +47,7 @@ import com.huanchengfly.tieba.post.ui.page.destinations.UserProfilePageDestinati
import com.huanchengfly.tieba.post.ui.widgets.compose.EmoticonText
import com.huanchengfly.tieba.post.ui.widgets.compose.NetworkImage
import com.huanchengfly.tieba.post.ui.widgets.compose.VoicePlayer
import com.huanchengfly.tieba.post.utils.EmoticonUtil.emoticonString
import com.huanchengfly.tieba.post.utils.appPreferences
import com.huanchengfly.tieba.post.utils.launchUrl
@ -245,7 +246,7 @@ fun PbContentText(
style: TextStyle = LocalTextStyle.current,
) {
PbContentText(
text = AnnotatedString(text),
text = text.emoticonString,
modifier = modifier,
color = color,
fontSize = fontSize,

View File

@ -27,6 +27,7 @@ import androidx.compose.material.pullrefresh.pullRefresh
import androidx.compose.material.pullrefresh.rememberPullRefreshState
import androidx.compose.material.ripple.rememberRipple
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@ -51,6 +52,7 @@ import com.huanchengfly.tieba.post.ui.common.theme.compose.ExtendedTheme
import com.huanchengfly.tieba.post.ui.common.theme.compose.pullRefreshIndicator
import com.huanchengfly.tieba.post.ui.page.ProvideNavigator
import com.huanchengfly.tieba.post.ui.page.destinations.ForumPageDestination
import com.huanchengfly.tieba.post.ui.page.destinations.SubPostsPageDestination
import com.huanchengfly.tieba.post.ui.page.destinations.ThreadPageDestination
import com.huanchengfly.tieba.post.ui.page.destinations.UserProfilePageDestination
import com.huanchengfly.tieba.post.ui.widgets.compose.ClickMenu
@ -126,6 +128,12 @@ fun ForumSearchPostPage(
}
var inputKeyword by remember { mutableStateOf("") }
LaunchedEffect(currentKeyword) {
if (currentKeyword.isNotEmpty() && currentKeyword != inputKeyword) {
inputKeyword = currentKeyword
}
}
fun refresh() {
viewModel.send(
ForumSearchPostUiIntent.Refresh(
@ -266,11 +274,29 @@ fun ForumSearchPostPage(
data = data,
lazyListState = lazyListState,
onItemClick = {
if (it.postInfo != null) {
navigator.navigate(
SubPostsPageDestination(
threadId = it.tid.toLong(),
subPostId = it.cid.toLong(),
loadFromSubPost = true
)
)
} else if (it.mainPost != null) {
navigator.navigate(
ThreadPageDestination(
threadId = it.tid.toLong(),
postId = it.pid.toLong(),
scrollToReply = true,
)
)
} else {
navigator.navigate(
ThreadPageDestination(
threadId = it.tid.toLong()
)
)
}
},
onItemUserClick = {
navigator.navigate(UserProfilePageDestination(it.userId.toLong()))
@ -282,6 +308,23 @@ fun ForumSearchPostPage(
)
)
},
onQuotePostClick = {
navigator.navigate(
ThreadPageDestination(
threadId = it.tid,
postId = it.pid,
scrollToReply = true
)
)
},
onMainPostClick = {
navigator.navigate(
ThreadPageDestination(
threadId = it.tid,
scrollToReply = true
)
)
},
hideForum = true,
) {
stickyHeader(key = "Sort&Filter") {

View File

@ -270,6 +270,7 @@ fun ThreadContent(
showTitle: Boolean = true,
showAbstract: Boolean = true,
isGood: Boolean = false,
maxLines: Int = 5,
) {
val content = buildAnnotatedString {
if (showTitle) {
@ -305,7 +306,7 @@ fun ThreadContent(
fontSize = 15.sp,
lineSpacing = 0.8.sp,
overflow = TextOverflow.Ellipsis,
maxLines = 5,
maxLines = maxLines,
style = MaterialTheme.typography.body1,
)
}

View File

@ -78,7 +78,6 @@ fun QuotePostCard(
PbContentText(
text = quoteContentString,
style = MaterialTheme.typography.body2,
modifier = modifier,
maxLines = 2,
overflow = TextOverflow.Ellipsis,
)
@ -113,7 +112,6 @@ fun MainPostCard(
text = titleString,
style = MaterialTheme.typography.subtitle2,
fontWeight = FontWeight.Bold,
modifier = modifier,
maxLines = 2,
overflow = TextOverflow.Ellipsis,
)
@ -121,7 +119,6 @@ fun MainPostCard(
PbContentText(
text = mainPost.content,
style = MaterialTheme.typography.body2,
modifier = modifier,
maxLines = 2,
overflow = TextOverflow.Ellipsis,
)
@ -137,6 +134,8 @@ fun SearchThreadList(
onItemUserClick: (SearchThreadBean.UserInfoBean) -> Unit,
onItemForumClick: (SearchThreadBean.ForumInfo) -> Unit,
modifier: Modifier = Modifier,
onQuotePostClick: (SearchThreadBean.PostInfo) -> Unit = {},
onMainPostClick: (SearchThreadBean.MainPost) -> Unit = {},
hideForum: Boolean = false,
header: LazyListScope.() -> Unit = {},
) {
@ -155,6 +154,8 @@ fun SearchThreadList(
onUserClick = onItemUserClick,
onForumClick = onItemForumClick,
hideForum = hideForum,
onQuotePostClick = onQuotePostClick,
onMainPostClick = onMainPostClick,
)
}
}
@ -202,6 +203,8 @@ fun SearchThreadItem(
onUserClick: (SearchThreadBean.UserInfoBean) -> Unit,
onForumClick: (SearchThreadBean.ForumInfo) -> Unit,
modifier: Modifier = Modifier,
onQuotePostClick: (SearchThreadBean.PostInfo) -> Unit = {},
onMainPostClick: (SearchThreadBean.MainPost) -> Unit = {},
hideForum: Boolean = false,
) {
Card(
@ -219,6 +222,7 @@ fun SearchThreadItem(
abstractText = item.content,
showTitle = item.mainPost == null && item.title.isNotBlank(),
showAbstract = item.content.isNotBlank(),
maxLines = 2,
)
if (item.mainPost != null) {
if (item.postInfo != null) {
@ -229,6 +233,9 @@ fun SearchThreadItem(
.fillMaxWidth()
.clip(RoundedCornerShape(6.dp))
.background(ExtendedTheme.colors.floorCard)
.clickable {
onQuotePostClick(item.postInfo)
}
)
} else {
MainPostCard(
@ -237,6 +244,9 @@ fun SearchThreadItem(
.fillMaxWidth()
.clip(RoundedCornerShape(6.dp))
.background(ExtendedTheme.colors.floorCard)
.clickable {
onMainPostClick(item.mainPost)
}
)
}
}