diff --git a/ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/PaywallDialog.kt b/ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/PaywallDialog.kt index 6011a289f7..16ae9538e3 100644 --- a/ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/PaywallDialog.kt +++ b/ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/PaywallDialog.kt @@ -16,8 +16,7 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.window.Dialog import androidx.compose.ui.window.DialogProperties -import androidx.window.core.layout.WindowWidthSizeClass -import com.revenuecat.purchases.ui.revenuecatui.helpers.computeWindowWidthSizeClass +import com.revenuecat.purchases.ui.revenuecatui.helpers.hasCompactDimension import com.revenuecat.purchases.ui.revenuecatui.helpers.shouldDisplayPaywall import com.revenuecat.purchases.ui.revenuecatui.helpers.windowAspectRatio import kotlinx.coroutines.launch @@ -91,19 +90,11 @@ private fun getDialogMaxHeightPercentage(): Float { if (windowAspectRatio() < UIDialogConstants.MAX_ASPECT_RATIO_TO_APPLY_MAX_HEIGHT) { return 1f } - return computeWindowWidthSizeClass().let { - when (it) { - WindowWidthSizeClass.MEDIUM, WindowWidthSizeClass.EXPANDED -> UIDialogConstants.MAX_HEIGHT_PERCENTAGE_TABLET - else -> 1f - } - } + return if (hasCompactDimension()) 1f else UIDialogConstants.MAX_HEIGHT_PERCENTAGE_TABLET } @Composable @ReadOnlyComposable private fun shouldUsePlatformDefaultWidth(): Boolean { - return when (computeWindowWidthSizeClass()) { - WindowWidthSizeClass.MEDIUM, WindowWidthSizeClass.EXPANDED -> true - else -> false - } + return !hasCompactDimension() } diff --git a/ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/helpers/WindowHelper.kt b/ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/helpers/WindowHelper.kt index 8528d4d884..da15aa0a4e 100644 --- a/ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/helpers/WindowHelper.kt +++ b/ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/helpers/WindowHelper.kt @@ -25,6 +25,13 @@ internal fun computeWindowHeightSizeClass(): WindowHeightSizeClass { return windowSizeClass().windowHeightSizeClass } +@Composable +@ReadOnlyComposable +internal fun hasCompactDimension(): Boolean { + return computeWindowHeightSizeClass() == WindowHeightSizeClass.COMPACT || + computeWindowWidthSizeClass() == WindowWidthSizeClass.COMPACT +} + @Composable @ReadOnlyComposable internal fun PaywallState.Loaded.shouldUseLandscapeLayout(): Boolean {