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.Explore
import androidx.compose.material.icons.outlined.FontDownload import androidx.compose.material.icons.outlined.FontDownload
import androidx.compose.material.icons.outlined.FormatColorFill import androidx.compose.material.icons.outlined.FormatColorFill
import androidx.compose.material.icons.outlined.Upcoming
import androidx.compose.material.icons.outlined.ViewAgenda import androidx.compose.material.icons.outlined.ViewAgenda
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.derivedStateOf 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.background
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row 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.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth 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.padding
import androidx.compose.foundation.layout.requiredHeightIn
import androidx.compose.foundation.layout.windowInsetsBottomHeight
import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
@ -308,10 +313,10 @@ internal fun SubPostsContent(
contentColor = ExtendedTheme.colors.text, contentColor = ExtendedTheme.colors.text,
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth()
) { ) {
Column {
Row( Row(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.navigationBarsPadding()
.padding(horizontal = 16.dp), .padding(horizontal = 16.dp),
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp) horizontalArrangement = Arrangement.spacedBy(8.dp)
@ -350,6 +355,17 @@ internal fun SubPostsContent(
) )
} }
} }
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.height
import androidx.compose.foundation.layout.navigationBars import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.requiredHeightIn
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.layout.windowInsetsBottomHeight
@ -1503,7 +1504,9 @@ private fun BottomBar(
) )
} }
} else { } else {
Spacer(modifier = Modifier.weight(1f)) Spacer(modifier = Modifier
.weight(1f)
.height(40.dp))
} }
BottomBarAgreeBtn( BottomBarAgreeBtn(
@ -1528,12 +1531,17 @@ private fun BottomBar(
} }
} }
Box(
modifier = Modifier
.requiredHeightIn(min = if (LocalContext.current.appPreferences.liftUpBottomBar) 16.dp else 0.dp)
) {
Spacer( Spacer(
modifier = Modifier modifier = Modifier
.windowInsetsBottomHeight(WindowInsets.navigationBars) .windowInsetsBottomHeight(WindowInsets.navigationBars)
) )
} }
} }
}
@Composable @Composable
fun PostCard( fun PostCard(

View File

@ -130,6 +130,8 @@ open class AppPreferencesUtils private constructor(ctx: Context) {
var imeHeight by DataStoreDelegates.int(defaultValue = 800) var imeHeight by DataStoreDelegates.int(defaultValue = 800)
var liftUpBottomBar by DataStoreDelegates.boolean(defaultValue = true)
var listItemsBackgroundIntermixed by DataStoreDelegates.boolean(defaultValue = true) var listItemsBackgroundIntermixed by DataStoreDelegates.boolean(defaultValue = true)
var listSingle by DataStoreDelegates.boolean(defaultValue = false) var listSingle by DataStoreDelegates.boolean(defaultValue = false)

View File

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