feat: 抬高贴子页面底栏

This commit is contained in:
HuanCheng65 2023-09-30 19:13:53 +08:00
parent 40915c0325
commit 2c4f7c5fc6
No known key found for this signature in database
GPG Key ID: 5EC9DD60A32C7360
5 changed files with 87 additions and 41 deletions

View File

@ -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),
)
}
}
}
}

View File

@ -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)
)
}
}

View File

@ -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)
)
}
}
}

View File

@ -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)

View File

@ -734,4 +734,6 @@
<string name="desc_photo">图片</string>
<string name="btn_open_photos">查看图片 (%d)</string>
<string name="title_hide_media">收起贴子列表的图片和视频</string>
<string name="title_lift_up_bottom_bar">全面屏优化</string>
<string name="summary_lift_up_bottom_bar">略微抬起贴子页面底栏以方便点按</string>
</resources>