Respect IME insets in bottom sheet
This commit is contained in:
parent
c0ba124ee6
commit
f079974c10
@ -1,6 +1,5 @@
|
||||
package de.mm20.launcher2.ui.component
|
||||
|
||||
import android.util.Log
|
||||
import androidx.compose.animation.core.animateFloatAsState
|
||||
import androidx.compose.animation.core.spring
|
||||
import androidx.compose.foundation.background
|
||||
@ -19,11 +18,11 @@ import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.RowScope
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.asPaddingValues
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.imePadding
|
||||
import androidx.compose.foundation.layout.offset
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.systemBars
|
||||
@ -173,7 +172,8 @@ fun BottomSheetDialog(
|
||||
) {
|
||||
BoxWithConstraints(
|
||||
modifier = Modifier
|
||||
.fillMaxSize(),
|
||||
.fillMaxSize()
|
||||
.imePadding(),
|
||||
propagateMinConstraints = true,
|
||||
contentAlignment = Alignment.BottomCenter
|
||||
) {
|
||||
@ -346,14 +346,17 @@ private enum class SwipeState {
|
||||
Full, Peek, Dismiss
|
||||
}
|
||||
|
||||
private class BottomSheetPositionProvider(val insets: WindowInsets, val density: Density): PopupPositionProvider {
|
||||
private class BottomSheetPositionProvider(val insets: WindowInsets, val density: Density) :
|
||||
PopupPositionProvider {
|
||||
override fun calculatePosition(
|
||||
anchorBounds: IntRect,
|
||||
windowSize: IntSize,
|
||||
layoutDirection: LayoutDirection,
|
||||
popupContentSize: IntSize
|
||||
): IntOffset {
|
||||
Log.d("MM20", "calculatePosition: anchorBounds=$anchorBounds, windowSize=$windowSize, layoutDirection=$layoutDirection, popupContentSize=$popupContentSize")
|
||||
return IntOffset.Zero + IntOffset(insets.getLeft(density, layoutDirection), insets.getTop(density))
|
||||
return IntOffset.Zero + IntOffset(
|
||||
insets.getLeft(density, layoutDirection),
|
||||
insets.getTop(density)
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -8,6 +8,8 @@ import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.rounded.AutoFixHigh
|
||||
import androidx.compose.material.icons.rounded.SettingsSuggest
|
||||
@ -60,7 +62,9 @@ fun CorePaletteColorPreference(
|
||||
showDialog = false
|
||||
}) {
|
||||
Column(
|
||||
modifier = Modifier.padding(it)
|
||||
modifier = Modifier
|
||||
.verticalScroll(rememberScrollState())
|
||||
.padding(it)
|
||||
) {
|
||||
SwitchPreference(
|
||||
icon = Icons.Rounded.SettingsSuggest,
|
||||
|
||||
@ -13,7 +13,9 @@ import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.rounded.Colorize
|
||||
import androidx.compose.material.icons.rounded.Palette
|
||||
@ -91,6 +93,7 @@ fun ThemeColorPreference(
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.verticalScroll(rememberScrollState())
|
||||
.padding(it),
|
||||
) {
|
||||
SingleChoiceSegmentedButtonRow(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user