添加新闻接口,UI调整

This commit is contained in:
2025-10-28 18:42:05 +08:00
parent 7095832722
commit 90156745ad
15 changed files with 275 additions and 153 deletions

View File

@@ -32,6 +32,21 @@ data class Moment(
val time: String, val time: String,
@SerializedName("isFollowed") @SerializedName("isFollowed")
val isFollowed: Boolean, val isFollowed: Boolean,
// 新闻相关字段
@SerializedName("isNews")
val isNews: Boolean = false,
@SerializedName("newsTitle")
val newsTitle: String? = null,
@SerializedName("newsUrl")
val newsUrl: String? = null,
@SerializedName("newsSource")
val newsSource: String? = null,
@SerializedName("newsCategory")
val newsCategory: String? = null,
@SerializedName("newsLanguage")
val newsLanguage: String? = null,
@SerializedName("newsContent")
val newsContent: String? = null,
) { ) {
fun toMomentItem(): MomentEntity { fun toMomentItem(): MomentEntity {
return MomentEntity( return MomentEntity(
@@ -60,6 +75,14 @@ data class Moment(
authorId = user.id.toInt(), authorId = user.id.toInt(),
liked = isLiked, liked = isLiked,
isFavorite = isFavorite, isFavorite = isFavorite,
// 新闻相关字段
isNews = isNews,
newsTitle = newsTitle ?: "",
newsUrl = newsUrl ?: "",
newsSource = newsSource ?: "",
newsCategory = newsCategory ?: "",
newsLanguage = newsLanguage ?: "",
newsContent = newsContent ?: ""
) )
} }
} }

View File

@@ -527,6 +527,7 @@ interface RaveNowAPI {
@Query("trend") trend: String? = null, @Query("trend") trend: String? = null,
@Query("favouriteUserId") favouriteUserId: Int? = null, @Query("favouriteUserId") favouriteUserId: Int? = null,
@Query("explore") explore: String? = null, @Query("explore") explore: String? = null,
@Query("newsFilter") newsFilter: String? = null,
): Response<ListContainer<Moment>> ): Response<ListContainer<Moment>>
@Multipart @Multipart

View File

@@ -299,12 +299,21 @@ data class MomentEntity(
// 关联动态 // 关联动态
var relMoment: MomentEntity? = null, var relMoment: MomentEntity? = null,
// 是否收藏 // 是否收藏
var isFavorite: Boolean = false var isFavorite: Boolean = false,
// 新闻相关字段
val isNews: Boolean = false,
val newsTitle: String = "",
val newsUrl: String = "",
val newsSource: String = "",
val newsCategory: String = "",
val newsLanguage: String = "",
val newsContent: String = ""
) )
class MomentLoaderExtraArgs( class MomentLoaderExtraArgs(
val explore: Boolean? = false, val explore: Boolean? = false,
val timelineId: Int? = null, val timelineId: Int? = null,
val authorId : Int? = null val authorId : Int? = null,
val newsOnly: Boolean? = null
) )
class MomentLoader : DataLoader<MomentEntity,MomentLoaderExtraArgs>() { class MomentLoader : DataLoader<MomentEntity,MomentLoaderExtraArgs>() {
override suspend fun fetchData( override suspend fun fetchData(
@@ -317,7 +326,8 @@ class MomentLoader : DataLoader<MomentEntity,MomentLoaderExtraArgs>() {
pageSize = pageSize, pageSize = pageSize,
explore = if (extra.explore == true) "true" else "", explore = if (extra.explore == true) "true" else "",
timelineId = extra.timelineId, timelineId = extra.timelineId,
authorId = extra.authorId authorId = extra.authorId,
newsFilter = if (extra.newsOnly == true) "news_only" else ""
) )
val data = result.body()?.let { val data = result.body()?.let {
ListContainer( ListContainer(
@@ -355,6 +365,18 @@ class MomentLoader : DataLoader<MomentEntity,MomentLoaderExtraArgs>() {
onListChanged?.invoke(this.list) onListChanged?.invoke(this.list)
} }
fun updateCommentCount(id: Int, delta: Int) {
this.list = this.list.map { momentItem ->
if (momentItem.id == id) {
val newCount = (momentItem.commentCount + delta).coerceAtLeast(0)
momentItem.copy(commentCount = newCount)
} else {
momentItem
}
}.toMutableList()
onListChanged?.invoke(this.list)
}
fun removeMoment(id: Int) { fun removeMoment(id: Int) {
this.list = this.list.filter { it.id != id }.toMutableList() this.list = this.list.filter { it.id != id }.toMutableList()
onListChanged?.invoke(this.list) onListChanged?.invoke(this.list)

View File

@@ -51,7 +51,8 @@ import com.aiosman.ravenow.ui.modifiers.noRippleClickable
@Composable @Composable
fun EditCommentBottomModal( fun EditCommentBottomModal(
replyComment: CommentEntity? = null, replyComment: CommentEntity? = null,
onSend: (String) -> Unit = {} autoFocus: Boolean = false,
onSend: (String) -> Unit = {},
) { ) {
val AppColors = LocalAppTheme.current val AppColors = LocalAppTheme.current
var text by remember { mutableStateOf("") } var text by remember { mutableStateOf("") }
@@ -59,9 +60,11 @@ fun EditCommentBottomModal(
val focusRequester = remember { FocusRequester() } val focusRequester = remember { FocusRequester() }
val context = LocalContext.current val context = LocalContext.current
LaunchedEffect(Unit) { LaunchedEffect(autoFocus) {
if (autoFocus) {
focusRequester.requestFocus() focusRequester.requestFocus()
} }
}
Column( Column(
modifier = Modifier modifier = Modifier

View File

@@ -72,9 +72,12 @@ open class BaseMomentModel :ViewModel(){
} }
suspend fun onAddComment(id: Int) { fun onAddComment(id: Int) {
// val currentPagingData = _momentsFlow.value momentLoader.updateCommentCount(id, +1)
// updateCommentCount(id) }
fun onDeleteComment(id: Int) {
momentLoader.updateCommentCount(id, -1)
} }
@@ -83,6 +86,7 @@ open class BaseMomentModel :ViewModel(){
fun onMomentFavoriteChangeEvent(event: MomentFavouriteChangeEvent) { fun onMomentFavoriteChangeEvent(event: MomentFavouriteChangeEvent) {
momentLoader.updateFavoriteCount(event.postId, event.isFavourite) momentLoader.updateFavoriteCount(event.postId, event.isFavourite)
} }
suspend fun favoriteMoment(id: Int) { suspend fun favoriteMoment(id: Int) {
momentService.favoriteMoment(id) momentService.favoriteMoment(id)
momentLoader.updateFavoriteCount(id, true) momentLoader.updateFavoriteCount(id, true)

View File

@@ -115,12 +115,17 @@ class NewsCommentModalViewModel(
fun NewsCommentModal( fun NewsCommentModal(
postId: Int? = null, postId: Int? = null,
commentCount: Int = 0, commentCount: Int = 0,
onDismiss: () -> Unit = {} onDismiss: () -> Unit = {},
onCommentAdded: () -> Unit = {},
onCommentDeleted: () -> Unit = {}
) { ) {
val AppColors = LocalAppTheme.current val AppColors = LocalAppTheme.current
val navController = LocalNavController.current val navController = LocalNavController.current
val debouncedNavigation = rememberDebouncedNavigation() val debouncedNavigation = rememberDebouncedNavigation()
// 实时评论数状态
var currentCommentCount by remember { mutableStateOf(commentCount) }
val model = viewModel<NewsCommentModalViewModel>( val model = viewModel<NewsCommentModalViewModel>(
key = "NewsCommentModalViewModel_$postId", key = "NewsCommentModalViewModel_$postId",
factory = object : ViewModelProvider.Factory { factory = object : ViewModelProvider.Factory {
@@ -156,6 +161,8 @@ fun NewsCommentModal(
showCommentMenu = false showCommentMenu = false
contextComment?.let { contextComment?.let {
model.deleteComment(it.id) model.deleteComment(it.id)
onCommentDeleted()
currentCommentCount = (currentCommentCount - 1).coerceAtLeast(0)
} }
}, },
commentEntity = contextComment, commentEntity = contextComment,
@@ -203,7 +210,7 @@ fun NewsCommentModal(
verticalAlignment = Alignment.CenterVertically verticalAlignment = Alignment.CenterVertically
) { ) {
Text( Text(
text = "${commentCount}条评论", text = "${currentCommentCount}条评论",
fontSize = 15.sp, fontSize = 15.sp,
fontWeight = FontWeight.Bold, fontWeight = FontWeight.Bold,
color = AppColors.text color = AppColors.text
@@ -262,7 +269,10 @@ fun NewsCommentModal(
) { ) {
HorizontalDivider(color = AppColors.inputBackground) HorizontalDivider(color = AppColors.inputBackground)
EditCommentBottomModal(replyComment) { EditCommentBottomModal(
replyComment = replyComment,
autoFocus = false
) {
if (replyComment != null) { if (replyComment != null) {
if (replyComment?.parentCommentId != null) { if (replyComment?.parentCommentId != null) {
// 第三级评论 // 第三级评论
@@ -285,9 +295,12 @@ fun NewsCommentModal(
model.createComment(content = it) model.createComment(content = it)
} }
replyComment = null replyComment = null
onCommentAdded()
currentCommentCount++
} }
Spacer(modifier = Modifier.height(navBarHeight)) Spacer(modifier = Modifier.height(navBarHeight))
} }
} }
} }

View File

@@ -1,5 +1,6 @@
package com.aiosman.ravenow.ui.index.tabs.moment.tabs.news package com.aiosman.ravenow.ui.index.tabs.moment.tabs.news
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.Image import androidx.compose.foundation.Image
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement
@@ -14,24 +15,23 @@ import androidx.compose.foundation.layout.statusBars
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.pager.VerticalPager
import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.pullrefresh.PullRefreshIndicator import androidx.compose.material.pullrefresh.PullRefreshIndicator
import androidx.compose.material.pullrefresh.pullRefresh
import androidx.compose.material.pullrefresh.rememberPullRefreshState
import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ModalBottomSheet import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.material3.rememberModalBottomSheetState import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.LaunchedEffect
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
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.clip
@@ -44,60 +44,40 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalConfiguration
import com.aiosman.ravenow.GuestLoginCheckOut
import com.aiosman.ravenow.GuestLoginCheckOutScene
import com.aiosman.ravenow.LocalAppTheme import com.aiosman.ravenow.LocalAppTheme
import com.aiosman.ravenow.LocalNavController
import com.aiosman.ravenow.R import com.aiosman.ravenow.R
import com.aiosman.ravenow.entity.MomentEntity import com.aiosman.ravenow.entity.MomentEntity
import com.aiosman.ravenow.exp.timeAgo import com.aiosman.ravenow.exp.timeAgo
import com.aiosman.ravenow.exp.formatPostTime2
import com.aiosman.ravenow.ui.NavigationRoute
import com.aiosman.ravenow.ui.composables.CustomAsyncImage import com.aiosman.ravenow.ui.composables.CustomAsyncImage
import com.aiosman.ravenow.ui.index.tabs.moment.tabs.dynamic.DynamicViewModel import com.aiosman.ravenow.ui.composables.rememberDebouncer
import com.aiosman.ravenow.ui.index.tabs.moment.tabs.news.NewsViewModel
import com.aiosman.ravenow.ui.modifiers.noRippleClickable import com.aiosman.ravenow.ui.modifiers.noRippleClickable
import kotlinx.coroutines.launch
@OptIn(ExperimentalMaterialApi::class, ExperimentalMaterial3Api::class) @OptIn(ExperimentalMaterialApi::class, ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class)
@Composable @Composable
fun NewsScreen() { fun NewsScreen() {
val model = DynamicViewModel val model = NewsViewModel
val moments = model.moments val moments = model.moments
val AppColors = LocalAppTheme.current val AppColors = LocalAppTheme.current
val context = LocalContext.current val context = LocalContext.current
val navController = LocalNavController.current
val scope = rememberCoroutineScope()
// 评论弹窗状态 // 评论弹窗状态
var showCommentModal by remember { mutableStateOf(false) } var showCommentModal by remember { mutableStateOf(false) }
var selectedMoment by remember { mutableStateOf<MomentEntity?>(null) } var selectedMoment by remember { mutableStateOf<MomentEntity?>(null) }
// 垂直翻页状态
val pagerState = rememberPagerState(pageCount = { moments.size })
// 下拉刷新状态 // 防抖器
val state = rememberPullRefreshState(model.refreshing, onRefresh = { val likeDebouncer = rememberDebouncer()
model.refreshPager(pullRefresh = true) val favoriteDebouncer = rememberDebouncer()
})
// 列表状态
val listState = rememberLazyListState()
// 用于跟踪是否已经触发过加载更多
var hasTriggeredLoadMore by remember { mutableStateOf(false) }
// 监听滚动到底部
val reachedBottom by remember {
derivedStateOf {
val layoutInfo = listState.layoutInfo
val lastVisibleItem = layoutInfo.visibleItemsInfo.lastOrNull()
val totalItems = layoutInfo.totalItemsCount
if (lastVisibleItem == null || totalItems == 0) {
false
} else {
val isLastItemVisible = lastVisibleItem.index >= totalItems - 2
isLastItemVisible && !hasTriggeredLoadMore
}
}
}
// 加载更多数据
LaunchedEffect(reachedBottom) {
if (reachedBottom) {
hasTriggeredLoadMore = true
model.loadMore()
}
}
// 初始化加载数据 // 初始化加载数据
LaunchedEffect(Unit) { LaunchedEffect(Unit) {
@@ -106,9 +86,13 @@ fun NewsScreen() {
// 监听数据变化,重置加载状态 // 监听数据变化,重置加载状态
LaunchedEffect(moments.size) { LaunchedEffect(moments.size) {
if (moments.size > 0) { // 当数据增加时如果接近列表末尾Pager会自动更新页数
kotlinx.coroutines.delay(500) }
hasTriggeredLoadMore = false
// 当翻页接近末尾时加载更多
LaunchedEffect(pagerState.currentPage, moments.size) {
if (moments.isNotEmpty() && pagerState.currentPage >= moments.size - 2) {
model.loadMore()
} }
} }
@@ -117,31 +101,61 @@ fun NewsScreen() {
.fillMaxSize() .fillMaxSize()
.background(AppColors.background) .background(AppColors.background)
) { ) {
Box(Modifier.pullRefresh(state)) { if (moments.isEmpty()) {
LazyColumn( Box(
modifier = Modifier.fillMaxSize(), modifier = Modifier.fillMaxSize(),
state = listState contentAlignment = Alignment.Center
) { ) {
items( Text(text = "暂无新闻内容", color = AppColors.text, fontSize = 16.sp)
moments.size, }
key = { idx -> idx } } else {
) { idx -> VerticalPager(
// 处理下标越界 state = pagerState,
if (idx < 0 || idx >= moments.size) return@items modifier = Modifier.fillMaxSize()
val momentItem = moments[idx] ?: return@items ) { page ->
val momentItem = moments.getOrNull(page) ?: return@VerticalPager
NewsItem( NewsItem(
moment = momentItem, moment = momentItem,
modifier = Modifier.fillMaxWidth(), modifier = Modifier.fillMaxSize(),
onCommentClick = { onCommentClick = {
selectedMoment = momentItem selectedMoment = momentItem
showCommentModal = true showCommentModal = true
},
onLikeClick = {
likeDebouncer {
// 检查游客模式
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.LIKE_MOMENT)) {
navController.navigate(NavigationRoute.Login.route)
} else {
scope.launch {
if (momentItem.liked) {
model.dislikeMoment(momentItem.id)
} else {
model.likeMoment(momentItem.id)
}
}
}
}
},
onFavoriteClick = {
favoriteDebouncer {
// 检查游客模式
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.LIKE_MOMENT)) {
navController.navigate(NavigationRoute.Login.route)
} else {
scope.launch {
if (momentItem.isFavorite) {
model.unfavoriteMoment(momentItem.id)
} else {
model.favoriteMoment(momentItem.id)
}
}
}
}
} }
) )
} }
} }
PullRefreshIndicator(model.refreshing, state, Modifier.align(Alignment.TopCenter))
}
// 评论弹窗 // 评论弹窗
if (showCommentModal && selectedMoment != null) { if (showCommentModal && selectedMoment != null) {
@@ -168,6 +182,12 @@ fun NewsScreen() {
commentCount = selectedMoment?.commentCount ?: 0, commentCount = selectedMoment?.commentCount ?: 0,
onDismiss = { onDismiss = {
showCommentModal = false showCommentModal = false
},
onCommentAdded = {
selectedMoment?.id?.let { model.onAddComment(it) }
},
onCommentDeleted = {
selectedMoment?.id?.let { model.onDeleteComment(it) }
} }
) )
} }
@@ -180,20 +200,25 @@ fun NewsScreen() {
fun NewsItem( fun NewsItem(
moment: MomentEntity, moment: MomentEntity,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
onCommentClick: () -> Unit = {} onCommentClick: () -> Unit = {},
onLikeClick: () -> Unit = {},
onFavoriteClick: () -> Unit = {}
) { ) {
val AppColors = LocalAppTheme.current val AppColors = LocalAppTheme.current
val context = LocalContext.current val context = LocalContext.current
Column( Column(
modifier = modifier modifier = modifier
.fillMaxWidth() .fillMaxSize()
.height(700.dp)
.background(AppColors.background) .background(AppColors.background)
.padding(vertical = 8.dp), .padding(vertical = 8.dp),
verticalArrangement = Arrangement.SpaceBetween verticalArrangement = Arrangement.SpaceBetween
) { ) {
Column { Column(
modifier = Modifier
.weight(1f)
.padding(bottom = 30.dp)
) {
// 新闻图片 // 新闻图片
Box( Box(
modifier = Modifier modifier = Modifier
@@ -228,7 +253,7 @@ fun NewsItem(
// 新闻标题 // 新闻标题
Text( Text(
text = moment.nickname, // 暂时使用用户名作为标题 text = if (moment.newsTitle.isNotEmpty()) moment.newsTitle else moment.nickname,
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(horizontal = 16.dp), .padding(horizontal = 16.dp),
@@ -241,15 +266,17 @@ fun NewsItem(
Spacer(modifier = Modifier.height(16.dp)) Spacer(modifier = Modifier.height(16.dp))
// 新闻内容 // 新闻内容(超出使用省略号)
Text( Text(
text = moment.momentTextContent, // 使用动态内容作为新闻内容 text = if (moment.newsContent.isNotEmpty()) moment.newsContent else moment.momentTextContent,
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(horizontal = 16.dp), .padding(horizontal = 16.dp),
fontSize = 14.sp, fontSize = 14.sp,
color = AppColors.text, color = AppColors.text,
lineHeight = 20.sp lineHeight = 20.sp,
maxLines = 6,
overflow = TextOverflow.Ellipsis
) )
Spacer(modifier = Modifier.height(16.dp)) Spacer(modifier = Modifier.height(16.dp))
@@ -262,11 +289,16 @@ fun NewsItem(
horizontalArrangement = Arrangement.SpaceBetween, horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically verticalAlignment = Alignment.CenterVertically
) { ) {
// 来源和时间 // 来源和时间(显示月份与具体时间)
Text( Text(
text = "${moment.nickname}${moment.time.timeAgo(context)}", text = if (moment.newsSource.isNotEmpty()) "${moment.newsSource}${moment.time.formatPostTime2()}" else "${moment.nickname}${moment.time.formatPostTime2()}",
fontSize = 12.sp, fontSize = 12.sp,
color = AppColors.secondaryText color = AppColors.secondaryText,
modifier = Modifier
.weight(1f)
.padding(end = 8.dp),
maxLines = 2,
overflow = TextOverflow.Ellipsis
) )
// 查看全文 // 查看全文
@@ -294,14 +326,15 @@ fun NewsItem(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(horizontal = 16.dp) .padding(horizontal = 16.dp)
.padding(bottom = 50.dp), .padding(bottom = 25.dp),
horizontalArrangement = Arrangement.SpaceEvenly horizontalArrangement = Arrangement.SpaceEvenly
) { ) {
// 点赞 // 点赞
NewsActionButton( NewsActionButton(
icon = R.drawable.rider_pro_moment_like, icon = if (moment.liked) R.drawable.rider_pro_moment_liked else R.drawable.rider_pro_moment_like,
count = moment.likeCount.toString(), count = moment.likeCount.toString(),
isActive = moment.liked isActive = moment.liked,
modifier = Modifier.noRippleClickable { onLikeClick() }
) )
// 评论 // 评论
@@ -314,9 +347,10 @@ fun NewsItem(
// 收藏 // 收藏
NewsActionButton( NewsActionButton(
icon = R.mipmap.icon_collect, icon = if (moment.isFavorite) R.mipmap.icon_variant_2 else R.mipmap.icon_collect,
count = moment.favoriteCount.toString(), count = moment.favoriteCount.toString(),
isActive = moment.isFavorite isActive = moment.isFavorite,
modifier = Modifier.noRippleClickable { onFavoriteClick() }
) )
// 分享 // 分享
@@ -357,10 +391,7 @@ fun NewsActionButton(
Image( Image(
painter = androidx.compose.ui.res.painterResource(id = icon), painter = androidx.compose.ui.res.painterResource(id = icon),
contentDescription = "操作图标", contentDescription = "操作图标",
modifier = Modifier.size(16.dp), modifier = Modifier.size(16.dp)
colorFilter = ColorFilter.tint(
if (isActive) AppColors.background else AppColors.text
)
) )
if (count.isNotEmpty()) { if (count.isNotEmpty()) {
@@ -368,7 +399,7 @@ fun NewsActionButton(
Text( Text(
text = count, text = count,
fontSize = 12.sp, fontSize = 12.sp,
color = if (isActive) AppColors.background else AppColors.text color = AppColors.text
) )
} }
if (text != null) { if (text != null) {

View File

@@ -0,0 +1,18 @@
package com.aiosman.ravenow.ui.index.tabs.moment.tabs.news
import com.aiosman.ravenow.entity.MomentLoaderExtraArgs
import com.aiosman.ravenow.ui.index.tabs.moment.BaseMomentModel
object NewsViewModel : BaseMomentModel() {
override fun extraArgs(): MomentLoaderExtraArgs {
// 只拉取新闻
return MomentLoaderExtraArgs(
explore = false,
timelineId = null,
authorId = null,
newsOnly = true
)
}
}

View File

@@ -6,6 +6,7 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.width
@@ -47,66 +48,72 @@ fun SelfProfileAction(
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center, horizontalArrangement = Arrangement.Center,
modifier = Modifier modifier = Modifier
.weight(1f) .width(60.dp).height(25.dp)
.clip(RoundedCornerShape(10.dp)) .clip(RoundedCornerShape(12.dp))
.background(AppColors.nonActive) .background(androidx.compose.ui.graphics.Color(0x229284BD))
.padding(horizontal = 5.dp, vertical = 12.dp)
.noRippleClickable { .noRippleClickable {
editProfileDebouncer { editProfileDebouncer {
onEditProfile() onEditProfile()
} }
} }
) { ) {
Image(
painter = painterResource(id = R.mipmap.fill_and_sign),
contentDescription = "",
modifier = Modifier.size(12.dp),
colorFilter = ColorFilter.tint(androidx.compose.ui.graphics.Color(0xFF9284BD))
)
Spacer(modifier = Modifier.width(4.dp))
Text( Text(
text = stringResource(R.string.edit_profile), text = stringResource(R.string.edit_profile),
fontSize = 14.sp, fontSize = 12.sp,
fontWeight = FontWeight.W900, fontWeight = FontWeight.W600,
color = AppColors.text, color = androidx.compose.ui.graphics.Color(0xFF9284BD),
) )
} }
// 预留按钮位置 // // 预留按钮位置
Row( // Row(
verticalAlignment = Alignment.CenterVertically, // verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center, // horizontalArrangement = Arrangement.Center,
modifier = Modifier // modifier = Modifier
.weight(1f) // .weight(1f)
.clip(RoundedCornerShape(10.dp)) // .clip(RoundedCornerShape(10.dp))
.padding(horizontal = 16.dp, vertical = 12.dp) // .padding(horizontal = 16.dp, vertical = 12.dp)
.noRippleClickable { // .noRippleClickable {
//
} // }
) { // ) {
Text( // Text(
text = "", // text = "",
fontSize = 14.sp, // fontSize = 14.sp,
fontWeight = FontWeight.W900, // fontWeight = FontWeight.W900,
color = AppColors.text, // color = AppColors.text,
) // )
} // }
//
// 分享按钮 // // 分享按钮
Row( // Row(
verticalAlignment = Alignment.CenterVertically, // verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center, // horizontalArrangement = Arrangement.Center,
modifier = Modifier // modifier = Modifier
.weight(1f) // .weight(1f)
.clip(RoundedCornerShape(10.dp)) // .clip(RoundedCornerShape(10.dp))
.background(AppColors.nonActive) // .background(AppColors.nonActive)
.padding(horizontal = 16.dp, vertical = 12.dp) // .padding(horizontal = 16.dp, vertical = 12.dp)
.noRippleClickable { // .noRippleClickable {
shareDebouncer { // shareDebouncer {
// TODO: 添加分享逻辑 // // TODO: 添加分享逻辑
} // }
} // }
) { // ) {
Text( // Text(
text = stringResource(R.string.share), // text = stringResource(R.string.share),
fontSize = 14.sp, // fontSize = 14.sp,
fontWeight = FontWeight.W900, // fontWeight = FontWeight.W900,
color = AppColors.text, // color = AppColors.text,
) // )
} // }
// // Rave Premium 按钮(右侧) // // Rave Premium 按钮(右侧)
// Row( // Row(

Binary file not shown.

After

Width:  |  Height:  |  Size: 335 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 277 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 377 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 521 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 614 B

View File

@@ -48,7 +48,7 @@
<string name="error_not_accept_term">"为了提供更好的服务,请您在注册前仔细阅读并同意《用户协议》。 "</string> <string name="error_not_accept_term">"为了提供更好的服务,请您在注册前仔细阅读并同意《用户协议》。 "</string>
<string name="empty_my_post_title">还没有发布任何动态</string> <string name="empty_my_post_title">还没有发布任何动态</string>
<string name="empty_my_post_content">发布一个动态吧</string> <string name="empty_my_post_content">发布一个动态吧</string>
<string name="edit_profile">编辑资料</string> <string name="edit_profile">编辑</string>
<string name="share">分享</string> <string name="share">分享</string>
<string name="logout">登出</string> <string name="logout">登出</string>
<string name="change_password">修改密码</string> <string name="change_password">修改密码</string>