From 2c4f7c5fc6605b46458b85cfe19cdce598babacb Mon Sep 17 00:00:00 2001 From: HuanCheng65 <22636177+HuanCheng65@users.noreply.github.com> Date: Sat, 30 Sep 2023 19:13:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=8A=AC=E9=AB=98=E8=B4=B4=E5=AD=90?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=BA=95=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../settings/custom/CustomSettingsPage.kt | 18 ++++ .../post/ui/page/subposts/SubPostsPage.kt | 90 +++++++++++-------- .../tieba/post/ui/page/thread/ThreadPage.kt | 16 +++- .../tieba/post/utils/AppPreferencesUtils.kt | 2 + app/src/main/res/values/strings.xml | 2 + 5 files changed, 87 insertions(+), 41 deletions(-) diff --git a/app/src/main/java/com/huanchengfly/tieba/post/ui/page/settings/custom/CustomSettingsPage.kt b/app/src/main/java/com/huanchengfly/tieba/post/ui/page/settings/custom/CustomSettingsPage.kt index e21ab528..f9b6174f 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/ui/page/settings/custom/CustomSettingsPage.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/ui/page/settings/custom/CustomSettingsPage.kt @@ -16,6 +16,7 @@ import androidx.compose.material.icons.outlined.ColorLens import androidx.compose.material.icons.outlined.Explore import androidx.compose.material.icons.outlined.FontDownload import androidx.compose.material.icons.outlined.FormatColorFill +import androidx.compose.material.icons.outlined.Upcoming import androidx.compose.material.icons.outlined.ViewAgenda import androidx.compose.runtime.Composable import androidx.compose.runtime.derivedStateOf @@ -285,6 +286,23 @@ fun CustomSettingsPage( }, ) } + prefsItem { + SwitchPref( + key = "liftUpBottomBar", + title = stringResource(id = R.string.title_lift_up_bottom_bar), + defaultChecked = true, + leadingIcon = { + LeadingIcon { + AvatarIcon( + icon = Icons.Outlined.Upcoming, + size = Sizes.Small, + contentDescription = null, + ) + } + }, + summary = stringResource(id = R.string.summary_lift_up_bottom_bar), + ) + } } } } \ No newline at end of file diff --git a/app/src/main/java/com/huanchengfly/tieba/post/ui/page/subposts/SubPostsPage.kt b/app/src/main/java/com/huanchengfly/tieba/post/ui/page/subposts/SubPostsPage.kt index ed9fdc0e..8d4bf249 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/ui/page/subposts/SubPostsPage.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/ui/page/subposts/SubPostsPage.kt @@ -4,12 +4,17 @@ import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.navigationBarsPadding +import androidx.compose.foundation.layout.navigationBars import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.requiredHeightIn +import androidx.compose.foundation.layout.windowInsetsBottomHeight import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.shape.RoundedCornerShape @@ -308,45 +313,56 @@ internal fun SubPostsContent( contentColor = ExtendedTheme.colors.text, modifier = Modifier.fillMaxWidth() ) { - Row( - modifier = Modifier - .fillMaxWidth() - .navigationBarsPadding() - .padding(horizontal = 16.dp), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(8.dp) - ) { - Avatar( - data = StringUtil.getAvatarUrl(account.portrait), - size = Sizes.Tiny, - contentDescription = account.name, - ) + Column { Row( modifier = Modifier - .padding(vertical = 8.dp) - .weight(1f) - .clip(RoundedCornerShape(6.dp)) - .background(ExtendedTheme.colors.bottomBarSurface) - .clickable { - val fid = forum?.get { id } ?: forumId - val forumName = forum?.get { name } - if (!forumName.isNullOrEmpty()) { - navigator.navigate( - ReplyPageDestination( - forumId = fid, - forumName = forumName, - threadId = threadId, - postId = postId, - ) - ) - } - } - .padding(8.dp), + .fillMaxWidth() + .padding(horizontal = 16.dp), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(8.dp) ) { - Text( - text = stringResource(id = R.string.tip_reply_thread), - style = MaterialTheme.typography.caption, - color = ExtendedTheme.colors.onBottomBarSurface, + Avatar( + data = StringUtil.getAvatarUrl(account.portrait), + size = Sizes.Tiny, + contentDescription = account.name, + ) + Row( + modifier = Modifier + .padding(vertical = 8.dp) + .weight(1f) + .clip(RoundedCornerShape(6.dp)) + .background(ExtendedTheme.colors.bottomBarSurface) + .clickable { + val fid = forum?.get { id } ?: forumId + val forumName = forum?.get { name } + if (!forumName.isNullOrEmpty()) { + navigator.navigate( + ReplyPageDestination( + forumId = fid, + forumName = forumName, + threadId = threadId, + postId = postId, + ) + ) + } + } + .padding(8.dp), + ) { + Text( + text = stringResource(id = R.string.tip_reply_thread), + style = MaterialTheme.typography.caption, + color = ExtendedTheme.colors.onBottomBarSurface, + ) + } + } + + Box( + modifier = Modifier + .requiredHeightIn(min = if (LocalContext.current.appPreferences.liftUpBottomBar) 16.dp else 0.dp) + ) { + Spacer( + modifier = Modifier + .windowInsetsBottomHeight(WindowInsets.navigationBars) ) } } diff --git a/app/src/main/java/com/huanchengfly/tieba/post/ui/page/thread/ThreadPage.kt b/app/src/main/java/com/huanchengfly/tieba/post/ui/page/thread/ThreadPage.kt index a14a158a..c31b7482 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/ui/page/thread/ThreadPage.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/ui/page/thread/ThreadPage.kt @@ -21,6 +21,7 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.navigationBars import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.requiredHeightIn import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.windowInsetsBottomHeight @@ -1503,7 +1504,9 @@ private fun BottomBar( ) } } else { - Spacer(modifier = Modifier.weight(1f)) + Spacer(modifier = Modifier + .weight(1f) + .height(40.dp)) } BottomBarAgreeBtn( @@ -1528,10 +1531,15 @@ private fun BottomBar( } } - Spacer( + Box( modifier = Modifier - .windowInsetsBottomHeight(WindowInsets.navigationBars) - ) + .requiredHeightIn(min = if (LocalContext.current.appPreferences.liftUpBottomBar) 16.dp else 0.dp) + ) { + Spacer( + modifier = Modifier + .windowInsetsBottomHeight(WindowInsets.navigationBars) + ) + } } } diff --git a/app/src/main/java/com/huanchengfly/tieba/post/utils/AppPreferencesUtils.kt b/app/src/main/java/com/huanchengfly/tieba/post/utils/AppPreferencesUtils.kt index ad5a5b60..05e65871 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/utils/AppPreferencesUtils.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/utils/AppPreferencesUtils.kt @@ -130,6 +130,8 @@ open class AppPreferencesUtils private constructor(ctx: Context) { var imeHeight by DataStoreDelegates.int(defaultValue = 800) + var liftUpBottomBar by DataStoreDelegates.boolean(defaultValue = true) + var listItemsBackgroundIntermixed by DataStoreDelegates.boolean(defaultValue = true) var listSingle by DataStoreDelegates.boolean(defaultValue = false) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0fe2f710..9559bbc4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -734,4 +734,6 @@ 图片 查看图片 (%d) 收起贴子列表的图片和视频 + 全面屏优化 + 略微抬起贴子页面底栏以方便点按