Skip to content

Latest commit

 

History

History

windowUtils

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Window Utils

Maven Central

Window Utils contains many useful composable functions to provide useful window info like screen dimensions and system bar size in Dp and Px and more

You can learn more about Dimensions here

Setup

add maven central repo to your root settings.gradle.kts

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
    }
}

add the dependency to your module's build.gradle.kts

dependencies {
    implementation("pro.jayeshseth.madifiers:windowUtils:<version>")
}

Screen Dimensions

ScreenDimensions returns the screen height and width in Dp and Px

Status Bars

Status Bars returns the status bar height in Dp and Px

val statusBarSize = WindowInsets.systemBars.asPaddingValues().calculateTopPadding()
+----------------+
|   Top          |
|   Padding      |
+----------------+
|                |
|     Content    |
|                |
+----------------+

Navigation Bar

NavigationBar returns the navigation bar height in Dp and Px

val navigationBarSize = WindowInsets.systemBars.asPaddingValues().calculateBottomPadding()
+----------------+
|                |
|     Content    |
|                |
+----------------+
|   Bottom       |
|   Padding      |
+----------------+

isGestureNavigation

isGestureNavigation is a hacky way to check if device is using gesture navigation bar or 3 button nav bar

Note: Doesn't work for tablet or foldable devices

isInLandscapeMode

isInLandscapeMode checks if device is in landscape orientation

Screenshots

Portrait landscape

Check Out Working Sample here