/ComposeExtensions

Primary LanguageKotlinMIT LicenseMIT

Summary

Android Compose extension.

library

  • Keyboard show/hide extensions.
  • Android System UI Controller

Download Stable - compose 1.7.0

Use gradle - compose 1.7.0, compose compiler 1.5.15, kotlin 1.9.25

implementation("tech.thdev:extensions-compose-keyboard-state:1.7.0")
implementation("tech.thdev:extensions-compose-system-ui-controller:1.7.0")

Release version are available in Sonatyp's repository.

Use keyboard extensions

Use scaffold modifier

CompositionLocalProvider(
    LocalMutableExKeyboardStateSourceOwner provides MutableExKeyboardStateSource()
) {
    Scaffold(
        modifier = Modifier
            .removeFocusWhenKeyboardIsHidden()
    ) {
    }
}

when checking status

val keyboardState by mutableKeyboardStateSource.keyboardState()

DisposableEffect(showKeyboard) {
    // Use keyboard state
    onDispose {
    }
}

Use system ui controller

// Remember a SystemUiController
val systemUiController = rememberExSystemUiController()

DisposableEffect(systemUiController) {
    // Update all of the system bar colors to be transparent, and use
    // dark icons if we're in light theme
    systemUiController.setSystemBarsColor(
        color = Color.Transparent,
    )

    // setStatusBarColor() and setNavigationBarColor() also exist

    onDispose {}
}

Sample

image