feat: 隐藏回贴功能入口

This commit is contained in:
HuanCheng65 2023-09-29 11:26:58 +08:00
parent 162be6e3a1
commit 9c1dd21f3c
No known key found for this signature in database
GPG Key ID: 5EC9DD60A32C7360
7 changed files with 64 additions and 26 deletions

View File

@ -6,6 +6,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.MaterialTheme import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Apps import androidx.compose.material.icons.outlined.Apps
import androidx.compose.material.icons.outlined.Brightness2 import androidx.compose.material.icons.outlined.Brightness2

View File

@ -3,6 +3,8 @@ package com.huanchengfly.tieba.post.ui.page.settings.habit
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.BrandingWatermark import androidx.compose.material.icons.outlined.BrandingWatermark
import androidx.compose.material.icons.outlined.CalendarViewDay import androidx.compose.material.icons.outlined.CalendarViewDay
@ -10,6 +12,7 @@ import androidx.compose.material.icons.outlined.ExitToApp
import androidx.compose.material.icons.outlined.NightsStay import androidx.compose.material.icons.outlined.NightsStay
import androidx.compose.material.icons.outlined.PhotoSizeSelectActual import androidx.compose.material.icons.outlined.PhotoSizeSelectActual
import androidx.compose.material.icons.outlined.SecurityUpdateWarning import androidx.compose.material.icons.outlined.SecurityUpdateWarning
import androidx.compose.material.icons.outlined.SpeakerNotesOff
import androidx.compose.material.icons.outlined.StarOutline import androidx.compose.material.icons.outlined.StarOutline
import androidx.compose.material.icons.outlined.Verified import androidx.compose.material.icons.outlined.Verified
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
@ -20,6 +23,7 @@ import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import com.huanchengfly.tieba.post.R import com.huanchengfly.tieba.post.R
import com.huanchengfly.tieba.post.dataStore import com.huanchengfly.tieba.post.dataStore
@ -41,12 +45,16 @@ import com.ramcosta.composedestinations.navigation.DestinationsNavigator
fun HabitSettingsPage( fun HabitSettingsPage(
navigator: DestinationsNavigator navigator: DestinationsNavigator
) { ) {
val context = LocalContext.current
MyScaffold( MyScaffold(
backgroundColor = Color.Transparent, backgroundColor = Color.Transparent,
topBar = { topBar = {
TitleCentredToolbar( TitleCentredToolbar(
title = stringResource(id = R.string.title_settings_read_habit), title = {
Text(
text = stringResource(id = R.string.title_settings_read_habit),
fontWeight = FontWeight.Bold, style = MaterialTheme.typography.h6
)
},
navigationIcon = { navigationIcon = {
BackNavigationIcon(onBackPressed = { navigator.navigateUp() }) BackNavigationIcon(onBackPressed = { navigator.navigateUp() })
} }
@ -232,6 +240,22 @@ fun HabitSettingsPage(
}, },
) )
} }
prefsItem {
SwitchPref(
key = "hideReply",
title = stringResource(id = R.string.title_hide_reply),
defaultChecked = false,
leadingIcon = {
LeadingIcon {
AvatarIcon(
icon = Icons.Outlined.SpeakerNotesOff,
size = Sizes.Small,
contentDescription = null,
)
}
},
)
}
} }
} }
} }

View File

@ -75,6 +75,7 @@ import com.huanchengfly.tieba.post.utils.AccountUtil.LocalAccount
import com.huanchengfly.tieba.post.utils.DateTimeUtils import com.huanchengfly.tieba.post.utils.DateTimeUtils
import com.huanchengfly.tieba.post.utils.StringUtil import com.huanchengfly.tieba.post.utils.StringUtil
import com.huanchengfly.tieba.post.utils.TiebaUtil import com.huanchengfly.tieba.post.utils.TiebaUtil
import com.huanchengfly.tieba.post.utils.appPreferences
import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.annotation.Destination
import com.ramcosta.composedestinations.navigation.DestinationsNavigator import com.ramcosta.composedestinations.navigation.DestinationsNavigator
import com.ramcosta.composedestinations.spec.DestinationStyleBottomSheet import com.ramcosta.composedestinations.spec.DestinationStyleBottomSheet
@ -298,7 +299,7 @@ internal fun SubPostsContent(
) )
}, },
bottomBar = { bottomBar = {
if (account != null) { if (account != null && !LocalContext.current.appPreferences.hideReply) {
Surface( Surface(
elevation = 16.dp, elevation = 16.dp,
color = ExtendedTheme.colors.bottomBar, color = ExtendedTheme.colors.bottomBar,
@ -521,6 +522,7 @@ private fun SubPostItem(
menuState = menuState, menuState = menuState,
indication = null, indication = null,
menuContent = { menuContent = {
if (!context.appPreferences.hideReply) {
DropdownMenuItem( DropdownMenuItem(
onClick = { onClick = {
onReplyClick(subPost.get()) onReplyClick(subPost.get())
@ -529,6 +531,7 @@ private fun SubPostItem(
) { ) {
Text(text = stringResource(id = R.string.btn_reply)) Text(text = stringResource(id = R.string.btn_reply))
} }
}
DropdownMenuItem( DropdownMenuItem(
onClick = { onClick = {
TiebaUtil.copyText( TiebaUtil.copyText(
@ -558,7 +561,7 @@ private fun SubPostItem(
} }
} }
}, },
onClick = { onReplyClick(subPost.get()) } onClick = { onReplyClick(subPost.get()) }.takeUnless { context.appPreferences.hideReply }
) { ) {
Card( Card(
header = { header = {

View File

@ -1463,7 +1463,7 @@ private fun BottomBar(
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp) horizontalArrangement = Arrangement.spacedBy(8.dp)
) { ) {
if (user.get { is_login } == 1) { if (user.get { is_login } == 1 && !LocalContext.current.appPreferences.hideReply) {
Avatar( Avatar(
data = StringUtil.getAvatarUrl(user.get { portrait }), data = StringUtil.getAvatarUrl(user.get { portrait }),
size = Sizes.Tiny, size = Sizes.Tiny,
@ -1568,8 +1568,9 @@ fun PostCard(
indication = null, indication = null,
onClick = { onClick = {
onReplyClick(post) onReplyClick(post)
}, }.takeIf { !context.appPreferences.hideReply },
menuContent = { menuContent = {
if (!context.appPreferences.hideReply) {
DropdownMenuItem( DropdownMenuItem(
onClick = { onClick = {
onReplyClick(post) onReplyClick(post)
@ -1578,6 +1579,7 @@ fun PostCard(
) { ) {
Text(text = stringResource(id = R.string.btn_reply)) Text(text = stringResource(id = R.string.btn_reply))
} }
}
DropdownMenuItem( DropdownMenuItem(
onClick = { onClick = {
TiebaUtil.copyText(context, post.content.plainText) TiebaUtil.copyText(context, post.content.plainText)
@ -1727,7 +1729,9 @@ fun PostCard(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(horizontal = 12.dp), .padding(horizontal = 12.dp),
onReplyClick = { onSubPostReplyClick?.invoke(post, it) }, onReplyClick = {
onSubPostReplyClick?.invoke(post, it)
},
onOpenSubPosts = onOpenSubPosts, onOpenSubPosts = onOpenSubPosts,
) )
} }
@ -1764,7 +1768,7 @@ private fun SubPostItem(
subPostList: ImmutableHolder<SubPostList>, subPostList: ImmutableHolder<SubPostList>,
subPostContent: AnnotatedString, subPostContent: AnnotatedString,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
onReplyClick: (SubPostList) -> Unit, onReplyClick: ((SubPostList) -> Unit)?,
onOpenSubPosts: (Long) -> Unit, onOpenSubPosts: (Long) -> Unit,
) { ) {
val context = LocalContext.current val context = LocalContext.current
@ -1772,14 +1776,16 @@ private fun SubPostItem(
LongClickMenu( LongClickMenu(
menuState = menuState, menuState = menuState,
menuContent = { menuContent = {
if (!context.appPreferences.hideReply) {
DropdownMenuItem( DropdownMenuItem(
onClick = { onClick = {
onReplyClick(subPostList.get()) onReplyClick?.invoke(subPostList.get())
menuState.expanded = false menuState.expanded = false
} }
) { ) {
Text(text = stringResource(id = R.string.title_reply)) Text(text = stringResource(id = R.string.title_reply))
} }
}
DropdownMenuItem( DropdownMenuItem(
onClick = { onClick = {
TiebaUtil.copyText( TiebaUtil.copyText(

View File

@ -195,6 +195,7 @@ fun BackNavigationIcon(onBackPressed: () -> Unit) {
)""", )""",
"androidx.compose.ui.text.font.FontWeight", "androidx.compose.ui.text.font.FontWeight",
"androidx.compose.material.MaterialTheme", "androidx.compose.material.MaterialTheme",
"androidx.compose.material.Text"
) )
) )
@Composable @Composable

View File

@ -113,6 +113,8 @@ open class AppPreferencesUtils private constructor(ctx: Context) {
var hideForumIntroAndStat by DataStoreDelegates.boolean(defaultValue = false) var hideForumIntroAndStat by DataStoreDelegates.boolean(defaultValue = false)
var hideReply by DataStoreDelegates.boolean(defaultValue = false)
var homePageScroll by DataStoreDelegates.boolean(defaultValue = false) var homePageScroll by DataStoreDelegates.boolean(defaultValue = false)
var imageDarkenWhenNightMode by DataStoreDelegates.boolean(defaultValue = true) var imageDarkenWhenNightMode by DataStoreDelegates.boolean(defaultValue = true)

View File

@ -726,4 +726,5 @@
<string name="desc_night_theme">夜间主题</string> <string name="desc_night_theme">夜间主题</string>
<string name="settings_image_darken_when_night_mode">夜间模式压暗缩略图</string> <string name="settings_image_darken_when_night_mode">夜间模式压暗缩略图</string>
<string name="tip_toolbar_primary_color_summary">修改重启后生效</string> <string name="tip_toolbar_primary_color_summary">修改重启后生效</string>
<string name="title_hide_reply">隐藏回贴入口</string>
</resources> </resources>