From de3b3a14cb1d108adf894cc28c5bf4364e291584 Mon Sep 17 00:00:00 2001 From: Abdourahamane Boinaidi Date: Wed, 25 Sep 2024 09:49:26 +0200 Subject: [PATCH] core: Add WindowAdaptiveInfo.isWindowSmall --- .../swisstransfer/ui/utils/WindowAdaptativeInfoExt.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/utils/WindowAdaptativeInfoExt.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/utils/WindowAdaptativeInfoExt.kt index bed5580d1..ef0021432 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/utils/WindowAdaptativeInfoExt.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/utils/WindowAdaptativeInfoExt.kt @@ -33,3 +33,14 @@ import androidx.window.core.layout.WindowWidthSizeClass fun WindowAdaptiveInfo.isWindowLarge(): Boolean = with(windowSizeClass) { return windowWidthSizeClass == WindowWidthSizeClass.EXPANDED && windowHeightSizeClass != WindowHeightSizeClass.COMPACT } + +/** + * Determines if the current window is classified as a small window suitable for mobile devices. + * + * A window is considered small if its width size class is not [WindowWidthSizeClass.EXPANDED] + * or its height size class is [WindowHeightSizeClass.COMPACT]. This function can be used + * to adapt the UI layout for smaller screens, ensuring a better user experience on mobile devices. + * + * @return `true` if the window is small (mobile), `false` otherwise. + */ +fun WindowAdaptiveInfo.isWindowSmall(): Boolean = !isWindowLarge()