修复BUG-我的pai coin积分、草稿箱和举报界面,上滑弹框,弹框会持续抖动
This commit is contained in:
@@ -23,12 +23,10 @@ import androidx.compose.foundation.shape.RoundedCornerShape
|
|||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.fillMaxHeight
|
import androidx.compose.foundation.layout.fillMaxHeight
|
||||||
import androidx.compose.foundation.layout.offset
|
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.Button
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.ModalBottomSheet
|
import androidx.compose.material3.ModalBottomSheet
|
||||||
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.rememberModalBottomSheetState
|
import androidx.compose.material3.rememberModalBottomSheetState
|
||||||
import androidx.compose.animation.core.animateDpAsState
|
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.Brush
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.layout.onSizeChanged
|
import androidx.compose.ui.layout.onSizeChanged
|
||||||
import androidx.compose.ui.platform.LocalConfiguration
|
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.platform.LocalDensity
|
import androidx.compose.ui.platform.LocalDensity
|
||||||
import androidx.compose.ui.unit.IntSize
|
import androidx.compose.ui.unit.IntSize
|
||||||
@@ -106,33 +103,37 @@ fun PointsBottomSheet(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val statusBarPadding = WindowInsets.systemBars.asPaddingValues()
|
|
||||||
val configuration = LocalConfiguration.current
|
|
||||||
val screenHeight = configuration.screenHeightDp.dp
|
|
||||||
val offsetY = screenHeight * 0.07f - statusBarPadding.calculateTopPadding()
|
|
||||||
|
|
||||||
ModalBottomSheet(
|
ModalBottomSheet(
|
||||||
onDismissRequest = onClose, // 允许通过代码关闭(如返回按钮)
|
onDismissRequest = onClose, // 允许通过代码关闭(如返回按钮)
|
||||||
sheetState = sheetState,
|
sheetState = sheetState,
|
||||||
containerColor = AppColors.background,
|
containerColor = Color.Transparent,
|
||||||
dragHandle = null // 移除拖动手柄
|
dragHandle = null, // 移除拖动手柄
|
||||||
|
shape = RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp)
|
||||||
) {
|
) {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.fillMaxHeight(0.95f)
|
.padding(top = 10.dp)
|
||||||
.offset(y = offsetY)
|
|
||||||
.padding(
|
|
||||||
start = 16.dp,
|
|
||||||
end = 16.dp,
|
|
||||||
bottom = 8.dp
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
Column(
|
Surface(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.fillMaxHeight()
|
.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 实现绝对居中布局
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@@ -340,6 +341,7 @@ fun PointsBottomSheet(
|
|||||||
} else {
|
} else {
|
||||||
HowToEarnList(onRecharge = onRecharge)
|
HowToEarnList(onRecharge = onRecharge)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import androidx.compose.material3.Divider
|
|||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.ModalBottomSheet
|
import androidx.compose.material3.ModalBottomSheet
|
||||||
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.rememberModalBottomSheetState
|
import androidx.compose.material3.rememberModalBottomSheetState
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
@@ -34,6 +35,7 @@ import android.graphics.BitmapFactory
|
|||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.layout.ContentScale
|
import androidx.compose.ui.layout.ContentScale
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
@@ -78,92 +80,108 @@ fun DraftBoxBottomSheet(
|
|||||||
ModalBottomSheet(
|
ModalBottomSheet(
|
||||||
onDismissRequest = onDismiss,
|
onDismissRequest = onDismiss,
|
||||||
sheetState = sheetState,
|
sheetState = sheetState,
|
||||||
containerColor = AppColors.background,
|
containerColor = Color.Transparent,
|
||||||
shape = RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp),
|
shape = RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp),
|
||||||
dragHandle = {}
|
dragHandle = {}
|
||||||
) {
|
) {
|
||||||
Column(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.fillMaxHeight(0.9f)
|
.padding(top = 8.dp)
|
||||||
.padding(horizontal = 16.dp, vertical = 8.dp)
|
|
||||||
) {
|
) {
|
||||||
// 标题
|
Surface(
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(vertical = 16.dp),
|
.fillMaxHeight()
|
||||||
contentAlignment = Alignment.Center
|
.clip(RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp)),
|
||||||
|
color = AppColors.background,
|
||||||
|
tonalElevation = 0.dp,
|
||||||
|
shadowElevation = 0.dp,
|
||||||
) {
|
) {
|
||||||
Text(
|
Column(
|
||||||
text = stringResource(R.string.drafts),
|
|
||||||
fontSize = 17.sp,
|
|
||||||
fontWeight = FontWeight.Bold,
|
|
||||||
color = AppColors.text
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 草稿列表
|
|
||||||
if (drafts.isEmpty()) {
|
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.fillMaxHeight(),
|
.fillMaxHeight()
|
||||||
contentAlignment = Alignment.Center
|
.padding(horizontal = 16.dp, vertical = 8.dp)
|
||||||
) {
|
) {
|
||||||
Text(
|
// 标题
|
||||||
text = stringResource(R.string.no_drafts),
|
Box(
|
||||||
fontSize = 16.sp,
|
modifier = Modifier
|
||||||
color = AppColors.secondaryText
|
.fillMaxWidth()
|
||||||
)
|
.padding(vertical = 16.dp),
|
||||||
}
|
contentAlignment = Alignment.Center
|
||||||
} else {
|
) {
|
||||||
LazyColumn(
|
Text(
|
||||||
modifier = Modifier
|
text = stringResource(R.string.drafts),
|
||||||
.fillMaxWidth()
|
fontSize = 17.sp,
|
||||||
.weight(1f),
|
fontWeight = FontWeight.Bold,
|
||||||
verticalArrangement = Arrangement.spacedBy(0.dp)
|
color = AppColors.text
|
||||||
) {
|
|
||||||
itemsIndexed(drafts) { index, draft ->
|
|
||||||
DraftItem(
|
|
||||||
draft = draft,
|
|
||||||
dateFormat = dateFormat,
|
|
||||||
onEditClick = {
|
|
||||||
model.viewModelScope.launch {
|
|
||||||
model.loadDraft(context, draft)
|
|
||||||
onDismiss()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onDeleteClick = {
|
|
||||||
draftStore.deleteDraft(index)
|
|
||||||
drafts = draftStore.getAllDrafts()
|
|
||||||
},
|
|
||||||
AppColors = AppColors,
|
|
||||||
context = context
|
|
||||||
)
|
)
|
||||||
// 在草稿项之间添加分割线(最后一个不添加)
|
}
|
||||||
if (index < drafts.size - 1) {
|
|
||||||
Spacer(modifier = Modifier.height(12.dp))
|
// 草稿列表
|
||||||
Divider(
|
if (drafts.isEmpty()) {
|
||||||
color = AppColors.secondaryText.copy(alpha = 0.2f),
|
Box(
|
||||||
thickness = 0.5.dp,
|
modifier = Modifier
|
||||||
modifier = Modifier.padding(horizontal = 16.dp)
|
.fillMaxWidth()
|
||||||
|
.fillMaxHeight(),
|
||||||
|
contentAlignment = Alignment.Center
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.no_drafts),
|
||||||
|
fontSize = 16.sp,
|
||||||
|
color = AppColors.secondaryText
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.height(12.dp))
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
LazyColumn(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.weight(1f),
|
||||||
|
verticalArrangement = Arrangement.spacedBy(0.dp)
|
||||||
|
) {
|
||||||
|
itemsIndexed(drafts) { index, draft ->
|
||||||
|
DraftItem(
|
||||||
|
draft = draft,
|
||||||
|
dateFormat = dateFormat,
|
||||||
|
onEditClick = {
|
||||||
|
model.viewModelScope.launch {
|
||||||
|
model.loadDraft(context, draft)
|
||||||
|
onDismiss()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onDeleteClick = {
|
||||||
|
draftStore.deleteDraft(index)
|
||||||
|
drafts = draftStore.getAllDrafts()
|
||||||
|
},
|
||||||
|
AppColors = AppColors,
|
||||||
|
context = context
|
||||||
|
)
|
||||||
|
// 在草稿项之间添加分割线(最后一个不添加)
|
||||||
|
if (index < drafts.size - 1) {
|
||||||
|
Spacer(modifier = Modifier.height(12.dp))
|
||||||
|
Divider(
|
||||||
|
color = AppColors.secondaryText.copy(alpha = 0.2f),
|
||||||
|
thickness = 0.5.dp,
|
||||||
|
modifier = Modifier.padding(horizontal = 16.dp)
|
||||||
|
)
|
||||||
|
Spacer(modifier = Modifier.height(12.dp))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 底部提示
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.only_save_the_last_5_drafts),
|
||||||
|
fontSize = 12.sp,
|
||||||
|
color = AppColors.secondaryText,
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(vertical = 8.dp),
|
||||||
|
textAlign = androidx.compose.ui.text.style.TextAlign.Center
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 底部提示
|
|
||||||
Text(
|
|
||||||
text = stringResource(R.string.only_save_the_last_5_drafts),
|
|
||||||
fontSize = 12.sp,
|
|
||||||
color = AppColors.secondaryText,
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.padding(vertical = 8.dp),
|
|
||||||
textAlign = androidx.compose.ui.text.style.TextAlign.Center
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import androidx.compose.foundation.layout.Spacer
|
|||||||
import androidx.compose.foundation.layout.WindowInsets
|
import androidx.compose.foundation.layout.WindowInsets
|
||||||
import androidx.compose.foundation.layout.asPaddingValues
|
import androidx.compose.foundation.layout.asPaddingValues
|
||||||
import androidx.compose.foundation.layout.aspectRatio
|
import androidx.compose.foundation.layout.aspectRatio
|
||||||
|
import androidx.compose.foundation.layout.fillMaxHeight
|
||||||
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.height
|
import androidx.compose.foundation.layout.height
|
||||||
@@ -46,6 +47,7 @@ import androidx.compose.material3.ExperimentalMaterial3Api
|
|||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.ModalBottomSheet
|
import androidx.compose.material3.ModalBottomSheet
|
||||||
import androidx.compose.material3.Scaffold
|
import androidx.compose.material3.Scaffold
|
||||||
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.rememberModalBottomSheetState
|
import androidx.compose.material3.rememberModalBottomSheetState
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
@@ -302,20 +304,35 @@ fun PostScreen(
|
|||||||
onDismissRequest = {
|
onDismissRequest = {
|
||||||
showReportDialog = false
|
showReportDialog = false
|
||||||
},
|
},
|
||||||
containerColor = AppColors.background,
|
containerColor = Color.Transparent,
|
||||||
sheetState = rememberModalBottomSheetState(
|
sheetState = rememberModalBottomSheetState(
|
||||||
skipPartiallyExpanded = true
|
skipPartiallyExpanded = true
|
||||||
),
|
),
|
||||||
dragHandle = {},
|
dragHandle = {},
|
||||||
shape = RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp),
|
shape = RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp),
|
||||||
|
|
||||||
) {
|
) {
|
||||||
ReportModal(
|
Box(
|
||||||
momentId = viewModel.moment!!.id,
|
modifier = Modifier
|
||||||
onClose = {
|
.fillMaxWidth()
|
||||||
showReportDialog = false
|
.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,
|
||||||
|
onClose = {
|
||||||
|
showReportDialog = false
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Scaffold(
|
Scaffold(
|
||||||
@@ -2033,8 +2050,8 @@ fun ReportModal(
|
|||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.background(AppColors.background)
|
.fillMaxHeight()
|
||||||
.padding(start = 24.dp, end = 24.dp, bottom = 64.dp)
|
.padding(start = 24.dp, end = 24.dp)
|
||||||
) {
|
) {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier.fillMaxWidth().padding(top = 16.dp, bottom = 16.dp),
|
modifier = Modifier.fillMaxWidth().padding(top = 16.dp, bottom = 16.dp),
|
||||||
|
|||||||
Reference in New Issue
Block a user