I can’t drag the bottom page by green box element
Globals vars
val CONST_UI_PANEL_FINDER_HEIGHT = 40
var CONST_UI_PANEL_DRAG_WIDTH = 100
var CONST_UI_PANEL_SHEET_COLLAPSED = CONST_UI_PANEL_CALENDAR_HEIGHT + CONST_UI_PANEL_FINDER_HEIGHT
var CONST_UI_PANEL_SHEET_HALF = 400
var CONST_UI_PANEL_SHEET_FULL = 800
var PEEK_HEIGHT = mutableIntStateOf(CONST_UI_PANEL_SHEET_COLLAPSED)
code in module
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun PanelContentBar() {
val bottomSheetSt = rememberStandardBottomSheetState(
skipHiddenState = true,
initialValue = SheetValue.PartiallyExpanded
)
val scaffoldState = rememberBottomSheetScaffoldState(bottomSheetSt)
BottomSheetScaffold(
modifier = Modifier
.background(color = JetMainTheme.colors.background),
sheetContent = {
Footer()
},
scaffoldState = scaffoldState,
sheetPeekHeight = PEEK_HEIGHT.value.dp,
sheetContainerColor = JetMainTheme.colors.background,
sheetDragHandle = {
Finder(scaffoldState)
},
sheetSwipeEnabled = false
) {
}
}
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun Finder(stateBt: BottomSheetScaffoldState) {
Box (
contentAlignment = Alignment.CenterStart,
modifier = Modifier
.height(CONST_UI_PANEL_FINDER_HEIGHT.dp)
.fillMaxWidth()
.padding(
start = CONST_UI_OTSTUP_X2.dp,
end = (CONST_UI_PANEL_DRAG_WIDTH + CONST_UI_OTSTUP_X2 * 2).dp
),
) {
val message = remember { mutableStateOf("") }
BasicTextField(
modifier = Modifier
.clip(RoundedCornerShape(CONST_UI_OTSTUP.dp))
.border(1.dp, color = JetMainTheme.colors.primary)
.fillMaxWidth()
//.padding(CONST_UI_OTSTUP_MIN.dp)
,
singleLine = true,
value = message.value,
onValueChange = { newText -> message.value = newText },
)
}
Box (
contentAlignment = Alignment.CenterEnd,
modifier = Modifier
.height(CONST_UI_PANEL_FINDER_HEIGHT.dp)
.fillMaxWidth()
.padding(end = CONST_UI_OTSTUP_X2.dp),
) {
val scope = rememberCoroutineScope()
var expandedType by remember {
mutableStateOf(ExpandedType.COLLAPSED)
}
var isUpdated = false
Box(
modifier = Modifier
.background(
color = JetMainTheme.colors.primary,
shape = RoundedCornerShape(CONST_UI_OTSTUP_MIN.dp)
)
.height(CONST_UI_OTSTUP.dp)
.width(CONST_UI_PANEL_DRAG_WIDTH.dp)
.pointerInput(Unit) {
detectVerticalDragGestures(
onVerticalDrag = { change, dragAmount ->
change.consume()
if (!isUpdated) {
Log.i(
"UIPanelContent.Finder",
"vert drag: dragAmount=$dragAmount expandedType=${expandedType} peekHaight=${PEEK_HEIGHT.value}"
)
expandedType = when {
dragAmount < 0 && expandedType == ExpandedType.COLLAPSED -> ExpandedType.HALF
dragAmount < 0 && expandedType == ExpandedType.HALF -> ExpandedType.FULL
dragAmount > 0 && expandedType == ExpandedType.FULL -> ExpandedType.HALF
dragAmount > 0 && expandedType == ExpandedType.HALF -> ExpandedType.COLLAPSED
else -> expandedType
}
isUpdated = true
}
},
onDragEnd = {
isUpdated = false
PEEK_HEIGHT.value = when {
expandedType == ExpandedType.HALF -> CONST_UI_PANEL_SHEET_HALF
expandedType == ExpandedType.FULL -> CONST_UI_PANEL_SHEET_FULL
else -> CONST_UI_PANEL_SHEET_COLLAPSED
}
Log.i(
"UIPanelContent.Finder",
"onDragEnd: expandedType=${expandedType} peekHeight=${PEEK_HEIGHT.value}"
)
scope.launch {
stateBt.bottomSheetState.partialExpand()
}
}
)
}
,
) {
}
}
}
@Composable
fun Footer() {
Column (
modifier = Modifier
.background(color = androidx.compose.ui.graphics.Color.Blue)
.padding(bottom = CONST_UI_PANEL_CALENDAR_HEIGHT.dp)
.fillMaxWidth()
) {
Text("line 1 text")
Text("line 2 text")
Text("line 3 text")
Text("line 4 text")
}
}
//--
enum class ExpandedType {
HALF, FULL, COLLAPSED
}
Initially, when I launch the application I have this screen
enter image description here
Then when I swipe vertically, nothing happens
(the bottom sheet should have opened halfway)
After swiping again, the bottom sheet opens completely.
enter image description here
Next, when I swipe down, the bottom sheet should go down half the screen, but it decreases from the bottom
enter image description here
When you swipe down again, the bottom sheet collapses as in the first picture
user24721113 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.