All Downloads are FREE. Search and download functionalities are using the official Maven repository.

desktopMain.io.github.lyxnx.compose.screenables.ScreenDefinition.jvm.kt Maven / Gradle / Ivy

There is a newer version: 1.1.3
Show newest version
package io.github.lyxnx.compose.screenables

import androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSizeClassApi
import androidx.compose.material3.windowsizeclass.calculateWindowSizeClass
import androidx.compose.runtime.Composable
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalWindowInfo
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.toSize

/**
 * Creates a screen definition
 */
@OptIn(ExperimentalMaterial3WindowSizeClassApi::class)
@Composable
public actual fun calculateScreenDefinition(): ScreenDefinition {
    return ScreenDefinition(
        foldOrientation = null,
        foldWidth = 0.dp,
        foldHeight = 0.dp,
        leftContentSize = DpSize.Zero,
        rightContentSize = DpSize.Zero,
        topContentSize = DpSize.Zero,
        bottomContentSize = DpSize.Zero,
        isPortrait = false, // desktop doesn't have a concept of portrait or landscape and only has different sized windows
        windowSizeClass = calculateWindowSizeClass(),
        windowSize = windowSize()
    )
}

@OptIn(ExperimentalComposeUiApi::class)
@Composable
private fun windowSize(): DpSize = with(LocalDensity.current) {
    LocalWindowInfo.current.containerSize.toSize().toDpSize()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy