About Modifiers - devrath/ComposeAlchemy GitHub Wiki

1_rtPw9vMKV31rckXABZqKPA

Why do modifiers exist

  • In simpler terms, A Modifier is used to modify a composable.
  • More analysis
    • Some composables have properties that are specific to that composable like a Text having a font.
    • But some properties are universal to all the composables like adding background, adding on-click, etc.
    • So these universal properties can be applied to any composable using a builder pattern and applied instead of adding all of them all the time. This is the reason the modifiers exist.

Spacings

  • The padding for a composable decreases the space available for child composables.

Window Insets

  • Window insets in Android refer to the areas of the screen that are occupied by system UI elements such as the status bar, navigation bar, and any other system decorations (like cutouts or notches). They are essential for ensuring that your app's UI doesn't overlap or get obscured by these system elements, especially in full-screen or immersive modes.
  • Window insets provide a way to control the padding areas needed on all the screen corners.
                    WindowInsetsDemo(
                        modifier = Modifier
                            .statusBarsPadding()
                            .navigationBarsPadding()
                            .safeGesturesPadding()
                            .safeDrawingPadding()
                    )