feat(SearchPost): 跳转原贴
This commit is contained in:
parent
1761507ba3
commit
f310f58828
|
|
@ -35,6 +35,7 @@ data class SearchThreadBean(
|
||||||
data class ThreadInfoBean(
|
data class ThreadInfoBean(
|
||||||
val tid: String,
|
val tid: String,
|
||||||
val pid: String,
|
val pid: String,
|
||||||
|
val cid: String,
|
||||||
val title: String,
|
val title: String,
|
||||||
val content: String,
|
val content: String,
|
||||||
val time: String,
|
val time: String,
|
||||||
|
|
@ -74,18 +75,22 @@ data class SearchThreadBean(
|
||||||
@Serializable
|
@Serializable
|
||||||
data class MediaInfo(
|
data class MediaInfo(
|
||||||
val type: String,
|
val type: String,
|
||||||
val size: String,
|
val size: String? = null,
|
||||||
val width: String,
|
val width: String,
|
||||||
val height: String,
|
val height: String,
|
||||||
@SerialName("water_pic")
|
@SerialName("water_pic")
|
||||||
@SerializedName("water_pic")
|
@SerializedName("water_pic")
|
||||||
val waterPic: String,
|
val waterPic: String? = null,
|
||||||
@SerialName("small_pic")
|
@SerialName("small_pic")
|
||||||
@SerializedName("small_pic")
|
@SerializedName("small_pic")
|
||||||
val smallPic: String,
|
val smallPic: String? = null,
|
||||||
@SerialName("big_pic")
|
@SerialName("big_pic")
|
||||||
@SerializedName("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
|
@Immutable
|
||||||
|
|
|
||||||
|
|
@ -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.EmoticonText
|
||||||
import com.huanchengfly.tieba.post.ui.widgets.compose.NetworkImage
|
import com.huanchengfly.tieba.post.ui.widgets.compose.NetworkImage
|
||||||
import com.huanchengfly.tieba.post.ui.widgets.compose.VoicePlayer
|
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.appPreferences
|
||||||
import com.huanchengfly.tieba.post.utils.launchUrl
|
import com.huanchengfly.tieba.post.utils.launchUrl
|
||||||
|
|
||||||
|
|
@ -245,7 +246,7 @@ fun PbContentText(
|
||||||
style: TextStyle = LocalTextStyle.current,
|
style: TextStyle = LocalTextStyle.current,
|
||||||
) {
|
) {
|
||||||
PbContentText(
|
PbContentText(
|
||||||
text = AnnotatedString(text),
|
text = text.emoticonString,
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
color = color,
|
color = color,
|
||||||
fontSize = fontSize,
|
fontSize = fontSize,
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import androidx.compose.material.pullrefresh.pullRefresh
|
||||||
import androidx.compose.material.pullrefresh.rememberPullRefreshState
|
import androidx.compose.material.pullrefresh.rememberPullRefreshState
|
||||||
import androidx.compose.material.ripple.rememberRipple
|
import androidx.compose.material.ripple.rememberRipple
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.derivedStateOf
|
import androidx.compose.runtime.derivedStateOf
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
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.common.theme.compose.pullRefreshIndicator
|
||||||
import com.huanchengfly.tieba.post.ui.page.ProvideNavigator
|
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.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.ThreadPageDestination
|
||||||
import com.huanchengfly.tieba.post.ui.page.destinations.UserProfilePageDestination
|
import com.huanchengfly.tieba.post.ui.page.destinations.UserProfilePageDestination
|
||||||
import com.huanchengfly.tieba.post.ui.widgets.compose.ClickMenu
|
import com.huanchengfly.tieba.post.ui.widgets.compose.ClickMenu
|
||||||
|
|
@ -126,6 +128,12 @@ fun ForumSearchPostPage(
|
||||||
}
|
}
|
||||||
var inputKeyword by remember { mutableStateOf("") }
|
var inputKeyword by remember { mutableStateOf("") }
|
||||||
|
|
||||||
|
LaunchedEffect(currentKeyword) {
|
||||||
|
if (currentKeyword.isNotEmpty() && currentKeyword != inputKeyword) {
|
||||||
|
inputKeyword = currentKeyword
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun refresh() {
|
fun refresh() {
|
||||||
viewModel.send(
|
viewModel.send(
|
||||||
ForumSearchPostUiIntent.Refresh(
|
ForumSearchPostUiIntent.Refresh(
|
||||||
|
|
@ -266,11 +274,29 @@ fun ForumSearchPostPage(
|
||||||
data = data,
|
data = data,
|
||||||
lazyListState = lazyListState,
|
lazyListState = lazyListState,
|
||||||
onItemClick = {
|
onItemClick = {
|
||||||
navigator.navigate(
|
if (it.postInfo != null) {
|
||||||
ThreadPageDestination(
|
navigator.navigate(
|
||||||
threadId = it.tid.toLong()
|
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 = {
|
onItemUserClick = {
|
||||||
navigator.navigate(UserProfilePageDestination(it.userId.toLong()))
|
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,
|
hideForum = true,
|
||||||
) {
|
) {
|
||||||
stickyHeader(key = "Sort&Filter") {
|
stickyHeader(key = "Sort&Filter") {
|
||||||
|
|
|
||||||
|
|
@ -270,6 +270,7 @@ fun ThreadContent(
|
||||||
showTitle: Boolean = true,
|
showTitle: Boolean = true,
|
||||||
showAbstract: Boolean = true,
|
showAbstract: Boolean = true,
|
||||||
isGood: Boolean = false,
|
isGood: Boolean = false,
|
||||||
|
maxLines: Int = 5,
|
||||||
) {
|
) {
|
||||||
val content = buildAnnotatedString {
|
val content = buildAnnotatedString {
|
||||||
if (showTitle) {
|
if (showTitle) {
|
||||||
|
|
@ -305,7 +306,7 @@ fun ThreadContent(
|
||||||
fontSize = 15.sp,
|
fontSize = 15.sp,
|
||||||
lineSpacing = 0.8.sp,
|
lineSpacing = 0.8.sp,
|
||||||
overflow = TextOverflow.Ellipsis,
|
overflow = TextOverflow.Ellipsis,
|
||||||
maxLines = 5,
|
maxLines = maxLines,
|
||||||
style = MaterialTheme.typography.body1,
|
style = MaterialTheme.typography.body1,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,6 @@ fun QuotePostCard(
|
||||||
PbContentText(
|
PbContentText(
|
||||||
text = quoteContentString,
|
text = quoteContentString,
|
||||||
style = MaterialTheme.typography.body2,
|
style = MaterialTheme.typography.body2,
|
||||||
modifier = modifier,
|
|
||||||
maxLines = 2,
|
maxLines = 2,
|
||||||
overflow = TextOverflow.Ellipsis,
|
overflow = TextOverflow.Ellipsis,
|
||||||
)
|
)
|
||||||
|
|
@ -113,7 +112,6 @@ fun MainPostCard(
|
||||||
text = titleString,
|
text = titleString,
|
||||||
style = MaterialTheme.typography.subtitle2,
|
style = MaterialTheme.typography.subtitle2,
|
||||||
fontWeight = FontWeight.Bold,
|
fontWeight = FontWeight.Bold,
|
||||||
modifier = modifier,
|
|
||||||
maxLines = 2,
|
maxLines = 2,
|
||||||
overflow = TextOverflow.Ellipsis,
|
overflow = TextOverflow.Ellipsis,
|
||||||
)
|
)
|
||||||
|
|
@ -121,7 +119,6 @@ fun MainPostCard(
|
||||||
PbContentText(
|
PbContentText(
|
||||||
text = mainPost.content,
|
text = mainPost.content,
|
||||||
style = MaterialTheme.typography.body2,
|
style = MaterialTheme.typography.body2,
|
||||||
modifier = modifier,
|
|
||||||
maxLines = 2,
|
maxLines = 2,
|
||||||
overflow = TextOverflow.Ellipsis,
|
overflow = TextOverflow.Ellipsis,
|
||||||
)
|
)
|
||||||
|
|
@ -137,6 +134,8 @@ fun SearchThreadList(
|
||||||
onItemUserClick: (SearchThreadBean.UserInfoBean) -> Unit,
|
onItemUserClick: (SearchThreadBean.UserInfoBean) -> Unit,
|
||||||
onItemForumClick: (SearchThreadBean.ForumInfo) -> Unit,
|
onItemForumClick: (SearchThreadBean.ForumInfo) -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
|
onQuotePostClick: (SearchThreadBean.PostInfo) -> Unit = {},
|
||||||
|
onMainPostClick: (SearchThreadBean.MainPost) -> Unit = {},
|
||||||
hideForum: Boolean = false,
|
hideForum: Boolean = false,
|
||||||
header: LazyListScope.() -> Unit = {},
|
header: LazyListScope.() -> Unit = {},
|
||||||
) {
|
) {
|
||||||
|
|
@ -155,6 +154,8 @@ fun SearchThreadList(
|
||||||
onUserClick = onItemUserClick,
|
onUserClick = onItemUserClick,
|
||||||
onForumClick = onItemForumClick,
|
onForumClick = onItemForumClick,
|
||||||
hideForum = hideForum,
|
hideForum = hideForum,
|
||||||
|
onQuotePostClick = onQuotePostClick,
|
||||||
|
onMainPostClick = onMainPostClick,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -202,6 +203,8 @@ fun SearchThreadItem(
|
||||||
onUserClick: (SearchThreadBean.UserInfoBean) -> Unit,
|
onUserClick: (SearchThreadBean.UserInfoBean) -> Unit,
|
||||||
onForumClick: (SearchThreadBean.ForumInfo) -> Unit,
|
onForumClick: (SearchThreadBean.ForumInfo) -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
|
onQuotePostClick: (SearchThreadBean.PostInfo) -> Unit = {},
|
||||||
|
onMainPostClick: (SearchThreadBean.MainPost) -> Unit = {},
|
||||||
hideForum: Boolean = false,
|
hideForum: Boolean = false,
|
||||||
) {
|
) {
|
||||||
Card(
|
Card(
|
||||||
|
|
@ -219,6 +222,7 @@ fun SearchThreadItem(
|
||||||
abstractText = item.content,
|
abstractText = item.content,
|
||||||
showTitle = item.mainPost == null && item.title.isNotBlank(),
|
showTitle = item.mainPost == null && item.title.isNotBlank(),
|
||||||
showAbstract = item.content.isNotBlank(),
|
showAbstract = item.content.isNotBlank(),
|
||||||
|
maxLines = 2,
|
||||||
)
|
)
|
||||||
if (item.mainPost != null) {
|
if (item.mainPost != null) {
|
||||||
if (item.postInfo != null) {
|
if (item.postInfo != null) {
|
||||||
|
|
@ -229,6 +233,9 @@ fun SearchThreadItem(
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.clip(RoundedCornerShape(6.dp))
|
.clip(RoundedCornerShape(6.dp))
|
||||||
.background(ExtendedTheme.colors.floorCard)
|
.background(ExtendedTheme.colors.floorCard)
|
||||||
|
.clickable {
|
||||||
|
onQuotePostClick(item.postInfo)
|
||||||
|
}
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
MainPostCard(
|
MainPostCard(
|
||||||
|
|
@ -237,6 +244,9 @@ fun SearchThreadItem(
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.clip(RoundedCornerShape(6.dp))
|
.clip(RoundedCornerShape(6.dp))
|
||||||
.background(ExtendedTheme.colors.floorCard)
|
.background(ExtendedTheme.colors.floorCard)
|
||||||
|
.clickable {
|
||||||
|
onMainPostClick(item.mainPost)
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue