Remove dead code.
This commit is contained in:
parent
7a1dd24dbd
commit
8ece139b63
2 changed files with 0 additions and 33 deletions
|
|
@ -77,28 +77,9 @@ fun ExpandableBottomSheetLayout(
|
||||||
var calculatedMaxBottomContentHeightPx by remember(maxBottomContentHeightPx) { mutableIntStateOf(maxBottomContentHeightPx) }
|
var calculatedMaxBottomContentHeightPx by remember(maxBottomContentHeightPx) { mutableIntStateOf(maxBottomContentHeightPx) }
|
||||||
val animatable = remember { Animatable(0f) }
|
val animatable = remember { Animatable(0f) }
|
||||||
|
|
||||||
fun calculatePercentage(currentPos: Int, minPos: Int, maxPos: Int): Float {
|
|
||||||
val currentProgress = currentPos - minPos
|
|
||||||
if (currentProgress < 0) {
|
|
||||||
Timber.e("Invalid current progress: $currentProgress, minPos: $minPos, maxPos: $maxPos")
|
|
||||||
return 0f
|
|
||||||
}
|
|
||||||
val total = (maxPos - minPos).toFloat()
|
|
||||||
if (total <= 0) {
|
|
||||||
Timber.e("Invalid total space: $total, minPos: $minPos, maxPos: $maxPos")
|
|
||||||
return 0f
|
|
||||||
}
|
|
||||||
return currentProgress / total
|
|
||||||
}
|
|
||||||
|
|
||||||
LaunchedEffect(animatable.value) {
|
LaunchedEffect(animatable.value) {
|
||||||
if (animatable.isRunning && animatable.value != animatable.targetValue) {
|
if (animatable.isRunning && animatable.value != animatable.targetValue) {
|
||||||
currentBottomContentHeightPx = animatable.value.roundToInt()
|
currentBottomContentHeightPx = animatable.value.roundToInt()
|
||||||
state.internalDraggingPercentage = calculatePercentage(
|
|
||||||
currentPos = currentBottomContentHeightPx,
|
|
||||||
minPos = minBottomContentHeightPx,
|
|
||||||
maxPos = calculatedMaxBottomContentHeightPx,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -122,11 +103,6 @@ fun ExpandableBottomSheetLayout(
|
||||||
minBottomContentHeightPx -> ExpandableBottomSheetLayoutState.Position.COLLAPSED
|
minBottomContentHeightPx -> ExpandableBottomSheetLayoutState.Position.COLLAPSED
|
||||||
else -> ExpandableBottomSheetLayoutState.Position.DRAGGING
|
else -> ExpandableBottomSheetLayoutState.Position.DRAGGING
|
||||||
}
|
}
|
||||||
state.internalDraggingPercentage = calculatePercentage(
|
|
||||||
currentPos = newHeight,
|
|
||||||
minPos = minBottomContentHeightPx,
|
|
||||||
maxPos = calculatedMaxBottomContentHeightPx,
|
|
||||||
)
|
|
||||||
currentBottomContentHeightPx = newHeight
|
currentBottomContentHeightPx = newHeight
|
||||||
},
|
},
|
||||||
onDragEnd = {
|
onDragEnd = {
|
||||||
|
|
|
||||||
|
|
@ -32,21 +32,12 @@ fun rememberExpandableBottomSheetLayoutState(): ExpandableBottomSheetLayoutState
|
||||||
@Stable
|
@Stable
|
||||||
class ExpandableBottomSheetLayoutState {
|
class ExpandableBottomSheetLayoutState {
|
||||||
internal var internalPosition: Position by mutableStateOf(Position.COLLAPSED)
|
internal var internalPosition: Position by mutableStateOf(Position.COLLAPSED)
|
||||||
internal var internalDraggingPercentage: Float by mutableFloatStateOf(
|
|
||||||
if (internalPosition == Position.EXPANDED) 1f else 0f
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current position of the bottom sheet layout.
|
* The current position of the bottom sheet layout.
|
||||||
*/
|
*/
|
||||||
val position get() = internalPosition
|
val position get() = internalPosition
|
||||||
|
|
||||||
/**
|
|
||||||
* The percentage of the bottom sheet layout that is currently being dragged.
|
|
||||||
* This value ranges from `0f` for [Position.COLLAPSED] to `1f` for [Position.EXPANDED].
|
|
||||||
*/
|
|
||||||
val draggingPercentage = internalDraggingPercentage
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The position of the bottom sheet layout.
|
* The position of the bottom sheet layout.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue