Skip to content

Commit fc4832c

Browse files
committed
library: Fix effect of displayCutoutSize on Dropdown
1 parent ebe10f7 commit fc4832c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/extra/SuperDropdown.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import androidx.compose.ui.text.rememberTextMeasurer
5353
import androidx.compose.ui.text.style.TextAlign
5454
import androidx.compose.ui.unit.Dp
5555
import androidx.compose.ui.unit.DpSize
56+
import androidx.compose.ui.unit.LayoutDirection
5657
import androidx.compose.ui.unit.dp
5758
import androidx.compose.ui.unit.sp
5859
import top.yukonga.miuix.kmp.basic.BasicComponent
@@ -190,6 +191,9 @@ fun SuperDropdown(
190191
with(density) { WindowInsets.captionBar.asPaddingValues().calculateBottomPadding().toPx() }.roundToInt()
191192
)
192193
val insideHeightPx by rememberUpdatedState(with(density) { insideMargin.height.toPx() }.roundToInt())
194+
val displayCutoutLeftSize = rememberUpdatedState(with(density) {
195+
WindowInsets.displayCutout.asPaddingValues(density).calculateLeftPadding(LayoutDirection.Ltr).toPx()
196+
}.roundToInt())
193197
val paddingPx by rememberUpdatedState(with(density) { horizontalPadding.toPx() }.roundToInt())
194198

195199
BackHandler(enabled = isDropdownExpanded.value) { dismissPopup(isDropdownExpanded) }
@@ -217,9 +221,9 @@ fun SuperDropdown(
217221
modifier = Modifier
218222
.onGloballyPositioned { layoutCoordinates ->
219223
offsetXPx = if (alwaysRight || !alignLeft) {
220-
dropdownOffsetXPx + componentWidthPx - layoutCoordinates.size.width - paddingPx
224+
dropdownOffsetXPx + componentWidthPx - layoutCoordinates.size.width - paddingPx - if (defaultWindowInsetsPadding) displayCutoutLeftSize.value else 0
221225
} else {
222-
dropdownOffsetXPx + paddingPx
226+
dropdownOffsetXPx + paddingPx - if (defaultWindowInsetsPadding) displayCutoutLeftSize.value else 0
223227
}
224228
offsetYPx = calculateOffsetYPx(
225229
windowHeightPx,

0 commit comments

Comments
 (0)