Slide 1

Slide 1 text

Shifting Paradigms Ragunath Jawahar / @ragunathjawahar

Slide 2

Slide 2 text

One moment…

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

Hiccups • A decade old UI toolkit • Bug fixes in the framework require OS updates • Multiple tech stacks • Multiple sources of truth • Accidental complexity

Slide 12

Slide 12 text

Hiccups • A decade old UI toolkit • Bug fixes in the framework require OS updates • Multiple tech stacks • Multiple sources of truth • Accidental complexity

Slide 13

Slide 13 text

Hiccups • A decade old UI toolkit • Bug fixes in the framework require OS updates • Multiple tech stacks • Multiple sources of truth • Accidental complexity

Slide 14

Slide 14 text

Hiccups • A decade old UI toolkit • Bug fixes in the framework require OS updates • Multiple tech stacks • Multiple sources of truth • Accidental complexity

Slide 15

Slide 15 text

Hiccups • A decade old UI toolkit • Bug fixes in the framework require OS updates • Multiple tech stacks • Multiple sources of truth • Accidental complexity

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

Data Binding

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

Hiccups • A decade old UI toolkit • Bug fixes in the framework require OS updates • Multiple tech stacks • Multiple sources of truth • Accidental complexity

Slide 22

Slide 22 text

Hiccups • A decade old UI toolkit • Bug fixes in the framework require OS updates • Multiple tech stacks • Multiple sources of truth • Accidental complexity

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

Loading

Slide 25

Slide 25 text

Loading Show Results

Slide 26

Slide 26 text

Loading Show Results Load More

Slide 27

Slide 27 text

Loading Show Results Load More

Slide 28

Slide 28 text

Loading Show Results Load More

Slide 29

Slide 29 text

Loading Show Results Load More

Slide 30

Slide 30 text

Progress Bar?

Slide 31

Slide 31 text

Loading Show Results Load More

Slide 32

Slide 32 text

Loading Show Results Load More

Slide 33

Slide 33 text

Loading Show Results Load More

Slide 34

Slide 34 text

Loading Show Results Load More

Slide 35

Slide 35 text

Loading Show Results Load More

Slide 36

Slide 36 text

Loading Show Results Load More Loading Show Results Load More

Slide 37

Slide 37 text

Loading Show Results Load More Loading Show Results Load More

Slide 38

Slide 38 text

Loading Show Results Load More Loading Show Results Load More

Slide 39

Slide 39 text

Loading Show Results Load More Loading Show Results Load More

Slide 40

Slide 40 text

Loading Show Results Load More Loading Show Results Load More

Slide 41

Slide 41 text

Hiccups • A decade old UI toolkit • Bug fixes in the framework require OS updates • Multiple tech stacks • Multiple sources of truth • Accidental complexity

Slide 42

Slide 42 text

Hiccups • A decade old UI toolkit • Bug fixes in the framework require OS updates • Multiple tech stacks • Multiple sources of truth • Accidental complexity

Slide 43

Slide 43 text

Jetpack Compose

Slide 44

Slide 44 text

• Component-based UI framework • Declarative • Favours composition over inheritance • Unbundled UI Toolkit • Kotlin only • “Pre-Alpha” ⛔

Slide 45

Slide 45 text

• Component-based UI framework • Declarative • Favours composition over inheritance • Unbundled UI Toolkit • Kotlin only • “Pre-Alpha” ⛔

Slide 46

Slide 46 text

• Component-based UI framework • Declarative • Favours composition over inheritance • Unbundled UI Toolkit • Kotlin only • “Pre-Alpha” ⛔

Slide 47

Slide 47 text

• Component-based UI framework • Declarative • Favours composition over inheritance • Unbundled UI Toolkit • Kotlin only • “Pre-Alpha” ⛔

Slide 48

Slide 48 text

• Component-based UI framework • Declarative • Favours composition over inheritance • Unbundled UI Toolkit • Kotlin only • “Pre-Alpha” ⛔

Slide 49

Slide 49 text

• Component-based UI framework • Declarative • Favours composition over inheritance • Unbundled UI Toolkit • Kotlin only • “Pre-Alpha” ⚠

Slide 50

Slide 50 text

• Component-based UI framework • Declarative • Favours composition over inheritance • Unbundled UI Toolkit • Kotlin only • “Pre-Alpha” ⚠

Slide 51

Slide 51 text

Components 1. Compose Runtime 2. Compose Compiler Plugin 3. Compose UI

Slide 52

Slide 52 text

Components 1. Compose Runtime 2. Compose Compiler Plugin 3. Compose UI

Slide 53

Slide 53 text

Components 1. Compose Runtime 2. Compose Compiler Plugin 3. Compose UI

Slide 54

Slide 54 text

Components 1. Compose Runtime 2. Compose Compiler Plugin 3. Compose UI

Slide 55

Slide 55 text

Components 1. Compose Runtime 2. Compose Compiler Plugin 3. Compose UI

Slide 56

Slide 56 text

Mental Model

Slide 57

Slide 57 text

ui = f(s)

Slide 58

Slide 58 text

ui = f(s)

Slide 59

Slide 59 text

ui = f(s)

Slide 60

Slide 60 text

ui = f(s)

Slide 61

Slide 61 text

ui = f(s)

Slide 62

Slide 62 text

No more references to views

Slide 63

Slide 63 text

@Composable fun Text( text: String, style: TextStyle? = null, textAlign: TextAlign = DefaultTextAlign, // More parameters… ) { // More code… } Composable functions

Slide 64

Slide 64 text

@Composable fun Text( text: String, style: TextStyle? = null, textAlign: TextAlign = DefaultTextAlign, // More parameters… ) { // More code… } Composable functions

Slide 65

Slide 65 text

@Composable fun Text( text: String, style: TextStyle? = null, textAlign: TextAlign = DefaultTextAlign, // More parameters… ) { // More code… } Composable functions

Slide 66

Slide 66 text

@Composable fun Text( text: String, style: TextStyle? = null, textAlign: TextAlign = DefaultTextAlign, // More parameters… ) { // More code… } Composable functions

Slide 67

Slide 67 text

A Composed Example (pun intended)

Slide 68

Slide 68 text

Slide 69

Slide 69 text

No content

Slide 70

Slide 70 text

No content

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

No content

Slide 73

Slide 73 text

ui = f(s)

Slide 74

Slide 74 text

ui = f(s)

Slide 75

Slide 75 text

@Model data class Fruit( val name: String, val price: Double = 2.0, var quantity: Int = 0 ) { val totalPrice: Double get() = quantity * price }

Slide 76

Slide 76 text

@Model data class Fruit( val name: String, val price: Double = 2.0, var quantity: Int = 0 ) { val totalPrice: Double get() = quantity * price }

Slide 77

Slide 77 text

@Model data class Fruit( val name: String, val price: Double = 2.0, var quantity: Int = 0 ) { val totalPrice: Double get() = quantity * price }

Slide 78

Slide 78 text

@Model data class Fruit( val name: String, val price: Double = 2.0, var quantity: Int = 0 ) { val totalPrice: Double get() = quantity * price }

Slide 79

Slide 79 text

@Model data class Fruit( val name: String, val price: Double = 2.0, var quantity: Int = 0 ) { val totalPrice: Double get() = quantity * price }

Slide 80

Slide 80 text

@Model data class Fruit( val name: String, val price: Double = 2.0, var quantity: Int = 0 ) { val totalPrice: Double get() = quantity * price }

Slide 81

Slide 81 text

@Model data class Fruit( val name: String, val price: Double = 2.0, var quantity: Int = 0 ) { val totalPrice: Double get() = quantity * price }

Slide 82

Slide 82 text

@Model data class Fruit( val name: String, val price: Double = 2.0, var quantity: Int = 0 ) { val totalPrice: Double get() = quantity * price }

Slide 83

Slide 83 text

@Model data class Fruit( val name: String, val price: Double = 2.0, var quantity: Int = 0 ) { val totalPrice: Double get() = quantity * price }

Slide 84

Slide 84 text

@Model data class Fruit( val name: String, val price: Double = 2.0, var quantity: Int = 0 ) { val totalPrice: Double get() = quantity * price }

Slide 85

Slide 85 text

@Model data class Fruit( val name: String, val price: Double = 2.0, var quantity: Int = 0 ) { val totalPrice: Double get() = quantity * price }

Slide 86

Slide 86 text

@Model data class Fruit( val name: String, val price: Double = 2.0, var quantity: Int = 0 ) { val totalPrice: Double get() = quantity * price }

Slide 87

Slide 87 text

ui = f(s)

Slide 88

Slide 88 text

ui = f(s) ✅

Slide 89

Slide 89 text

ui = f(s)

Slide 90

Slide 90 text

ui = f(s)

Slide 91

Slide 91 text

No content

Slide 92

Slide 92 text

Stepper

Slide 93

Slide 93 text

@Composable fun Stepper(count: Int, onCountChange: (Int) P> Unit) { val onRemoveOne = { onCountChange(count - 1) } val onAddOne = { onCountChange(count + 1) } Row { Button(text = "-", onClick = if (count > 0) onRemoveOne else null) WidthSpacer(8.dp) Container(width = 24.dp) { Text(text = "$count", style = +themeTextStyle { body1 }) } WidthSpacer(8.dp) Button(text = "+", onClick = onAddOne) } }

Slide 94

Slide 94 text

@Composable fun Stepper(count: Int, onCountChange: (Int) P> Unit) { val onRemoveOne = { onCountChange(count - 1) } val onAddOne = { onCountChange(count + 1) } Row { Button(text = "-", onClick = if (count > 0) onRemoveOne else null) WidthSpacer(8.dp) Container(width = 24.dp) { Text(text = "$count", style = +themeTextStyle { body1 }) } WidthSpacer(8.dp) Button(text = "+", onClick = onAddOne) } }

Slide 95

Slide 95 text

@Composable fun Stepper(count: Int, onCountChange: (Int) P> Unit) { val onRemoveOne = { onCountChange(count - 1) } val onAddOne = { onCountChange(count + 1) } Row { Button(text = "-", onClick = if (count > 0) onRemoveOne else null) WidthSpacer(8.dp) Container(width = 24.dp) { Text(text = "$count", style = +themeTextStyle { body1 }) } WidthSpacer(8.dp) Button(text = "+", onClick = onAddOne) } }

Slide 96

Slide 96 text

@Composable fun Stepper(count: Int, onCountChange: (Int) P> Unit) { val onRemoveOne = { onCountChange(count - 1) } val onAddOne = { onCountChange(count + 1) } Row { Button(text = "-", onClick = if (count > 0) onRemoveOne else null) WidthSpacer(8.dp) Container(width = 24.dp) { Text(text = "$count", style = +themeTextStyle { body1 }) } WidthSpacer(8.dp) Button(text = "+", onClick = onAddOne) } }

Slide 97

Slide 97 text

@Composable fun Stepper(count: Int, onCountChange: (Int) P> Unit) { val onRemoveOne = { onCountChange(count - 1) } val onAddOne = { onCountChange(count + 1) } Row { Button(text = "-", onClick = if (count > 0) onRemoveOne else null) WidthSpacer(8.dp) Container(width = 24.dp) { Text(text = "$count", style = +themeTextStyle { body1 }) } WidthSpacer(8.dp) Button(text = "+", onClick = onAddOne) } }

Slide 98

Slide 98 text

@Composable fun Stepper(count: Int, onCountChange: (Int) P> Unit) { val onRemoveOne = { onCountChange(count - 1) } val onAddOne = { onCountChange(count + 1) } Row { Button(text = "-", onClick = if (count > 0) onRemoveOne else null) WidthSpacer(8.dp) Container(width = 24.dp) { Text(text = "$count", style = +themeTextStyle { body1 }) } WidthSpacer(8.dp) Button(text = "+", onClick = onAddOne) } }

Slide 99

Slide 99 text

@Composable fun Stepper(count: Int, onCountChange: (Int) P> Unit) { val onRemoveOne = { onCountChange(count - 1) } val onAddOne = { onCountChange(count + 1) } Row { Button(text = "-", onClick = if (count > 0) onRemoveOne else null) WidthSpacer(8.dp) Container(width = 24.dp) { Text(text = "$count", style = +themeTextStyle { body1 }) } WidthSpacer(8.dp) Button(text = "+", onClick = onAddOne) } }

Slide 100

Slide 100 text

@Composable fun Stepper(count: Int, onCountChange: (Int) P> Unit) { val onRemoveOne = { onCountChange(count - 1) } val onAddOne = { onCountChange(count + 1) } Row { Button(text = "-", onClick = if (count > 0) onRemoveOne else null) WidthSpacer(8.dp) Container(width = 24.dp) { Text(text = "$count", style = +themeTextStyle { body1 }) } WidthSpacer(8.dp) Button(text = "+", onClick = onAddOne) } }

Slide 101

Slide 101 text

@Composable fun Stepper(count: Int, onCountChange: (Int) P> Unit) { val onRemoveOne = { onCountChange(count - 1) } val onAddOne = { onCountChange(count + 1) } Row { Button(text = "-", onClick = if (count > 0) onRemoveOne else null) WidthSpacer(8.dp) Container(width = 24.dp) { Text(text = "$count", style = +themeTextStyle { body1 }) } WidthSpacer(8.dp) Button(text = "+", onClick = onAddOne) } }

Slide 102

Slide 102 text

@Composable fun Stepper(count: Int, onCountChange: (Int) P> Unit) { val onRemoveOne = { onCountChange(count - 1) } val onAddOne = { onCountChange(count + 1) } Row { Button(text = "-", onClick = if (count > 0) onRemoveOne else null) WidthSpacer(8.dp) Container(width = 24.dp) { Text(text = "$count", style = +themeTextStyle { body1 }) } WidthSpacer(8.dp) Button(text = "+", onClick = onAddOne) } }

Slide 103

Slide 103 text

@Composable fun Stepper(count: Int, onCountChange: (Int) P> Unit) { val onRemoveOne = { onCountChange(count - 1) } val onAddOne = { onCountChange(count + 1) } Row { Button(text = "-", onClick = if (count > 0) onRemoveOne else null) WidthSpacer(8.dp) Container(width = 24.dp) { Text(text = "$count", style = +themeTextStyle { body1 }) } WidthSpacer(8.dp) Button(text = "+", onClick = onAddOne) } }

Slide 104

Slide 104 text

@Composable fun Stepper(count: Int, onCountChange: (Int) P> Unit) { val onRemoveOne = { onCountChange(count - 1) } val onAddOne = { onCountChange(count + 1) } Row { Button(text = "-", onClick = if (count > 0) onRemoveOne else null) WidthSpacer(8.dp) Container(width = 24.dp) { Text(text = "$count", style = +themeTextStyle { body1 }) } WidthSpacer(8.dp) Button(text = "+", onClick = onAddOne) } }

Slide 105

Slide 105 text

@Composable fun Stepper(count: Int, onCountChange: (Int) P> Unit) { val onRemoveOne = { onCountChange(count - 1) } val onAddOne = { onCountChange(count + 1) } Row { Button(text = "-", onClick = if (count > 0) onRemoveOne else null) WidthSpacer(8.dp) Container(width = 24.dp) { Text(text = "$count", style = +themeTextStyle { body1 }) } WidthSpacer(8.dp) Button(text = "+", onClick = onAddOne) } }

Slide 106

Slide 106 text

@Composable fun Stepper(count: Int, onCountChange: (Int) P> Unit) { val onRemoveOne = { onCountChange(count - 1) } val onAddOne = { onCountChange(count + 1) } Row { Button(text = "-", onClick = if (count > 0) onRemoveOne else null) WidthSpacer(8.dp) Container(width = 24.dp) { Text(text = "$count", style = +themeTextStyle { body1 }) } WidthSpacer(8.dp) Button(text = "+", onClick = onAddOne) } }

Slide 107

Slide 107 text

@Composable fun Stepper(count: Int, onCountChange: (Int) P> Unit) { val onRemoveOne = { onCountChange(count - 1) } val onAddOne = { onCountChange(count + 1) } Row { Button(text = "-", onClick = if (count > 0) onRemoveOne else null) WidthSpacer(8.dp) Container(width = 24.dp) { Text(text = "$count", style = +themeTextStyle { body1 }) } WidthSpacer(8.dp) Button(text = "+", onClick = onAddOne) } }

Slide 108

Slide 108 text

@Composable fun Stepper(count: Int, onCountChange: (Int) P> Unit) { val onRemoveOne = { onCountChange(count - 1) } val onAddOne = { onCountChange(count + 1) } Row { Button(text = "-", onClick = if (count > 0) onRemoveOne else null) WidthSpacer(8.dp) Container(width = 24.dp) { Text(text = "$count", style = +themeTextStyle { body1 }) } WidthSpacer(8.dp) Button(text = "+", onClick = onAddOne) } }

Slide 109

Slide 109 text

@Composable fun Stepper(count: Int, onCountChange: (Int) P> Unit) { val onRemoveOne = { onCountChange(count - 1) } val onAddOne = { onCountChange(count + 1) } Row { Button(text = "-", onClick = if (count > 0) onRemoveOne else null) WidthSpacer(8.dp) Container(width = 24.dp) { Text(text = "$count", style = +themeTextStyle { body1 }) } WidthSpacer(8.dp) Button(text = "+", onClick = onAddOne) } }

Slide 110

Slide 110 text

@Composable fun Stepper(count: Int, onCountChange: (Int) P> Unit) { val onRemoveOne = { onCountChange(count - 1) } val onAddOne = { onCountChange(count + 1) } Row { Button(text = "-", onClick = if (count > 0) onRemoveOne else null) WidthSpacer(8.dp) Container(width = 24.dp) { Text(text = "$count", style = +themeTextStyle { body1 }) } WidthSpacer(8.dp) Button(text = "+", onClick = onAddOne) } }

Slide 111

Slide 111 text

@Composable fun Stepper(count: Int, onCountChange: (Int) P> Unit) { val onRemoveOne = { onCountChange(count - 1) } val onAddOne = { onCountChange(count + 1) } Row { Button(text = "-", onClick = if (count > 0) onRemoveOne else null) WidthSpacer(8.dp) Container(width = 24.dp) { Text(text = "$count", style = +themeTextStyle { body1 }) } WidthSpacer(8.dp) Button(text = "+", onClick = onAddOne) } }

Slide 112

Slide 112 text

@Composable fun Stepper(count: Int, onCountChange: (Int) P> Unit) { val onRemoveOne = { onCountChange(count - 1) } val onAddOne = { onCountChange(count + 1) } Row { Button(text = "-", onClick = if (count > 0) onRemoveOne else null) WidthSpacer(8.dp) Container(width = 24.dp) { Text(text = "$count", style = +themeTextStyle { body1 }) } WidthSpacer(8.dp) Button(text = "+", onClick = onAddOne) } }

Slide 113

Slide 113 text

@Composable fun Stepper(count: Int, onCountChange: (Int) P> Unit) { val onRemoveOne = { onCountChange(count - 1) } val onAddOne = { onCountChange(count + 1) } Row { Button(text = "-", onClick = if (count > 0) onRemoveOne else null) WidthSpacer(8.dp) Container(width = 24.dp) { Text(text = "$count", style = +themeTextStyle { body1 }) } WidthSpacer(8.dp) Button(text = "+", onClick = onAddOne) } }

Slide 114

Slide 114 text

@Composable fun Stepper(count: Int, onCountChange: (Int) P> Unit) { val onRemoveOne = { onCountChange(count - 1) } val onAddOne = { onCountChange(count + 1) } Row { Button(text = "-", onClick = if (count > 0) onRemoveOne else null) WidthSpacer(8.dp) Container(width = 24.dp) { Text(text = "$count", style = +themeTextStyle { body1 }) } WidthSpacer(8.dp) Button(text = "+", onClick = onAddOne) } }

Slide 115

Slide 115 text

@Composable fun Stepper(count: Int, onCountChange: (Int) P> Unit) { val onRemoveOne = { onCountChange(count - 1) } val onAddOne = { onCountChange(count + 1) } Row { Button(text = "-", onClick = if (count > 0) onRemoveOne else null) WidthSpacer(8.dp) Container(width = 24.dp) { Text(text = "$count", style = +themeTextStyle { body1 }) } WidthSpacer(8.dp) Button(text = "+", onClick = onAddOne) } }

Slide 116

Slide 116 text

@Composable fun Stepper(count: Int, onCountChange: (Int) P> Unit) { val onRemoveOne = { onCountChange(count - 1) } val onAddOne = { onCountChange(count + 1) } Row { Button(text = "-", onClick = if (count > 0) onRemoveOne else null) WidthSpacer(8.dp) Container(width = 24.dp) { Text(text = "$count", style = +themeTextStyle { body1 }) } WidthSpacer(8.dp) Button(text = "+", onClick = onAddOne) } }

Slide 117

Slide 117 text

@Composable fun Stepper(count: Int, onCountChange: (Int) P> Unit) { val onRemoveOne = { onCountChange(count - 1) } val onAddOne = { onCountChange(count + 1) } Row { Button(text = "-", onClick = if (count > 0) onRemoveOne else null) WidthSpacer(8.dp) Container(width = 24.dp) { Text(text = "$count", style = +themeTextStyle { body1 }) } WidthSpacer(8.dp) Button(text = "+", onClick = onAddOne) } }

Slide 118

Slide 118 text

@Composable fun Stepper(count: Int, onCountChange: (Int) P> Unit) { val onRemoveOne = { onCountChange(count - 1) } val onAddOne = { onCountChange(count + 1) } Row { Button(text = "-", onClick = if (count > 0) onRemoveOne else null) WidthSpacer(8.dp) Container(width = 24.dp) { Text(text = "$count", style = +themeTextStyle { body1 }) } WidthSpacer(8.dp) Button(text = "+", onClick = onAddOne) } }

Slide 119

Slide 119 text

@Composable fun Stepper(count: Int, onCountChange: (Int) P> Unit) { val onRemoveOne = { onCountChange(count - 1) } val onAddOne = { onCountChange(count + 1) } Row { Button(text = "-", onClick = if (count > 0) onRemoveOne else null) WidthSpacer(8.dp) Container(width = 24.dp) { Text(text = "$count", style = +themeTextStyle { body1 }) } WidthSpacer(8.dp) Button(text = "+", onClick = onAddOne) } }

Slide 120

Slide 120 text

Stepper

Slide 121

Slide 121 text

Stepper ✅

Slide 122

Slide 122 text

No content

Slide 123

Slide 123 text

Fruit Row

Slide 124

Slide 124 text

@Composable fun FruitRow(fruit: Fruit) { Padding(padding = EdgeInsets(left = 16.dp, right = 16.dp)) { FlexRow { expanded(1.0f) { Text(text = "${fruit.name} ($${fruit.totalPrice})", style = +themeTextStyle { h6 }) } inflexible { Stepper(fruit.quantity, onCountChange = { fruit.quantity = it }) } } } }

Slide 125

Slide 125 text

@Composable fun FruitRow(fruit: Fruit) { Padding(padding = EdgeInsets(left = 16.dp, right = 16.dp)) { FlexRow { expanded(1.0f) { Text(text = "${fruit.name} ($${fruit.totalPrice})", style = +themeTextStyle { h6 }) } inflexible { Stepper(fruit.quantity, onCountChange = { fruit.quantity = it }) } } } }

Slide 126

Slide 126 text

@Composable fun FruitRow(fruit: Fruit) { Padding(padding = EdgeInsets(left = 16.dp, right = 16.dp)) { FlexRow { expanded(1.0f) { Text(text = "${fruit.name} ($${fruit.totalPrice})", style = +themeTextStyle { h6 }) } inflexible { Stepper(fruit.quantity, onCountChange = { fruit.quantity = it }) } } } }

Slide 127

Slide 127 text

@Composable fun FruitRow(fruit: Fruit) { Padding(padding = EdgeInsets(left = 16.dp, right = 16.dp)) { FlexRow { expanded(1.0f) { Text(text = "${fruit.name} ($${fruit.totalPrice})", style = +themeTextStyle { h6 }) } inflexible { Stepper(fruit.quantity, onCountChange = { fruit.quantity = it }) } } } }

Slide 128

Slide 128 text

@Composable fun FruitRow(fruit: Fruit) { Padding(padding = EdgeInsets(left = 16.dp, right = 16.dp)) { FlexRow { expanded(1.0f) { Text(text = "${fruit.name} ($${fruit.totalPrice})", style = +themeTextStyle { h6 }) } inflexible { Stepper(fruit.quantity, onCountChange = { fruit.quantity = it }) } } } }

Slide 129

Slide 129 text

@Composable fun FruitRow(fruit: Fruit) { Padding(padding = EdgeInsets(left = 16.dp, right = 16.dp)) { FlexRow { expanded(1.0f) { Text(text = "${fruit.name} ($${fruit.totalPrice})", style = +themeTextStyle { h6 }) } inflexible { Stepper(fruit.quantity, onCountChange = { fruit.quantity = it }) } } } }

Slide 130

Slide 130 text

@Composable fun FruitRow(fruit: Fruit) { Padding(padding = EdgeInsets(left = 16.dp, right = 16.dp)) { FlexRow { expanded(1.0f) { Text(text = "${fruit.name} ($${fruit.totalPrice})", style = +themeTextStyle { h6 }) } inflexible { Stepper(fruit.quantity, onCountChange = { fruit.quantity = it }) } } } }

Slide 131

Slide 131 text

@Composable fun FruitRow(fruit: Fruit) { Padding(padding = EdgeInsets(left = 16.dp, right = 16.dp)) { FlexRow { expanded(1.0f) { Text(text = "${fruit.name} ($${fruit.totalPrice})", style = +themeTextStyle { h6 }) } inflexible { Stepper(fruit.quantity, onCountChange = { fruit.quantity = it }) } } } }

Slide 132

Slide 132 text

@Composable fun FruitRow(fruit: Fruit) { Padding(padding = EdgeInsets(left = 16.dp, right = 16.dp)) { FlexRow { expanded(1.0f) { Text(text = "${fruit.name} ($${fruit.totalPrice})", style = +themeTextStyle { h6 }) } inflexible { Stepper(fruit.quantity, onCountChange = { fruit.quantity = it }) } } } }

Slide 133

Slide 133 text

@Composable fun FruitRow(fruit: Fruit) { Padding(padding = EdgeInsets(left = 16.dp, right = 16.dp)) { FlexRow { expanded(1.0f) { Text(text = "${fruit.name} ($${fruit.totalPrice})", style = +themeTextStyle { h6 }) } inflexible { Stepper(fruit.quantity, onCountChange = { fruit.quantity = it }) } } } }

Slide 134

Slide 134 text

@Composable fun FruitRow(fruit: Fruit) { Padding(padding = EdgeInsets(left = 16.dp, right = 16.dp)) { FlexRow { expanded(1.0f) { Text(text = "${fruit.name} ($${fruit.totalPrice})", style = +themeTextStyle { h6 }) } inflexible { Stepper(fruit.quantity, onCountChange = { fruit.quantity = it }) } } } }

Slide 135

Slide 135 text

@Composable fun FruitRow(fruit: Fruit) { Padding(padding = EdgeInsets(left = 16.dp, right = 16.dp)) { FlexRow { expanded(1.0f) { Text(text = "${fruit.name} ($${fruit.totalPrice})", style = +themeTextStyle { h6 }) } inflexible { Stepper(fruit.quantity, onCountChange = { fruit.quantity = it }) } } } }

Slide 136

Slide 136 text

@Composable fun FruitRow(fruit: Fruit) { Padding(padding = EdgeInsets(left = 16.dp, right = 16.dp)) { FlexRow { expanded(1.0f) { Text(text = "${fruit.name} ($${fruit.totalPrice})", style = +themeTextStyle { h6 }) } inflexible { Stepper(fruit.quantity, onCountChange = { fruit.quantity = it }) } } } }

Slide 137

Slide 137 text

@Composable fun FruitRow(fruit: Fruit) { Padding(padding = EdgeInsets(left = 16.dp, right = 16.dp)) { FlexRow { expanded(1.0f) { Text(text = "${fruit.name} ($${fruit.totalPrice})", style = +themeTextStyle { h6 }) } inflexible { Stepper(fruit.quantity, onCountChange = { fruit.quantity = it }) } } } }

Slide 138

Slide 138 text

@Composable fun FruitRow(fruit: Fruit) { Padding(padding = EdgeInsets(left = 16.dp, right = 16.dp)) { FlexRow { expanded(1.0f) { Text(text = "${fruit.name} ($${fruit.totalPrice})", style = +themeTextStyle { h6 }) } inflexible { Stepper(fruit.quantity, onCountChange = { fruit.quantity = it }) } } } }

Slide 139

Slide 139 text

@Composable fun FruitRow(fruit: Fruit) { Padding(padding = EdgeInsets(left = 16.dp, right = 16.dp)) { FlexRow { expanded(1.0f) { Text(text = "${fruit.name} ($${fruit.totalPrice})", style = +themeTextStyle { h6 }) } inflexible { Stepper(fruit.quantity, onCountChange = { fruit.quantity = it }) } } } }

Slide 140

Slide 140 text

@Composable fun FruitRow(fruit: Fruit) { Padding(padding = EdgeInsets(left = 16.dp, right = 16.dp)) { FlexRow { expanded(1.0f) { Text(text = "${fruit.name} ($${fruit.totalPrice})", style = +themeTextStyle { h6 }) } inflexible { Stepper(fruit.quantity, onCountChange = { fruit.quantity = it }) } } } }

Slide 141

Slide 141 text

@Composable fun FruitRow(fruit: Fruit) { Padding(padding = EdgeInsets(left = 16.dp, right = 16.dp)) { FlexRow { expanded(1.0f) { Text(text = "${fruit.name} ($${fruit.totalPrice})", style = +themeTextStyle { h6 }) } inflexible { Stepper(fruit.quantity, onCountChange = { fruit.quantity = it }) } } } }

Slide 142

Slide 142 text

@Composable fun FruitRow(fruit: Fruit) { Padding(padding = EdgeInsets(left = 16.dp, right = 16.dp)) { FlexRow { expanded(1.0f) { Text(text = "${fruit.name} ($${fruit.totalPrice})", style = +themeTextStyle { h6 }) } inflexible { Stepper(fruit.quantity, onCountChange = { fruit.quantity = it }) } } } }

Slide 143

Slide 143 text

Fruit Row

Slide 144

Slide 144 text

Fruit Row ✅

Slide 145

Slide 145 text

State?

Slide 146

Slide 146 text

FruitApp { val apple = +memo { Fruit("Apple", price = 2.0) } FruitRow(apple) }

Slide 147

Slide 147 text

FruitApp { val apple = +memo { Fruit("Apple", price = 2.0) } FruitRow(apple) }

Slide 148

Slide 148 text

FruitApp { val apple = +memo { Fruit("Apple", price = 2.0) } FruitRow(apple) }

Slide 149

Slide 149 text

FruitApp { val apple = +memo { Fruit("Apple", price = 2.0) } FruitRow(apple) }

Slide 150

Slide 150 text

FruitApp { val apple = +memo { Fruit("Apple", price = 2.0) } FruitRow(apple) }

Slide 151

Slide 151 text

FruitApp { val apple = +memo { Fruit("Apple", price = 2.0) } FruitRow(apple) }

Slide 152

Slide 152 text

FruitApp { val apple = +memo { Fruit("Apple", price = 2.0) } FruitRow(apple) }

Slide 153

Slide 153 text

FruitApp { val apple = +memo { Fruit("Apple", price = 2.0) } FruitRow(apple) }

Slide 154

Slide 154 text

Observations • Smallest reusable unit is a function • Stateless widgets (“controlled components”) • Single source of truth • Structure of the code matches the structure of the view hierarchy • UI was built from leaf to node • State stays as close to the root as possible • Declarative • Reduction in boilerplate

Slide 155

Slide 155 text

Observations • Smallest reusable unit is a function • Stateless widgets (“controlled components”) • Single source of truth • Structure of the code matches the structure of the view hierarchy • UI was built from leaf to node • State stays as close to the root as possible • Declarative • Reduction in boilerplate

Slide 156

Slide 156 text

Observations • Smallest reusable unit is a function • Stateless widgets (“controlled components”) • Single source of truth • Structure of the code matches the structure of the view hierarchy • UI was built from leaf to node • State stays as close to the root as possible • Declarative • Reduction in boilerplate

Slide 157

Slide 157 text

Observations • Smallest reusable unit is a function • Stateless widgets (“controlled components”) • Single source of truth • Structure of the code matches the structure of the view hierarchy • UI was built from leaf to node • State stays as close to the root as possible • Declarative • Reduction in boilerplate

Slide 158

Slide 158 text

Observations • Smallest reusable unit is a function • Stateless widgets (“controlled components”) • Single source of truth • Structure of the code matches the structure of the view hierarchy • UI was built from leaf to node • State stays as close to the root as possible • Declarative • Reduction in boilerplate

Slide 159

Slide 159 text

Observations • Smallest reusable unit is a function • Stateless widgets (“controlled components”) • Single source of truth • Structure of the code matches the structure of the view hierarchy • UI was built from leaf to node • State stays as close to the root as possible • Declarative • Reduction in boilerplate

Slide 160

Slide 160 text

Observations • Smallest reusable unit is a function • Stateless widgets (“controlled components”) • Single source of truth • Structure of the code matches the structure of the view hierarchy • UI was built from leaf to node • State stays as close to the root as possible • Declarative • Reduction in boilerplate

Slide 161

Slide 161 text

Observations • Smallest reusable unit is a function • Stateless widgets (“controlled components”) • Single source of truth • Structure of the code matches the structure of the view hierarchy • UI was built from leaf to node • State stays as close to the root as possible • Declarative • Reduction in boilerplate

Slide 162

Slide 162 text

Observations • Smallest reusable unit is a function • Stateless widgets (“controlled components”) • Single source of truth • Structure of the code matches the structure of the view hierarchy • UI was built from leaf to node • State stays as close to the root as possible • Declarative • Reduction in boilerplate

Slide 163

Slide 163 text

Observations • Smallest reusable unit is a function • Stateless widgets (“controlled components”) • Single source of truth • Structure of the code matches the structure of the view hierarchy • UI was built from leaf to node • State stays as close to the root as possible • Declarative • Reduction in boilerplate

Slide 164

Slide 164 text

No content

Slide 165

Slide 165 text

Resources • http://intelligiblebabble.com/content-on-declarative-ui/ • http://intelligiblebabble.com/compose-from-first-principles/ • https://www.youtube.com/watch?v=4EFjDSijAZU • https://github.com/SimonSchubert/Braincup • https://developer.android.com/jetpack/compose • #compose channel at https://kotlinlang.slack.com/ • https://speakerdeck.com/benoberkfell/prototyping-with- jetpack-compose?slide=67

Slide 166

Slide 166 text

@ragunathjawahar Twitter / Medium / GitHub end;