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
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>")
}
ScreenDimensions returns the screen height and width in Dp
and Px
Status Bars returns the status bar height in Dp
and Px
val statusBarSize = WindowInsets.systemBars.asPaddingValues().calculateTopPadding()
+----------------+
| Top |
| Padding |
+----------------+
| |
| Content |
| |
+----------------+
NavigationBar returns the navigation bar height in Dp
and Px
val navigationBarSize = WindowInsets.systemBars.asPaddingValues().calculateBottomPadding()
+----------------+
| |
| Content |
| |
+----------------+
| Bottom |
| Padding |
+----------------+
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 checks if device is in landscape orientation
Portrait | landscape |
---|---|
Check Out Working Sample here