windowConstraints
This constraint not only constrains the window, but also constrains the content. When constraining the content, it is equivalent to Modifier.sizeIn, and it can only take effect when used by the first child node under the root node. It Constrain the width of the content to be between minWidthdp and maxWidthdp and the height of the content to be between minHeightdp and maxHeightdp and the depth of the content to be between minDepthdp and maxDepthdp as permitted by the incoming measurement Constraints. If the incoming constraints are more restrictive the requested size will obey the incoming constraints and attempt to be as close as possible to the preferred size.
Return
The Modifier that applies the resize constraints to the content and WindowContainer.
Parameters
The minimum width of the content.
The minimum height of the content.
The maximum width of the content.
The maximum height of the content.
The minimum depth of the content.
The maximum depth of the content.
Samples
import androidx.compose.foundation.layout.Box
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.pico.spatial.ui.foundation.dsl.SpatialAppScope
import com.pico.spatial.ui.foundation.dsl.WindowContainer
import com.pico.spatial.ui.platform.resize.ContainerResizeType
fun main() {
//sampleStart
WindowContainer(id = "ResizeSample", resizeType = ContainerResizeType.ContentSize) {
Box(
modifier =
Modifier.windowConstraints(
minWidth = 500.dp,
minHeight = 500.dp,
minDepth = 500.dp,
maxWidth = 1500.dp,
maxHeight = 1500.dp,
maxDepth = 1500.dp,
)
) {}
}
//sampleEnd
}Constraint the width, height, and depth of the window to be equal to the maximum and minimum values. When the ContainerResizeType is CONTENT_SIZE, you can directly control the size of the WindowContainer
Return
the Modifier that applies the resize constraints to the content and WindowContainer.
Parameters
The width of the content.
The height of the content.
The depth of the content.
Samples
import androidx.compose.foundation.layout.Box
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.pico.spatial.ui.foundation.dsl.SpatialAppScope
import com.pico.spatial.ui.foundation.dsl.WindowContainer
import com.pico.spatial.ui.platform.resize.ContainerResizeType
fun main() {
//sampleStart
WindowContainer(id = "ResizeSample", resizeType = ContainerResizeType.ContentSize) {
Box(
modifier = Modifier.windowConstraints(width = 500.dp, height = 700.dp, depth = 300.dp)
) {}
}
//sampleEnd
}