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,30 +1153,14 @@ fun ThreadPage(
|
||||||
.defaultMinSize(minHeight = 1.dp)
|
.defaultMinSize(minHeight = 1.dp)
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
modifier = Modifier.weight(1f)
|
scrimColor = Color.Transparent,
|
||||||
) {
|
modifier = Modifier
|
||||||
MyScaffold(
|
.fillMaxSize()
|
||||||
scaffoldState = scaffoldState,
|
.padding(it)
|
||||||
topBar = {
|
|
||||||
TopBar(
|
|
||||||
forum = forum,
|
|
||||||
onBack = { navigator.navigateUp() },
|
|
||||||
onForumClick = {
|
|
||||||
val forumName = forum?.get { name }
|
|
||||||
if (forumName != null) navigator.navigate(
|
|
||||||
ForumPageDestination(
|
|
||||||
forumName
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
},
|
|
||||||
) {
|
) {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier.pullRefresh(
|
modifier = Modifier
|
||||||
state = pullRefreshState,
|
.pullRefresh(state = pullRefreshState, enabled = hasPrevious)
|
||||||
enabled = hasPrevious
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
LoadMoreLayout(
|
LoadMoreLayout(
|
||||||
isLoading = isLoadingMore,
|
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 = {}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1453,11 +1456,13 @@ private fun BottomBar(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
hasAgreed: Boolean = false,
|
hasAgreed: Boolean = false,
|
||||||
agreeNum: Long = 0,
|
agreeNum: Long = 0,
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.background(ExtendedTheme.colors.threadBottomBar)
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.height(IntrinsicSize.Min)
|
.height(IntrinsicSize.Min)
|
||||||
.background(ExtendedTheme.colors.bottomBar)
|
|
||||||
.then(modifier)
|
.then(modifier)
|
||||||
.padding(horizontal = 16.dp),
|
.padding(horizontal = 16.dp),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
|
@ -1512,6 +1517,12 @@ private fun BottomBar(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Spacer(
|
||||||
|
modifier = Modifier
|
||||||
|
.windowInsetsBottomHeight(WindowInsets.navigationBars)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|
|
||||||
|
|
@ -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