Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions app/src/main/runtime/display/XServerDisplayHost.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ const val XSERVER_DRAWER_OPEN_TRIGGER_DP = 32
// Open only on a clearly rightward swipe: dx must exceed this * |dy| (~27deg of horizontal).
const val XSERVER_DRAWER_OPEN_HORIZONTAL_RATIO = 2f

private val DrawerWidth = 300.dp
private val DrawerMinWidth = 295.dp
private val DrawerMaxWidth = 960.dp
private const val DrawerHeightFactor = 0.76f
private val DrawerStartPadding = 6.dp
private val DrawerVerticalPadding = 6.dp
private const val DrawerSettleAnimationMs = 200
Expand Down Expand Up @@ -119,7 +121,11 @@ private fun XServerDisplayHost(
val animationScope = rememberCoroutineScope()
val density = LocalDensity.current
val viewConfiguration = LocalViewConfiguration.current
val closedFallbackPx = with(density) { -(DrawerWidth + DrawerStartPadding).toPx() }
val configuration = LocalConfiguration.current
val drawerWidth =
(minOf(configuration.screenWidthDp, configuration.screenHeightDp) * DrawerHeightFactor).dp
.coerceIn(DrawerMinWidth, DrawerMaxWidth)
val closedFallbackPx = with(density) { -(drawerWidth + DrawerStartPadding).toPx() }
var drawerOffsetPx by remember { mutableFloatStateOf(closedFallbackPx) }
var drawerWidthPx by remember { mutableFloatStateOf(0f) }
val drawerClosedOffset =
Expand Down Expand Up @@ -297,7 +303,7 @@ private fun XServerDisplayHost(
} else {
1f
}
val scaledDrawerWidth = DrawerWidth * evenScale
val scaledDrawerWidth = drawerWidth * evenScale

CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Ltr) {
AndroidView(
Expand Down