Android Jetpack Compose A modern toolkit for building native UI From: Ajinkya Saswade
What is Jetpack Compose? Android’s modern toolkit for building native UI Jetpack compose accelerates UI development on Android with less code, powerful tools and intuitive Kotlin APIs. Note : Jetpack Compose is currently in Developer preview and not ready for production.
Inspired by ● React ● Litho ● Vue.js ● Flutter ...but it’s written completely in Kotlin and is fully compatible with the existing Android view system
Why are they building it? When we have existing UI toolkit. “API design is building future regret” - Chet Hase Move android.widget to a support library Jetpack
API regret View.java
API regret Button And the list goes on with Fragment and other stuff.
What is Compose? ● New set of Jetpack UI widgets ● A Kotlin compiler plugin ● Fully compatible with your existing app/code. (Both Java or Kotlin). In compose “Everything is a function”
What goals are achieve? ● Simplify ● Less code ● Fix what’s broken.
Building with Compose Adding into Existing Project - Gradle Configuration
Adding into Existing Project - Gradle Configuration
Jetpack Compose Basics
Define a composable function
Preview function
Layouts
Layouts
Components (Functions) Layouts ● Column ● Row ● Flex (Column / Row) ● ConstraintLayout (in process) Built-in Components ● Button ● Checkbox ● Drawers ● AppBars Custom View ● Draw ● Layout
What problem does Compose solve? Separation of Concerns Coupling VS Cohesion
Separation of Concerns Framing into more familiar way There is lot of depency hidden here. There is lot of coupling between the ViewModel & layout.xml
Separation of Concerns Now because we’re in the same language some of the dependencies might start to become more explicit. After doing some refactoring some of the coupling is reduce and cohesion is increased There’s actually a forced line of separation
State Management Over Time ● Observability is required ● Compose adds @Model classes ● @Model allows cross-cutting observation ● We can still use LiveData, Rx, etc. One of the concerns of the UI developer is solved i.e How your UI changes over the time
Data Flow
Eg.
Eg.
Eg.
Eg.
Compose Architecture
Compose UI Core
Compose UI Foundation
Compose UI Material
Compatibility
Declarative VS Imperative
Imperative way
Declarative way
How does it work? Compose works on Gap Buffer data structure
Gap Buffer
Gap Buffer
Jetpack Compose Questions?
Learn more about Jetpack Compose Jetpack Compose Android Compose Tutorial Codelabs Using Jetpack Compose to build UI in Android Exploring Jetpack Compose: Text
Jetpack Compose Thank You! about.me/ajinkyasaswade

Android jetpack compose | Declarative UI