Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Jetpack Compose, The New Way Building Android UI

Jetpack Compose, The New Way Building Android UI

Jetpack Compose is Modern toolkit for building native Android UI. Jetpack Compose simplifies and accelerates UI development on Android with less code, powerful tools, and intuitive Kotlin APIs. We can try to develop Android UI with no XML. Just using Kotlin API.

I Wayan Dharmana

November 30, 2019
Tweet

Other Decks in Programming

Transcript

  1. Jetpack Compose The New Way Building Android UI I Wayan

    Dharmana Associate Android Developer
  2. Jetpack Compose Modern toolkit for building native Android UI. Jetpack

    Compose simplifies and accelerates UI development on Android with less code, powerful tools, and intuitive Kotlin APIs.
  3. Jetpack Compose Less Code Do more with Less Code. Intuitive

    Just describe your UI, let Compose take care others. Accelerate Development Compatible with all your existing code. Powerful Create beautiful app with built-in support for Material Design, Dark Theme, etc
  4. Declarative UI Declarative UI is a UI that's designed in

    a declarative way. You describe what it should be like.
  5. Imperative vs Declarative IMPERATIVE • Masukan air ke dalam panci

    • Nyalakan Kompor • Tunggu Air Mendidih • Masukkan Mie • Siapkan Bumbu Mie • Aduk Mie hingga Matang • Buang Air Rebusan Mie • Tuang Mie ke Atas Bumbu DECLARATIVE • Sebuah Meja ◦ Berisi Makanan ▪ Mie Instan Goreng / Kuah “Saya pengen makan mie Instan”
  6. FYI, Jetpack Compose is currently in Developer Preview. We need

    to install Android Studio 4.0 Preview before Try http://d.android.com/studio/preview
  7. @Composable Function • Regular function annotated with @Composable • Enables

    your function to call other @Composable functions within it
  8. Compose in Android App • Use setContent to define layout

    • Call composable function instead of XML file
  9. Preview Changes with @Preview • Prepare Android Studio 4.0 Preview

    • Set Preview Content with @Preview annotation. • Build Project
  10. Modifier • List of properties that provide additional decoration/context for

    a UI component • Available modifiers are: Spacing, AspectRatio and modifiers for Row and Column
  11. Manage State with @Model • @Model annotation can help us

    to manage data state • Composable functions who read values from @Model parameters will automatically be recompose if the data changes.
  12. Manage State with @Model • Setup @Model function (CounterState) •

    Setup Counter as @Composable function • Put Counter below List
  13. Manage State with @Model • Setup @Model function (CounterState) •

    Setup Counter as @Composable function • Put Counter below List
  14. Theme your app with MaterialTheme MaterialTheme is a Composable function

    that reflects the styling principles from Google Material Design.
  15. Theme your Text with themeTextStyle Update your text font, size,

    and color with style. Example: set Text with H2 size
  16. Custom Theme? Why Not. Customize and build your own theme.

    Prepare custom color & composable function.
  17. WOW. Saya bisa menghasilkan 1.000 USD / hari membuat layout

    Android TANPA keluar rumah menggunakan XML dengan Jetpack Compose SKIP TO LIVE CODE > klub-ngoding.site