修复BUG-我的pai coin积分、草稿箱和举报界面,上滑弹框,弹框会持续抖动

This commit is contained in:
2025-11-28 18:44:49 +08:00
parent 04974b0a01
commit ca8b7b3c53
3 changed files with 134 additions and 97 deletions

View File

@@ -23,12 +23,10 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.material3.Button
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.animation.core.animateDpAsState
@@ -56,7 +54,6 @@ import androidx.compose.ui.geometry.CornerRadius
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.IntSize
@@ -106,32 +103,36 @@ fun PointsBottomSheet(
}
}
val statusBarPadding = WindowInsets.systemBars.asPaddingValues()
val configuration = LocalConfiguration.current
val screenHeight = configuration.screenHeightDp.dp
val offsetY = screenHeight * 0.07f - statusBarPadding.calculateTopPadding()
ModalBottomSheet(
onDismissRequest = onClose, // 允许通过代码关闭(如返回按钮)
sheetState = sheetState,
containerColor = AppColors.background,
dragHandle = null // 移除拖动手柄
containerColor = Color.Transparent,
dragHandle = null, // 移除拖动手柄
shape = RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp)
) {
Box(
modifier = Modifier
.fillMaxWidth()
.fillMaxHeight(0.95f)
.offset(y = offsetY)
.padding(
start = 16.dp,
end = 16.dp,
bottom = 8.dp
)
.padding(top = 10.dp)
) {
Surface(
modifier = Modifier
.fillMaxWidth()
.fillMaxHeight()
.clip(RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp)),
color = AppColors.background,
tonalElevation = 0.dp,
shadowElevation = 0.dp,
) {
Column(
modifier = Modifier
.fillMaxWidth()
.fillMaxHeight()
.padding(
start = 16.dp,
end = 16.dp,
bottom = 8.dp
)
) {
// 头部 - 使用 Box 实现绝对居中布局
Box(
@@ -343,6 +344,7 @@ fun PointsBottomSheet(
}
}
}
}
}
@Composable

View File

@@ -22,6 +22,7 @@ import androidx.compose.material3.Divider
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
@@ -34,6 +35,7 @@ import android.graphics.BitmapFactory
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
@@ -78,14 +80,28 @@ fun DraftBoxBottomSheet(
ModalBottomSheet(
onDismissRequest = onDismiss,
sheetState = sheetState,
containerColor = AppColors.background,
containerColor = Color.Transparent,
shape = RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp),
dragHandle = {}
) {
Box(
modifier = Modifier
.fillMaxWidth()
.padding(top = 8.dp)
) {
Surface(
modifier = Modifier
.fillMaxWidth()
.fillMaxHeight()
.clip(RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp)),
color = AppColors.background,
tonalElevation = 0.dp,
shadowElevation = 0.dp,
) {
Column(
modifier = Modifier
.fillMaxWidth()
.fillMaxHeight(0.9f)
.fillMaxHeight()
.padding(horizontal = 16.dp, vertical = 8.dp)
) {
// 标题
@@ -167,6 +183,8 @@ fun DraftBoxBottomSheet(
}
}
}
}
}
}
@Composable

View File

@@ -26,6 +26,7 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
@@ -46,6 +47,7 @@ import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
@@ -302,13 +304,26 @@ fun PostScreen(
onDismissRequest = {
showReportDialog = false
},
containerColor = AppColors.background,
containerColor = Color.Transparent,
sheetState = rememberModalBottomSheetState(
skipPartiallyExpanded = true
),
dragHandle = {},
shape = RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp),
) {
Box(
modifier = Modifier
.fillMaxWidth()
.padding(top = 7.dp)
) {
Surface(
modifier = Modifier
.fillMaxWidth()
.clip(RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp)),
tonalElevation = 0.dp,
shadowElevation = 0.dp,
color = AppColors.background,
contentColor = AppColors.text
) {
ReportModal(
momentId = viewModel.moment!!.id,
@@ -318,6 +333,8 @@ fun PostScreen(
)
}
}
}
}
Scaffold(
modifier = Modifier.fillMaxSize(),
bottomBar = {
@@ -2033,8 +2050,8 @@ fun ReportModal(
Column(
modifier = Modifier
.fillMaxWidth()
.background(AppColors.background)
.padding(start = 24.dp, end = 24.dp, bottom = 64.dp)
.fillMaxHeight()
.padding(start = 24.dp, end = 24.dp)
) {
Box(
modifier = Modifier.fillMaxWidth().padding(top = 16.dp, bottom = 16.dp),