Slide 1

Slide 1 text

Jetpack Compose Kashif Mehmood

Slide 2

Slide 2 text

What is Compose?

Slide 3

Slide 3 text

What is Compose? • A general purpose framework to manage state and emit a tree of objects derived from state • Can be used to build any sort of tree produced by composables • Compose UI is an implementation on UI Kit built using Compose. • Compose UI != Compose • Compose can be used to build anything you can think of that has a state and emits a tree and/or is reactive in nature

Slide 4

Slide 4 text

What is Jetpack Compose?

Slide 5

Slide 5 text

Jetpack Compose is a modern declarative UI Toolkit to simplify and accelerate native Android UI development.

Slide 6

Slide 6 text

Inspired By • React • Swift UI • Vue.js • Flutter • Litho . . . Built completely with kotlin, available for multiplatform projects and android.

Slide 7

Slide 7 text

Imperative UI Declarative UI vs Focuses on What Focuses on How Inheritance is prefered Composition is prefered View and logic are seperate Uses one language to build entire application. Tons of Boilerplate Code, slow development Less Code, faster development

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

Challenges with Views System Different Languages Multiple Files 30+ thousands lines of code Cognitive Overhead Deprecation s everywhere Multiple layers of inheritance Developer ergonomics Boilerplate code

Slide 10

Slide 10 text

UI logic and definition separate Layout Definition XML Static Kotlin/java Dynamic Logic & Behaviour Completely separate, can't use syntactic sugar and language features. (unless you are databinding fanatic) Generate tons of boilerplate codes, especially when using bindings.

Slide 11

Slide 11 text

Is Jetpack Compose ready for production?

Slide 12

Slide 12 text

Can I use it in my existing app?

Slide 13

Slide 13 text

What about performance?

Slide 14

Slide 14 text

Layouts Column Constraint Box Row

Slide 15

Slide 15 text

Slot layouts

Slide 16

Slide 16 text

Modifiers An ordered, immutable collection of modifier elements Decorates or Add behaviour to Compose UI elements Modifiers can be chained Chaining order is important

Slide 17

Slide 17 text

Life cycle of a composable Recompose 0 or more times Composable Enter the Composition Leave the Composition

Slide 18

Slide 18 text

What’s the State? An interface that has a value property during the execution of a Composable function. A mutable value holder where reads to the value property during the execution of a Composable function. Any changes to value will schedule recomposition of any composable functions that read value. State MutableState

Slide 19

Slide 19 text

Recomposition Composable Event UI-Redr aw

Slide 20

Slide 20 text

State & Recomposition Update State User Event Update UI Composition @Composable

Slide 21

Slide 21 text

What’s the State? Value Holder Observable Recomposition Trigger

Slide 22

Slide 22 text

What’s the State? Remember Remember Saveable

Slide 23

Slide 23 text

What’s the State? StateFull State less

Slide 24

Slide 24 text

Why state less? Single source of truth Encapsulated Decoupled

Slide 25

Slide 25 text

Side effects A side-effect is a change to the state of the app that happens outside the scope of a composable function. Used to trigger one of events Should be called with the scope of composable lifecycle

Slide 26

Slide 26 text

Side effects LaunchedEffect DisposableEffect DerivedStateOf

Slide 27

Slide 27 text

Lets Talk KMM

Slide 28

Slide 28 text

Thank you LinkedIn: @kashif-mehmood-km Github: @Kashif-E Twitter: @Kashif_mehmood_