pref: 透明主题优化
This commit is contained in:
parent
2f9ffde700
commit
e4c61fb00d
|
|
@ -17,6 +17,20 @@ val ExtendedColors.loadMoreIndicator: Color
|
||||||
indicator
|
indicator
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val ExtendedColors.threadBottomBar: Color
|
||||||
|
get() = if (ThemeUtil.isTranslucentTheme(theme)) {
|
||||||
|
windowBackground
|
||||||
|
} else {
|
||||||
|
bottomBar
|
||||||
|
}
|
||||||
|
|
||||||
|
val ExtendedColors.menuBackground: Color
|
||||||
|
get() = if (ThemeUtil.isTranslucentTheme(theme)) {
|
||||||
|
windowBackground
|
||||||
|
} else {
|
||||||
|
card
|
||||||
|
}
|
||||||
|
|
||||||
val ExtendedColors.invertChipBackground: Color
|
val ExtendedColors.invertChipBackground: Color
|
||||||
get() = if (ThemeUtil.isNightMode(theme)) primary.copy(alpha = 0.3f) else primary
|
get() = if (ThemeUtil.isNightMode(theme)) primary.copy(alpha = 0.3f) else primary
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.fillMaxHeight
|
import androidx.compose.foundation.layout.fillMaxHeight
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.pager.rememberPagerState
|
import androidx.compose.foundation.pager.rememberPagerState
|
||||||
import androidx.compose.material.Scaffold
|
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.outlined.AccountCircle
|
import androidx.compose.material.icons.outlined.AccountCircle
|
||||||
import androidx.compose.material.icons.outlined.Inventory2
|
import androidx.compose.material.icons.outlined.Inventory2
|
||||||
|
|
@ -52,6 +51,7 @@ import com.huanchengfly.tieba.post.ui.utils.DevicePosture
|
||||||
import com.huanchengfly.tieba.post.ui.utils.MainNavigationContentPosition
|
import com.huanchengfly.tieba.post.ui.utils.MainNavigationContentPosition
|
||||||
import com.huanchengfly.tieba.post.ui.utils.MainNavigationType
|
import com.huanchengfly.tieba.post.ui.utils.MainNavigationType
|
||||||
import com.huanchengfly.tieba.post.ui.widgets.compose.LazyLoadHorizontalPager
|
import com.huanchengfly.tieba.post.ui.widgets.compose.LazyLoadHorizontalPager
|
||||||
|
import com.huanchengfly.tieba.post.ui.widgets.compose.MyScaffold
|
||||||
import com.huanchengfly.tieba.post.utils.appPreferences
|
import com.huanchengfly.tieba.post.utils.appPreferences
|
||||||
import com.ramcosta.composedestinations.annotation.Destination
|
import com.ramcosta.composedestinations.annotation.Destination
|
||||||
import com.ramcosta.composedestinations.annotation.RootNavGraph
|
import com.ramcosta.composedestinations.annotation.RootNavGraph
|
||||||
|
|
@ -254,7 +254,7 @@ fun MainPage(
|
||||||
navigationType = navigationType,
|
navigationType = navigationType,
|
||||||
navigationContentPosition = navigationContentPosition
|
navigationContentPosition = navigationContentPosition
|
||||||
) {
|
) {
|
||||||
Scaffold(
|
MyScaffold(
|
||||||
backgroundColor = Color.Transparent,
|
backgroundColor = Color.Transparent,
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize(),
|
||||||
bottomBar = {
|
bottomBar = {
|
||||||
|
|
|
||||||
|
|
@ -12,16 +12,18 @@ import androidx.compose.foundation.layout.IntrinsicSize
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
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.WindowInsets
|
||||||
import androidx.compose.foundation.layout.aspectRatio
|
import androidx.compose.foundation.layout.aspectRatio
|
||||||
import androidx.compose.foundation.layout.defaultMinSize
|
import androidx.compose.foundation.layout.defaultMinSize
|
||||||
import androidx.compose.foundation.layout.fillMaxHeight
|
import androidx.compose.foundation.layout.fillMaxHeight
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.navigationBarsPadding
|
import androidx.compose.foundation.layout.navigationBars
|
||||||
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.layout.windowInsetsBottomHeight
|
||||||
import androidx.compose.foundation.lazy.LazyListScope
|
import androidx.compose.foundation.lazy.LazyListScope
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||||
|
|
@ -119,6 +121,7 @@ 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.invertChipBackground
|
||||||
import com.huanchengfly.tieba.post.ui.common.theme.compose.invertChipContent
|
import com.huanchengfly.tieba.post.ui.common.theme.compose.invertChipContent
|
||||||
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.common.theme.compose.threadBottomBar
|
||||||
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.ReplyPageDestination
|
import com.huanchengfly.tieba.post.ui.page.destinations.ReplyPageDestination
|
||||||
|
|
@ -980,7 +983,65 @@ fun ThreadPage(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
Column {
|
MyScaffold(
|
||||||
|
scaffoldState = scaffoldState,
|
||||||
|
topBar = {
|
||||||
|
TopBar(
|
||||||
|
forum = forum,
|
||||||
|
onBack = { navigator.navigateUp() },
|
||||||
|
onForumClick = {
|
||||||
|
val forumName = forum?.get { name }
|
||||||
|
if (forumName != null) navigator.navigate(
|
||||||
|
ForumPageDestination(
|
||||||
|
forumName
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
},
|
||||||
|
bottomBar = {
|
||||||
|
BottomBar(
|
||||||
|
user = user,
|
||||||
|
onClickReply = {
|
||||||
|
navigator.navigate(
|
||||||
|
ReplyPageDestination(
|
||||||
|
forumId = curForumId ?: 0,
|
||||||
|
forumName = forum?.get { name }.orEmpty(),
|
||||||
|
threadId = threadId,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
onAgree = {
|
||||||
|
val firstPostId =
|
||||||
|
thread?.get { firstPostId }.takeIf { it != 0L }
|
||||||
|
?: firstPost?.get { id }
|
||||||
|
?: 0L
|
||||||
|
if (firstPostId != 0L) viewModel.send(
|
||||||
|
ThreadUiIntent.AgreeThread(
|
||||||
|
threadId,
|
||||||
|
firstPostId,
|
||||||
|
!hasThreadAgreed
|
||||||
|
)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
onClickMore = {
|
||||||
|
if (bottomSheetState.isVisible) {
|
||||||
|
closeBottomSheet()
|
||||||
|
} else {
|
||||||
|
openBottomSheet()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
hasAgreed = hasThreadAgreed,
|
||||||
|
agreeNum = threadAgreeNum,
|
||||||
|
modifier = Modifier
|
||||||
|
.clickable(
|
||||||
|
interactionSource = remember { MutableInteractionSource() },
|
||||||
|
indication = null,
|
||||||
|
onClick = {}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
) {
|
||||||
ModalBottomSheetLayout(
|
ModalBottomSheetLayout(
|
||||||
sheetState = bottomSheetState,
|
sheetState = bottomSheetState,
|
||||||
sheetShape = RoundedCornerShape(topStart = 12.dp, topEnd = 12.dp),
|
sheetShape = RoundedCornerShape(topStart = 12.dp, topEnd = 12.dp),
|
||||||
|
|
@ -1092,308 +1153,250 @@ fun ThreadPage(
|
||||||
.defaultMinSize(minHeight = 1.dp)
|
.defaultMinSize(minHeight = 1.dp)
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
modifier = Modifier.weight(1f)
|
scrimColor = Color.Transparent,
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.padding(it)
|
||||||
) {
|
) {
|
||||||
MyScaffold(
|
Box(
|
||||||
scaffoldState = scaffoldState,
|
modifier = Modifier
|
||||||
topBar = {
|
.pullRefresh(state = pullRefreshState, enabled = hasPrevious)
|
||||||
TopBar(
|
|
||||||
forum = forum,
|
|
||||||
onBack = { navigator.navigateUp() },
|
|
||||||
onForumClick = {
|
|
||||||
val forumName = forum?.get { name }
|
|
||||||
if (forumName != null) navigator.navigate(
|
|
||||||
ForumPageDestination(
|
|
||||||
forumName
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
},
|
|
||||||
) {
|
) {
|
||||||
Box(
|
LoadMoreLayout(
|
||||||
modifier = Modifier.pullRefresh(
|
isLoading = isLoadingMore,
|
||||||
state = pullRefreshState,
|
onLoadMore = {
|
||||||
enabled = hasPrevious
|
viewModel.send(
|
||||||
)
|
ThreadUiIntent.LoadMore(
|
||||||
) {
|
threadId = threadId,
|
||||||
LoadMoreLayout(
|
page = if (curSortType == ThreadSortType.SORT_TYPE_DESC) totalPage - currentPageMax
|
||||||
isLoading = isLoadingMore,
|
else currentPageMax + 1,
|
||||||
onLoadMore = {
|
forumId = forumId,
|
||||||
viewModel.send(
|
postId = nextPagePostId,
|
||||||
ThreadUiIntent.LoadMore(
|
seeLz = isSeeLz,
|
||||||
threadId = threadId,
|
sortType = curSortType,
|
||||||
page = if (curSortType == ThreadSortType.SORT_TYPE_DESC) totalPage - currentPageMax
|
postIds = data.map { it.post.get { id } }
|
||||||
else currentPageMax + 1,
|
|
||||||
forumId = forumId,
|
|
||||||
postId = nextPagePostId,
|
|
||||||
seeLz = isSeeLz,
|
|
||||||
sortType = curSortType,
|
|
||||||
postIds = data.map { it.post.get { id } }
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
},
|
)
|
||||||
loadEnd = !hasMore,
|
},
|
||||||
lazyListState = lazyListState,
|
loadEnd = !hasMore,
|
||||||
isEmpty = data.isEmpty()
|
lazyListState = lazyListState,
|
||||||
|
isEmpty = data.isEmpty()
|
||||||
|
) {
|
||||||
|
MyLazyColumn(
|
||||||
|
state = lazyListState,
|
||||||
|
modifier = Modifier.fillMaxWidth()
|
||||||
) {
|
) {
|
||||||
MyLazyColumn(
|
item(key = "FirstPost") {
|
||||||
state = lazyListState,
|
if (firstPost != null) {
|
||||||
modifier = Modifier.fillMaxWidth()
|
Column {
|
||||||
) {
|
PostCard(
|
||||||
item(key = "FirstPost") {
|
postHolder = firstPost!!,
|
||||||
if (firstPost != null) {
|
contentRenders = firstPostContentRenders,
|
||||||
Column {
|
canDelete = { it.author_id == user.get { id } },
|
||||||
PostCard(
|
immersiveMode = isImmersiveMode,
|
||||||
postHolder = firstPost!!,
|
isCollected = {
|
||||||
contentRenders = firstPostContentRenders,
|
it.id == thread?.get { collectMarkPid }
|
||||||
canDelete = { it.author_id == user.get { id } },
|
?.toLongOrNull()
|
||||||
immersiveMode = isImmersiveMode,
|
},
|
||||||
isCollected = {
|
showSubPosts = false,
|
||||||
it.id == thread?.get { collectMarkPid }
|
onReplyClick = {
|
||||||
?.toLongOrNull()
|
navigator.navigate(
|
||||||
},
|
ReplyPageDestination(
|
||||||
showSubPosts = false,
|
forumId = curForumId ?: 0,
|
||||||
onReplyClick = {
|
forumName = forum?.get { name }
|
||||||
navigator.navigate(
|
.orEmpty(),
|
||||||
ReplyPageDestination(
|
threadId = threadId,
|
||||||
forumId = curForumId ?: 0,
|
|
||||||
forumName = forum?.get { name }
|
|
||||||
.orEmpty(),
|
|
||||||
threadId = threadId,
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
},
|
)
|
||||||
onMenuFavoriteClick = {
|
},
|
||||||
viewModel.send(
|
onMenuFavoriteClick = {
|
||||||
ThreadUiIntent.AddFavorite(
|
viewModel.send(
|
||||||
threadId,
|
ThreadUiIntent.AddFavorite(
|
||||||
it.id,
|
threadId,
|
||||||
it.floor
|
it.id,
|
||||||
)
|
it.floor
|
||||||
)
|
)
|
||||||
},
|
)
|
||||||
) {
|
},
|
||||||
deletePost = null
|
) {
|
||||||
confirmDeleteDialogState.show()
|
deletePost = null
|
||||||
}
|
confirmDeleteDialogState.show()
|
||||||
|
|
||||||
VerticalDivider(
|
|
||||||
modifier = Modifier
|
|
||||||
.padding(horizontal = 16.dp)
|
|
||||||
.padding(bottom = 8.dp),
|
|
||||||
thickness = 2.dp
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VerticalDivider(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(horizontal = 16.dp)
|
||||||
|
.padding(bottom = 8.dp),
|
||||||
|
thickness = 2.dp
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stickyHeader(key = "ThreadHeader") {
|
}
|
||||||
|
stickyHeader(key = "ThreadHeader") {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.background(MaterialTheme.colors.background)
|
||||||
|
.padding(8.dp),
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = stringResource(
|
||||||
|
R.string.title_thread_header,
|
||||||
|
"${thread?.get { replyNum - 1 } ?: 0}"),
|
||||||
|
fontSize = 13.sp,
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
color = ExtendedTheme.colors.text,
|
||||||
|
modifier = Modifier.padding(horizontal = 8.dp),
|
||||||
|
)
|
||||||
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.text_all),
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(horizontal = 8.dp)
|
||||||
|
.clickable(
|
||||||
|
interactionSource = remember { MutableInteractionSource() },
|
||||||
|
indication = null,
|
||||||
|
enabled = isSeeLz
|
||||||
|
) {
|
||||||
|
if (isSeeLz) {
|
||||||
|
viewModel.send(
|
||||||
|
ThreadUiIntent.LoadFirstPage(
|
||||||
|
threadId = threadId,
|
||||||
|
forumId = forumId,
|
||||||
|
seeLz = false,
|
||||||
|
sortType = curSortType
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fontSize = 13.sp,
|
||||||
|
fontWeight = if (!isSeeLz) FontWeight.SemiBold else FontWeight.Normal,
|
||||||
|
color = if (!isSeeLz) ExtendedTheme.colors.text else ExtendedTheme.colors.textSecondary,
|
||||||
|
)
|
||||||
|
HorizontalDivider()
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.title_see_lz),
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(horizontal = 8.dp)
|
||||||
|
.clickable(
|
||||||
|
interactionSource = remember { MutableInteractionSource() },
|
||||||
|
indication = null,
|
||||||
|
enabled = !isSeeLz
|
||||||
|
) {
|
||||||
|
if (!isSeeLz) {
|
||||||
|
viewModel.send(
|
||||||
|
ThreadUiIntent.LoadFirstPage(
|
||||||
|
threadId = threadId,
|
||||||
|
forumId = forumId,
|
||||||
|
seeLz = true,
|
||||||
|
sortType = curSortType
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fontSize = 13.sp,
|
||||||
|
fontWeight = if (isSeeLz) FontWeight.SemiBold else FontWeight.Normal,
|
||||||
|
color = if (isSeeLz) ExtendedTheme.colors.text else ExtendedTheme.colors.textSecondary,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (curSortType == ThreadSortType.SORT_TYPE_DESC) {
|
||||||
|
latestPosts(true)
|
||||||
|
}
|
||||||
|
item(key = "LoadPreviousBtn") {
|
||||||
|
if (hasPrevious) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.background(MaterialTheme.colors.background)
|
.fillMaxWidth()
|
||||||
|
.clickable {
|
||||||
|
viewModel.send(
|
||||||
|
ThreadUiIntent.LoadPrevious(
|
||||||
|
threadId,
|
||||||
|
max(currentPageMax - 1, 1),
|
||||||
|
forumId,
|
||||||
|
postId = data
|
||||||
|
.first()
|
||||||
|
.post
|
||||||
|
.get { id },
|
||||||
|
seeLz = isSeeLz,
|
||||||
|
sortType = curSortType,
|
||||||
|
postIds = data.map { it.post.get { id } }
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
.padding(8.dp),
|
.padding(8.dp),
|
||||||
|
horizontalArrangement = Arrangement.Center,
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
|
Icon(
|
||||||
|
imageVector = Icons.Rounded.AlignVerticalTop,
|
||||||
|
contentDescription = null,
|
||||||
|
modifier = Modifier.size(16.dp)
|
||||||
|
)
|
||||||
|
Spacer(modifier = Modifier.width(16.dp))
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(
|
text = stringResource(id = R.string.btn_load_previous),
|
||||||
R.string.title_thread_header,
|
|
||||||
"${thread?.get { replyNum - 1 } ?: 0}"),
|
|
||||||
fontSize = 13.sp,
|
|
||||||
fontWeight = FontWeight.Bold,
|
|
||||||
color = ExtendedTheme.colors.text,
|
color = ExtendedTheme.colors.text,
|
||||||
modifier = Modifier.padding(horizontal = 8.dp),
|
fontSize = 14.sp
|
||||||
)
|
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
|
||||||
Text(
|
|
||||||
text = stringResource(R.string.text_all),
|
|
||||||
modifier = Modifier
|
|
||||||
.padding(horizontal = 8.dp)
|
|
||||||
.clickable(
|
|
||||||
interactionSource = remember { MutableInteractionSource() },
|
|
||||||
indication = null,
|
|
||||||
enabled = isSeeLz
|
|
||||||
) {
|
|
||||||
if (isSeeLz) {
|
|
||||||
viewModel.send(
|
|
||||||
ThreadUiIntent.LoadFirstPage(
|
|
||||||
threadId = threadId,
|
|
||||||
forumId = forumId,
|
|
||||||
seeLz = false,
|
|
||||||
sortType = curSortType
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fontSize = 13.sp,
|
|
||||||
fontWeight = if (!isSeeLz) FontWeight.SemiBold else FontWeight.Normal,
|
|
||||||
color = if (!isSeeLz) ExtendedTheme.colors.text else ExtendedTheme.colors.textSecondary,
|
|
||||||
)
|
|
||||||
HorizontalDivider()
|
|
||||||
Text(
|
|
||||||
text = stringResource(R.string.title_see_lz),
|
|
||||||
modifier = Modifier
|
|
||||||
.padding(horizontal = 8.dp)
|
|
||||||
.clickable(
|
|
||||||
interactionSource = remember { MutableInteractionSource() },
|
|
||||||
indication = null,
|
|
||||||
enabled = !isSeeLz
|
|
||||||
) {
|
|
||||||
if (!isSeeLz) {
|
|
||||||
viewModel.send(
|
|
||||||
ThreadUiIntent.LoadFirstPage(
|
|
||||||
threadId = threadId,
|
|
||||||
forumId = forumId,
|
|
||||||
seeLz = true,
|
|
||||||
sortType = curSortType
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fontSize = 13.sp,
|
|
||||||
fontWeight = if (isSeeLz) FontWeight.SemiBold else FontWeight.Normal,
|
|
||||||
color = if (isSeeLz) ExtendedTheme.colors.text else ExtendedTheme.colors.textSecondary,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (curSortType == ThreadSortType.SORT_TYPE_DESC) {
|
}
|
||||||
latestPosts(true)
|
if (!isRefreshing && data.isEmpty()) {
|
||||||
}
|
item(key = "EmptyTip") {
|
||||||
item(key = "LoadPreviousBtn") {
|
TipScreen(
|
||||||
if (hasPrevious) {
|
title = { Text(text = stringResource(id = R.string.title_empty)) },
|
||||||
Row(
|
image = {
|
||||||
modifier = Modifier
|
val composition by rememberLottieComposition(
|
||||||
.fillMaxWidth()
|
LottieCompositionSpec.RawRes(R.raw.lottie_empty_box)
|
||||||
.clickable {
|
)
|
||||||
viewModel.send(
|
LottieAnimation(
|
||||||
ThreadUiIntent.LoadPrevious(
|
composition = composition,
|
||||||
threadId,
|
iterations = LottieConstants.IterateForever,
|
||||||
max(currentPageMax - 1, 1),
|
modifier = Modifier
|
||||||
forumId,
|
.fillMaxWidth()
|
||||||
postId = data
|
.aspectRatio(2f)
|
||||||
.first()
|
)
|
||||||
.post
|
},
|
||||||
.get { id },
|
actions = {
|
||||||
seeLz = isSeeLz,
|
if (canReload) {
|
||||||
sortType = curSortType,
|
Button(onClick = { reload() }) {
|
||||||
postIds = data.map { it.post.get { id } }
|
Text(text = stringResource(id = R.string.btn_refresh))
|
||||||
)
|
}
|
||||||
)
|
}
|
||||||
}
|
},
|
||||||
.padding(8.dp),
|
modifier = Modifier.fillMaxSize(),
|
||||||
horizontalArrangement = Arrangement.Center,
|
scrollable = false
|
||||||
verticalAlignment = Alignment.CenterVertically
|
)
|
||||||
) {
|
}
|
||||||
Icon(
|
} else {
|
||||||
imageVector = Icons.Rounded.AlignVerticalTop,
|
items(
|
||||||
contentDescription = null,
|
items = data,
|
||||||
modifier = Modifier.size(16.dp)
|
key = { (item) -> "Post_${item.get { id }}" }
|
||||||
)
|
) { (item, blocked, renders, subPosts) ->
|
||||||
Spacer(modifier = Modifier.width(16.dp))
|
PostCard(
|
||||||
Text(
|
item,
|
||||||
text = stringResource(id = R.string.btn_load_previous),
|
renders,
|
||||||
color = ExtendedTheme.colors.text,
|
subPosts,
|
||||||
fontSize = 14.sp
|
blocked
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (curSortType != ThreadSortType.SORT_TYPE_DESC) {
|
||||||
if (!isRefreshing && data.isEmpty()) {
|
latestPosts(false)
|
||||||
item(key = "EmptyTip") {
|
|
||||||
TipScreen(
|
|
||||||
title = { Text(text = stringResource(id = R.string.title_empty)) },
|
|
||||||
image = {
|
|
||||||
val composition by rememberLottieComposition(
|
|
||||||
LottieCompositionSpec.RawRes(R.raw.lottie_empty_box)
|
|
||||||
)
|
|
||||||
LottieAnimation(
|
|
||||||
composition = composition,
|
|
||||||
iterations = LottieConstants.IterateForever,
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.aspectRatio(2f)
|
|
||||||
)
|
|
||||||
},
|
|
||||||
actions = {
|
|
||||||
if (canReload) {
|
|
||||||
Button(onClick = { reload() }) {
|
|
||||||
Text(text = stringResource(id = R.string.btn_refresh))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
modifier = Modifier.fillMaxSize(),
|
|
||||||
scrollable = false
|
|
||||||
)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
items(
|
|
||||||
items = data,
|
|
||||||
key = { (item) -> "Post_${item.get { id }}" }
|
|
||||||
) { (item, blocked, renders, subPosts) ->
|
|
||||||
PostCard(
|
|
||||||
item,
|
|
||||||
renders,
|
|
||||||
subPosts,
|
|
||||||
blocked
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (curSortType != ThreadSortType.SORT_TYPE_DESC) {
|
|
||||||
latestPosts(false)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PullRefreshIndicator(
|
|
||||||
refreshing = isRefreshing,
|
|
||||||
state = pullRefreshState,
|
|
||||||
modifier = Modifier.align(Alignment.TopCenter),
|
|
||||||
backgroundColor = ExtendedTheme.colors.pullRefreshIndicator,
|
|
||||||
contentColor = ExtendedTheme.colors.primary,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PullRefreshIndicator(
|
||||||
|
refreshing = isRefreshing,
|
||||||
|
state = pullRefreshState,
|
||||||
|
modifier = Modifier.align(Alignment.TopCenter),
|
||||||
|
backgroundColor = ExtendedTheme.colors.pullRefreshIndicator,
|
||||||
|
contentColor = ExtendedTheme.colors.primary,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BottomBar(
|
|
||||||
user = user,
|
|
||||||
onClickReply = {
|
|
||||||
navigator.navigate(
|
|
||||||
ReplyPageDestination(
|
|
||||||
forumId = curForumId ?: 0,
|
|
||||||
forumName = forum?.get { name }.orEmpty(),
|
|
||||||
threadId = threadId,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
},
|
|
||||||
onAgree = {
|
|
||||||
val firstPostId =
|
|
||||||
thread?.get { firstPostId }.takeIf { it != 0L } ?: firstPost?.get { id }
|
|
||||||
?: 0L
|
|
||||||
if (firstPostId != 0L) viewModel.send(
|
|
||||||
ThreadUiIntent.AgreeThread(
|
|
||||||
threadId,
|
|
||||||
firstPostId,
|
|
||||||
!hasThreadAgreed
|
|
||||||
)
|
|
||||||
)
|
|
||||||
},
|
|
||||||
onClickMore = {
|
|
||||||
if (bottomSheetState.isVisible) {
|
|
||||||
closeBottomSheet()
|
|
||||||
} else {
|
|
||||||
openBottomSheet()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
hasAgreed = hasThreadAgreed,
|
|
||||||
agreeNum = threadAgreeNum,
|
|
||||||
modifier = Modifier
|
|
||||||
.navigationBarsPadding()
|
|
||||||
.clickable(
|
|
||||||
interactionSource = remember { MutableInteractionSource() },
|
|
||||||
indication = null,
|
|
||||||
onClick = {}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1454,63 +1457,71 @@ private fun BottomBar(
|
||||||
hasAgreed: Boolean = false,
|
hasAgreed: Boolean = false,
|
||||||
agreeNum: Long = 0,
|
agreeNum: Long = 0,
|
||||||
) {
|
) {
|
||||||
Row(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier.background(ExtendedTheme.colors.threadBottomBar)
|
||||||
.height(IntrinsicSize.Min)
|
|
||||||
.background(ExtendedTheme.colors.bottomBar)
|
|
||||||
.then(modifier)
|
|
||||||
.padding(horizontal = 16.dp),
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
|
||||||
) {
|
) {
|
||||||
if (user.get { is_login } == 1 && !LocalContext.current.appPreferences.hideReply) {
|
Row(
|
||||||
Avatar(
|
modifier = Modifier
|
||||||
data = StringUtil.getAvatarUrl(user.get { portrait }),
|
.height(IntrinsicSize.Min)
|
||||||
size = Sizes.Tiny,
|
.then(modifier)
|
||||||
contentDescription = user.get { name },
|
.padding(horizontal = 16.dp),
|
||||||
modifier = Modifier
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
.padding(vertical = 8.dp)
|
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
||||||
|
) {
|
||||||
|
if (user.get { is_login } == 1 && !LocalContext.current.appPreferences.hideReply) {
|
||||||
|
Avatar(
|
||||||
|
data = StringUtil.getAvatarUrl(user.get { portrait }),
|
||||||
|
size = Sizes.Tiny,
|
||||||
|
contentDescription = user.get { name },
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(vertical = 8.dp)
|
||||||
|
)
|
||||||
|
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(vertical = 8.dp)
|
||||||
|
.weight(1f)
|
||||||
|
.clip(RoundedCornerShape(6.dp))
|
||||||
|
.background(ExtendedTheme.colors.bottomBarSurface)
|
||||||
|
.clickable(onClick = onClickReply)
|
||||||
|
.padding(8.dp),
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = stringResource(id = R.string.tip_reply_thread),
|
||||||
|
style = MaterialTheme.typography.caption,
|
||||||
|
color = ExtendedTheme.colors.onBottomBarSurface,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
|
}
|
||||||
|
|
||||||
|
BottomBarAgreeBtn(
|
||||||
|
hasAgreed = hasAgreed,
|
||||||
|
agreeNum = agreeNum,
|
||||||
|
onClick = onAgree,
|
||||||
|
modifier = Modifier.fillMaxHeight()
|
||||||
)
|
)
|
||||||
|
|
||||||
Row(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(vertical = 8.dp)
|
.fillMaxHeight()
|
||||||
.weight(1f)
|
.clickable(onClick = onClickMore)
|
||||||
.clip(RoundedCornerShape(6.dp))
|
.padding(horizontal = 4.dp),
|
||||||
.background(ExtendedTheme.colors.bottomBarSurface)
|
contentAlignment = Alignment.Center
|
||||||
.clickable(onClick = onClickReply)
|
|
||||||
.padding(8.dp),
|
|
||||||
) {
|
) {
|
||||||
Text(
|
Icon(
|
||||||
text = stringResource(id = R.string.tip_reply_thread),
|
imageVector = Icons.Rounded.MoreVert,
|
||||||
style = MaterialTheme.typography.caption,
|
contentDescription = stringResource(id = R.string.btn_more),
|
||||||
color = ExtendedTheme.colors.onBottomBarSurface,
|
tint = ExtendedTheme.colors.textSecondary,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BottomBarAgreeBtn(
|
Spacer(
|
||||||
hasAgreed = hasAgreed,
|
|
||||||
agreeNum = agreeNum,
|
|
||||||
onClick = onAgree,
|
|
||||||
modifier = Modifier.fillMaxHeight()
|
|
||||||
)
|
|
||||||
|
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxHeight()
|
.windowInsetsBottomHeight(WindowInsets.navigationBars)
|
||||||
.clickable(onClick = onClickMore)
|
)
|
||||||
.padding(horizontal = 4.dp),
|
|
||||||
contentAlignment = Alignment.Center
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Rounded.MoreVert,
|
|
||||||
contentDescription = stringResource(id = R.string.btn_more),
|
|
||||||
tint = ExtendedTheme.colors.textSecondary,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ import androidx.compose.ui.graphics.Shape
|
||||||
import androidx.compose.ui.unit.IntOffset
|
import androidx.compose.ui.unit.IntOffset
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.huanchengfly.tieba.post.ui.common.theme.compose.ExtendedTheme
|
import com.huanchengfly.tieba.post.ui.common.theme.compose.ExtendedTheme
|
||||||
|
import com.huanchengfly.tieba.post.ui.common.theme.compose.menuBackground
|
||||||
import kotlinx.coroutines.flow.filterIsInstance
|
import kotlinx.coroutines.flow.filterIsInstance
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
@ -160,7 +161,7 @@ fun LongClickMenu(
|
||||||
DropdownMenu(
|
DropdownMenu(
|
||||||
expanded = menuState.expanded,
|
expanded = menuState.expanded,
|
||||||
onDismissRequest = { menuState.expanded = false },
|
onDismissRequest = { menuState.expanded = false },
|
||||||
modifier = modifier.background(color = MaterialTheme.colors.surface)
|
modifier = modifier.background(color = ExtendedTheme.colors.menuBackground)
|
||||||
) {
|
) {
|
||||||
ProvideContentColor(color = ExtendedTheme.colors.text) {
|
ProvideContentColor(color = ExtendedTheme.colors.text) {
|
||||||
menuContent()
|
menuContent()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue