pref: 透明主题优化

This commit is contained in:
HuanCheng65 2023-09-29 22:24:14 +08:00
parent 2f9ffde700
commit e4c61fb00d
No known key found for this signature in database
GPG Key ID: 5EC9DD60A32C7360
4 changed files with 356 additions and 330 deletions

View File

@ -17,6 +17,20 @@ val ExtendedColors.loadMoreIndicator: Color
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
get() = if (ThemeUtil.isNightMode(theme)) primary.copy(alpha = 0.3f) else primary

View File

@ -8,7 +8,6 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.material.Scaffold
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.AccountCircle
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.MainNavigationType
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.ramcosta.composedestinations.annotation.Destination
import com.ramcosta.composedestinations.annotation.RootNavGraph
@ -254,7 +254,7 @@ fun MainPage(
navigationType = navigationType,
navigationContentPosition = navigationContentPosition
) {
Scaffold(
MyScaffold(
backgroundColor = Color.Transparent,
modifier = Modifier.fillMaxSize(),
bottomBar = {

View File

@ -12,16 +12,18 @@ import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
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.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.windowInsetsBottomHeight
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.items
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.invertChipContent
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.destinations.ForumPageDestination
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(
sheetState = bottomSheetState,
sheetShape = RoundedCornerShape(topStart = 12.dp, topEnd = 12.dp),
@ -1092,30 +1153,14 @@ fun ThreadPage(
.defaultMinSize(minHeight = 1.dp)
)
},
modifier = Modifier.weight(1f)
) {
MyScaffold(
scaffoldState = scaffoldState,
topBar = {
TopBar(
forum = forum,
onBack = { navigator.navigateUp() },
onForumClick = {
val forumName = forum?.get { name }
if (forumName != null) navigator.navigate(
ForumPageDestination(
forumName
)
)
}
)
},
scrimColor = Color.Transparent,
modifier = Modifier
.fillMaxSize()
.padding(it)
) {
Box(
modifier = Modifier.pullRefresh(
state = pullRefreshState,
enabled = hasPrevious
)
modifier = Modifier
.pullRefresh(state = pullRefreshState, enabled = hasPrevious)
) {
LoadMoreLayout(
isLoading = isLoadingMore,
@ -1353,48 +1398,6 @@ fun ThreadPage(
}
}
}
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,10 +1457,12 @@ private fun BottomBar(
hasAgreed: Boolean = false,
agreeNum: Long = 0,
) {
Column(
modifier = Modifier.background(ExtendedTheme.colors.threadBottomBar)
) {
Row(
modifier = Modifier
.height(IntrinsicSize.Min)
.background(ExtendedTheme.colors.bottomBar)
.then(modifier)
.padding(horizontal = 16.dp),
verticalAlignment = Alignment.CenterVertically,
@ -1512,6 +1517,12 @@ private fun BottomBar(
)
}
}
Spacer(
modifier = Modifier
.windowInsetsBottomHeight(WindowInsets.navigationBars)
)
}
}
@Composable

View File

@ -31,6 +31,7 @@ import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.unit.IntOffset
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.menuBackground
import kotlinx.coroutines.flow.filterIsInstance
import kotlinx.coroutines.launch
import kotlin.math.roundToInt
@ -160,7 +161,7 @@ fun LongClickMenu(
DropdownMenu(
expanded = menuState.expanded,
onDismissRequest = { menuState.expanded = false },
modifier = modifier.background(color = MaterialTheme.colors.surface)
modifier = modifier.background(color = ExtendedTheme.colors.menuBackground)
) {
ProvideContentColor(color = ExtendedTheme.colors.text) {
menuContent()