Slide 1

Slide 1 text

@[email protected] Playing in the Treehouse with Redwood and Zipline

Slide 2

Slide 2 text

Redwood Zipline

Slide 3

Slide 3 text

Redwood Zipline Treehouse

Slide 4

Slide 4 text

Figma Android Eng iOS Eng Web Eng Redwood

Slide 5

Slide 5 text

Figma Android Eng iOS Eng Web Eng View Impl UIKit Impl DOM Impl Redwood

Slide 6

Slide 6 text

Figma Android Eng iOS Eng Web Eng View Impl UIKit Impl DOM Impl Redwood Redwood

Slide 7

Slide 7 text

Figma Android Eng iOS Eng Web Eng View Impl UIKit Impl DOM Impl Redwood Redwood

Slide 8

Slide 8 text

Schema Widgets Redwood

Slide 9

Slide 9 text

Schema Widgets Compose Redwood

Slide 10

Slide 10 text

Redwood Schema data class Column( val children: () -> Unit, ) data class TextInput( val hint: String, val text: String, val onTextChanged: (String) -> Unit, )

Slide 11

Slide 11 text

Redwood Schema data class Column( val children: () -> Unit, val birthday: LocalDate, ) data class TextInput( val hint: String, val text: String, val onTextChanged: (String) -> Unit, )

Slide 12

Slide 12 text

Redwood Schema import kotlinx.datetime.LocalDate data class Column( val children: () -> Unit, val birthday: LocalDate, ) data class TextInput( val hint: String, val text: String, val onTextChanged: (String) -> Unit, )

Slide 13

Slide 13 text

Redwood Schema data class Column( val children: () -> Unit, ) data class TextInput( val hint: String, val text: String, val onTextChanged: (String) -> Unit, )

Slide 14

Slide 14 text

Redwood Schema data class Column( val children: () -> Unit, ) data class TextInput( val hint: String, val text: String, val onTextChanged: (String) -> Unit, )

Slide 15

Slide 15 text

Redwood Schema data class Column( val children: () -> Unit, ) data class TextInput( val hint: String, val text: String, val onTextChanged: (String) -> Unit, )

Slide 16

Slide 16 text

Redwood Schema data class Column( val children: () -> Unit, ) data class TextInput( val hint: String, val text: String, val onTextChanged: (String) -> Unit, )

Slide 17

Slide 17 text

Redwood Schema data class Column( val children: () -> Unit, ) data class TextInput( val hint: String, val text: String, val onTextChanged: (String) -> Unit, )

Slide 18

Slide 18 text

Redwood Schema

Slide 19

Slide 19 text

Redwood Schema data class Row(…) data class Column(…) data class Image( val url: HttpUrl, val size: ImageSize, val borderStyle: BorderStyle, ) data class Text( val text: String, val font: FontFamily, val style: FontStyle, )

Slide 20

Slide 20 text

Redwood Schema data class ContactItem( val name: String, val image: HttpUrl, val content: () -> Unit, ) data class Text( val text: String, val font: FontFamily, val style: FontStyle, )

Slide 21

Slide 21 text

Redwood Schema data class Row(…) data class Column(…) data class Image( val url: HttpUrl, val size: ImageSize, val borderStyle: BorderStyle, ) data class Text( val text: String, val font: FontFamily, val style: FontStyle, ) data class ContactItem( val name: String, val image: HttpUrl, val content: () -> Unit, ) data class Text( val text: String, val font: FontFamily, val style: FontStyle, )

Slide 22

Slide 22 text

Redwood Compose data class Column( val children: () -> Unit, ) data class TextInput( val hint: String, val text: String, val onTextChanged: (String) -> Unit, )

Slide 23

Slide 23 text

Redwood Compose data class Column( val children: () -> Unit, ) data class TextInput( val hint: String, val text: String, val onTextChanged: (String) -> Unit, ) @Composable fun Column( children: @Composable () -> Unit, ) { … } @Composable fun TextInput( hint: String, text: String, onTextChanged: (String) -> Unit, ) { … }

Slide 24

Slide 24 text

Redwood Compose @Composable fun Column( children: @Composable () -> Unit, ) { … } @Composable fun TextInput( hint: String, text: String, onTextChanged: (String) -> Unit, ) { … }

Slide 25

Slide 25 text

Redwood Compose Column { var query by remember { mutableStateOf("") } TextInput( hint = "Search", text = query, onTextChanged = { query = it }, ) val images = LoadImages(query) ScrollableColumn { for (image in images) { Image(url = image.url) } } }

Slide 26

Slide 26 text

Redwood Widgets data class Column( val children: () -> Unit, ) data class TextInput( val hint: String, val text: String, val onTextChanged: (String) -> Unit, )

Slide 27

Slide 27 text

Redwood Widgets data class Column( val children: () -> Unit, ) data class TextInput( val hint: String, val text: String, val onTextChanged: (String) -> Unit, ) interface Column : Widget { val children: Widget.Children } interface TextInput : Widget { fun hint(hint: String) fun text(text: String) fun onTextChanged(onTextChanged: ((String) -> Unit)?) }

Slide 28

Slide 28 text

Redwood Widgets interface Column : Widget { val children: Widget.Children } interface TextInput : Widget { fun hint(hint: String) fun text(text: String) fun onTextChanged(onTextChanged: ((String) -> Unit)?) }

Slide 29

Slide 29 text

Redwood Widgets interface Widget { val value: T } interface Column : Widget { val children: Widget.Children } interface TextInput : Widget { fun hint(hint: String) fun text(text: String) fun onTextChanged(onTextChanged: ((String) -> Unit)?) }

Slide 30

Slide 30 text

Redwood Widgets interface Column : Widget { val children: Widget.Children }

Slide 31

Slide 31 text

Redwood Widgets class ViewColumn : Column interface Column : Widget { val children: Widget.Children }

Slide 32

Slide 32 text

Redwood Widgets class ViewColumn( override val value: LinearLayout, ) : Column interface Column : Widget { val children: Widget.Children }

Slide 33

Slide 33 text

Redwood Widgets class ViewColumn( override val value: LinearLayout, ) : Column { override val children = ViewGroupChildren(value) } interface Column : Widget { val children: Widget.Children }

Slide 34

Slide 34 text

Redwood Widgets interface EmojiWidgetFactory : Widget.Factory { fun Column(): Column fun ScrollableColumn(): ScrollableColumn fun TextInput(): TextInput fun Image(): Image }

Slide 35

Slide 35 text

Redwood Widgets interface EmojiWidgetFactory : Widget.Factory { fun Column(): Column … }

Slide 36

Slide 36 text

Redwood Widgets class EmojiViewWidgetFactory : EmojiWidgetFactory interface EmojiWidgetFactory : Widget.Factory { fun Column(): Column … }

Slide 37

Slide 37 text

Redwood Widgets class EmojiViewWidgetFactory( private val context: Context, ) : EmojiWidgetFactory interface EmojiWidgetFactory : Widget.Factory { fun Column(): Column … }

Slide 38

Slide 38 text

Redwood Widgets class EmojiViewWidgetFactory( private val context: Context, ) : EmojiWidgetFactory { override fun Column(): Column { } } interface EmojiWidgetFactory : Widget.Factory { fun Column(): Column … }

Slide 39

Slide 39 text

Redwood Widgets class EmojiViewWidgetFactory( private val context: Context, ) : EmojiWidgetFactory { override fun Column(): Column { return ViewColumn(LinearLayout(context)) } } interface EmojiWidgetFactory : Widget.Factory { fun Column(): Column … }

Slide 40

Slide 40 text

Redwood Widgets class EmojiViewWidgetFactory( private val context: Context, ) : EmojiWidgetFactory { override fun Column(): Column { return ViewColumn(LinearLayout(context)) } … } interface EmojiWidgetFactory : Widget.Factory { fun Column(): Column … }

Slide 41

Slide 41 text

@Composable fun MessageCard(msg: Message) { Row(modifier = Modifier.padding(all = 8.dp)) { Image( painter = painterResource(R.drawable.profile_picture), contentDescription = null, modifier = Modifier .size(40.dp) .clip(CircleShape) .border(1.5.dp, MaterialTheme.colors.secondary, CircleShape), ) Spacer(modifier = Modifier.width(8.dp)) Column { Text( text = msg.author, color = MaterialTheme.colors.secondaryVariant, style = MaterialTheme.typography.subtitle2, ) Spacer(modifier = Modifier.height(4.dp)) Surface(shape = MaterialTheme.shapes.medium, elevation = 1.dp) { Text( text = msg.body, modifier = Modifier.padding(all = 4.dp), style = MaterialTheme.typography.body2, ) } } } }

Slide 42

Slide 42 text

@Composable fun MessageCard(…) { Row(…) { Image(…) Spacer(…) Column { Text(…) Spacer(…) Surface(…) { Text(…) } } } }

Slide 43

Slide 43 text

@Composable fun MessageCard(…) { Row(…) { Image(…) Spacer(…) Column { Text(…) Spacer(…) Surface(…) { Text(…) } } } } Root

Slide 44

Slide 44 text

@Composable fun MessageCard(…) { Row(…) { Image(…) Spacer(…) Column { Text(…) Spacer(…) Surface(…) { Text(…) } } } } Root

Slide 45

Slide 45 text

@Composable fun MessageCard(…) { Row(…) { Image(…) Spacer(…) Column { Text(…) Spacer(…) Surface(…) { Text(…) } } } } Root Row

Slide 46

Slide 46 text

@Composable fun MessageCard(…) { Row(…) { Image(…) Spacer(…) Column { Text(…) Spacer(…) Surface(…) { Text(…) } } } } Root Row

Slide 47

Slide 47 text

@Composable fun MessageCard(…) { Row(…) { Image(…) Spacer(…) Column { Text(…) Spacer(…) Surface(…) { Text(…) } } } } Root Row Image

Slide 48

Slide 48 text

@Composable fun MessageCard(…) { Row(…) { Image(…) Spacer(…) Column { Text(…) Spacer(…) Surface(…) { Text(…) } } } } Root Row Spacer Image

Slide 49

Slide 49 text

Spacer Image Column @Composable fun MessageCard(…) { Row(…) { Image(…) Spacer(…) Column { Text(…) Spacer(…) Surface(…) { Text(…) } } } } Root Row

Slide 50

Slide 50 text

Spacer Image Column @Composable fun MessageCard(…) { Row(…) { Image(…) Spacer(…) Column { Text(…) Spacer(…) Surface(…) { Text(…) } } } } Root Row

Slide 51

Slide 51 text

Spacer Image Column @Composable fun MessageCard(…) { Row(…) { Image(…) Spacer(…) Column { Text(…) Spacer(…) Surface(…) { Text(…) } } } } Root Row Text

Slide 52

Slide 52 text

Spacer Image Column @Composable fun MessageCard(…) { Row(…) { Image(…) Spacer(…) Column { Text(…) Spacer(…) Surface(…) { Text(…) } } } } Root Row Text Spacer

Slide 53

Slide 53 text

Text Spacer Surface Spacer Image Column @Composable fun MessageCard(…) { Row(…) { Image(…) Spacer(…) Column { Text(…) Spacer(…) Surface(…) { Text(…) } } } } Root Row

Slide 54

Slide 54 text

Text Spacer Surface Spacer Image Column @Composable fun MessageCard(…) { Row(…) { Image(…) Spacer(…) Column { Text(…) Spacer(…) Surface(…) { Text(…) } } } } Root Row

Slide 55

Slide 55 text

Text Spacer Surface Spacer Image Column @Composable fun MessageCard(…) { Row(…) { Image(…) Spacer(…) Column { Text(…) Spacer(…) Surface(…) { Text(…) } } } } Root Row Text

Slide 56

Slide 56 text

@Composable fun MessageCard(…) { Row(…) { Image(…) Spacer(…) Column { Text(…) Spacer(…) Surface(…) { Text(…) } } } } Root Row Spacer Image Column Text Spacer Surface Text

Slide 57

Slide 57 text

Root

Slide 58

Slide 58 text

Root FrameLayout

Slide 59

Slide 59 text

Root Row Spacer Image Column Text Spacer Surface Text FrameLayout LinearLayout View ImageView LinearLayout TextView View FrameLayout TextView

Slide 60

Slide 60 text

Root Row Spacer Image Column Text Spacer Surface Text UIStackView UIStackView UIView UIImageView UIStackView UITextView UIView UIView UITextView

Slide 61

Slide 61 text

Root Row Spacer Image Column Text Spacer Surface Text

Slide 62

Slide 62 text

Redwood Compose & Widgets @Composable fun TextInput( hint: String, text: String, onTextChanged: (String) -> Unit, ) { … }

Slide 63

Slide 63 text

Redwood Compose & Widgets @Composable fun TextInput( hint: String, text: String, onTextChanged: (String) -> Unit, ) {
 ComposeNode<…>( factory = …, update = { … }, ) }

Slide 64

Slide 64 text

Redwood Compose & Widgets @Composable fun TextInput( hint: String, text: String, onTextChanged: (String) -> Unit, ) {
 RedwoodComposeNode<…>( factory = …, update = { … }, ) }

Slide 65

Slide 65 text

Redwood Compose & Widgets @Composable fun TextInput( hint: String, text: String, onTextChanged: (String) -> Unit, ) {
 RedwoodComposeNode, …>( factory = …, update = { … }, ) }

Slide 66

Slide 66 text

Redwood Compose & Widgets @Composable fun TextInput( hint: String, text: String, onTextChanged: (String) -> Unit, ) {
 RedwoodComposeNode, TextInput<*>>( factory = …, update = { … }, ) }

Slide 67

Slide 67 text

Redwood Compose & Widgets @Composable fun TextInput( hint: String, text: String, onTextChanged: (String) -> Unit, ) {
 RedwoodComposeNode, TextInput<*>>( factory = EmojiWidgetFactory<*>::TextInput, update = { … }, ) }

Slide 68

Slide 68 text

Redwood Compose & Widgets @Composable fun TextInput( hint: String, text: String, onTextChanged: (String) -> Unit, ) { RedwoodComposeNode, TextInput<*>>( factory = EmojiWidgetFactory<*>::TextInput, update = { set(hint) { hint(hint) } set(text) { text(text) } set(onTextChanged) { onTextChanged(onTextChanged) } }, ) }

Slide 69

Slide 69 text

Redwood Compose & Widgets @Composable fun TextInput( hint: String, text: String, onTextChanged: (String) -> Unit, ) { RedwoodComposeNode, TextInput<*>>( factory = EmojiWidgetFactory<*>::TextInput, update = { set(hint) { hint(hint) } set(text) { text(text) } set(onTextChanged) { onTextChanged(onTextChanged) } }, ) }

Slide 70

Slide 70 text

Root Row Spacer Image Column Text Spacer Surface Text FrameLayout LinearLayout View ImageView LinearLayout TextView View FrameLayout TextView

Slide 71

Slide 71 text

Root Row Spacer Image Column Text Spacer Surface Text FrameLayout LinearLayout View ImageView LinearLayout TextView View FrameLayout TextView

Slide 72

Slide 72 text

Root Row Spacer Image Column Text Spacer Surface Text FrameLayout LinearLayout View ImageView LinearLayout TextView View FrameLayout TextView Text(msg.body, …)

Slide 73

Slide 73 text

Root Row Spacer Image Column Text Spacer Surface Text FrameLayout LinearLayout View ImageView LinearLayout View FrameLayout TextView TextView Text(msg.body, …)

Slide 74

Slide 74 text

Redwood Layout data class Row( val width: Constraint, val height: Constraint, val margin: Margin, val overflow: Overflow, val horizontalAlignment: MainAxisAlignment, val verticalAlignment: CrossAxisAlignment, val children: RowScope.() -> Unit, ) data class Column(…) data class Spacer(…)

Slide 75

Slide 75 text

Redwood Counter Sample data class Text( val text: String?, ) data class Button( val text: String?, val enabled: Boolean = true, val onClick: (() -> Unit)? = null, )

Slide 76

Slide 76 text

Redwood Counter Sample @Composable fun Counter(value: Int = 0) { var count by remember { mutableStateOf(value) } Column { Button("-1", onClick = { count-- }) Text("Count: $count") Button("+1", onClick = { count++ }) } }

Slide 77

Slide 77 text

Redwood Counter Sample @Composable fun Counter(value: Int = 0) { var count by remember { mutableStateOf(value) } Column { Button("-1", onClick = { count-- }) Text("Count: $count") Button("+1", onClick = { count++ }) } }

Slide 78

Slide 78 text

Redwood Counter Sample @Composable fun Counter(value: Int = 0) { var count by remember { mutableStateOf(value) } Column { Button("-1", onClick = { count-- }) Text("Count: $count") Button("+1", onClick = { count++ }) } }

Slide 79

Slide 79 text

Redwood Counter Sample @Composable fun Counter(value: Int = 0) { var count by remember { mutableStateOf(value) } Column { Button("-1", onClick = { count-- }) Text("Count: $count") Button("+1", onClick = { count++ }) } }

Slide 80

Slide 80 text

Redwood Counter Sample @Composable fun Counter(value: Int = 0) { var count by remember { mutableStateOf(value) } Column { Button("-1", onClick = { count-- }) Text("Count: $count") Button("+1", onClick = { count++ }) } }

Slide 81

Slide 81 text

Redwood Counter Sample class AndroidText( override val value: TextView, ) : Text { override fun text(text: String?) { value.text = text } }

Slide 82

Slide 82 text

Redwood Counter Sample val root = findViewById(android.R.id.content)!! val composition = RedwoodComposition( scope = mainScope, container = ViewGroupChildren(root), provider = SchemaWidgetFactories( Counter = AndroidCounterWidgetFactory(this), RedwoodLayout = ViewRedwoodLayoutWidgetFactory(this), ), )

Slide 83

Slide 83 text

Redwood Counter Sample val root = findViewById(android.R.id.content)!! val composition = RedwoodComposition( scope = mainScope, container = ViewGroupChildren(root), provider = SchemaWidgetFactories( Counter = AndroidCounterWidgetFactory(this), RedwoodLayout = ViewRedwoodLayoutWidgetFactory(this), ), )

Slide 84

Slide 84 text

Redwood Counter Sample val root = findViewById(android.R.id.content)!! val composition = RedwoodComposition( scope = mainScope, container = ViewGroupChildren(root), provider = SchemaWidgetFactories( Counter = AndroidCounterWidgetFactory(this), RedwoodLayout = ViewRedwoodLayoutWidgetFactory(this), ), )

Slide 85

Slide 85 text

Redwood Counter Sample val root = findViewById(android.R.id.content)!! val composition = RedwoodComposition( scope = mainScope, container = ViewGroupChildren(root), provider = SchemaWidgetFactories( Counter = AndroidCounterWidgetFactory(this), RedwoodLayout = ViewRedwoodLayoutWidgetFactory(this), ), )

Slide 86

Slide 86 text

Redwood Counter Sample val root = findViewById(android.R.id.content)!! val composition = RedwoodComposition( scope = mainScope, container = ViewGroupChildren(root), provider = SchemaWidgetFactories( Counter = AndroidCounterWidgetFactory(this), RedwoodLayout = ViewRedwoodLayoutWidgetFactory(this), ), )

Slide 87

Slide 87 text

Redwood Counter Sample val root = findViewById(android.R.id.content)!! val composition = RedwoodComposition( scope = mainScope, container = ViewGroupChildren(root), provider = SchemaWidgetFactories( Counter = AndroidCounterWidgetFactory(this), RedwoodLayout = ViewRedwoodLayoutWidgetFactory(this), ), ) composition.setContent { Counter() }

Slide 88

Slide 88 text

Redwood Counter Sample

Slide 89

Slide 89 text

Redwood Counter Sample class ComposeUiText : Text<@Composable () -> Unit> { private var text by mutableStateOf("") override val value = @Composable { Text(text = text) } override fun text(text: String?) { this.text = text ?: "" } }

Slide 90

Slide 90 text

Redwood Counter Sample val factories = SchemaWidgetFactories( Counter = ComposeUiCounterWidgetFactory, RedwoodLayout = ComposeUiRedwoodLayoutWidgetFactory(), ) setContent { CounterTheme { RedwoodContent(factories) { Counter() } } }

Slide 91

Slide 91 text

Redwood Counter Sample val factories = SchemaWidgetFactories( Counter = ComposeUiCounterWidgetFactory, RedwoodLayout = ComposeUiRedwoodLayoutWidgetFactory(), ) setContent { CounterTheme { RedwoodContent(factories) { Counter() } } }

Slide 92

Slide 92 text

Redwood Counter Sample val factories = SchemaWidgetFactories( Counter = ComposeUiCounterWidgetFactory, RedwoodLayout = ComposeUiRedwoodLayoutWidgetFactory(), ) setContent { CounterTheme { RedwoodContent(factories) { Counter() } } }

Slide 93

Slide 93 text

Redwood Counter Sample

Slide 94

Slide 94 text

Redwood Counter Sample application { Window( onCloseRequest = ::exitApplication, title = "Counter", state = rememberWindowState(300.dp, 300.dp), ) { CounterTheme { RedwoodContent(factories) { Counter() } } } }

Slide 95

Slide 95 text

Redwood Counter Sample

Slide 96

Slide 96 text

Redwood Counter Sample class HtmlText( override val value: HTMLSpanElement, ) : Text { override fun text(text: String?) { value.textContent = text } }

Slide 97

Slide 97 text

Redwood Counter Sample

Slide 98

Slide 98 text

Redwood Counter Sample class IosText : Text { override val value = UILabel().apply { textAlignment = NSTextAlignmentCenter } override fun text(text: String?) { value.text = text } }

Slide 99

Slide 99 text

Redwood Counter Sample

Slide 100

Slide 100 text

Redwood Treehouse Zipline

Slide 101

Slide 101 text

Zipline 2016 2019 2022

Slide 102

Slide 102 text

No content

Slide 103

Slide 103 text

No content

Slide 104

Slide 104 text

No content

Slide 105

Slide 105 text

No content

Slide 106

Slide 106 text

American Red Cross Payment to $redcross

Slide 107

Slide 107 text

American Red Cross Payment to $redcross

Slide 108

Slide 108 text

American Red Cross Payment to $redcross Donation

Slide 109

Slide 109 text

American Red Cross Payment to $redcross Donation ~1 day

Slide 110

Slide 110 text

American Red Cross Payment to $redcross Donation ~1 day 3 - 7 days

Slide 111

Slide 111 text

American Red Cross Payment to $redcross Donation ~1 day 3 - 7 days 4 - 10 days

Slide 112

Slide 112 text

No content

Slide 113

Slide 113 text

No content

Slide 114

Slide 114 text

{"id":"Lgh13IUG7f6","amount":137,"currency":"USD","sender": {"id":"2q3u9bUG8f6","username":"jake","display_name":"Jake Wharton","is_non_profit":false},"recipient": {"id":"h98FUH87gwe","username":"redcross","display_name":"America n Red Cross","is_non_profit":true},"date":"2018-10-29T15:22:21"}

Slide 115

Slide 115 text

{"id":"Lgh13IUG7f6","amount":137,"currency":"USD","sender": {"id":"2q3u9bUG8f6","username":"jake","display_name":"Jake Wharton","is_non_profit":false},"recipient": {"id":"h98FUH87gwe","username":"redcross","display_name":"America n Red Cross","is_non_profit":true},"date":"2018-10-29T15:22:21"} {"payment_line_1":"American Red Cross","payment_line_2":"Donation to $redcross","payment_line_3":"$1.37","payment_line_4":"Oct 29, 2018 at 3:22PM"}

Slide 116

Slide 116 text

{"id":"Lgh13IUG7f6","amount":137,"currency":"USD","sender": {"id":"2q3u9bUG8f6","username":"jake","display_name":"Jake Wharton","is_non_profit":false},"recipient": {"id":"h98FUH87gwe","username":"redcross","display_name":"America n Red Cross","is_non_profit":true},"date":"2018-10-29T15:22:21"} {"payment_line_1":"American Red Cross","payment_line_2":"Donation to $redcross","payment_line_3":"$1.37","payment_line_4":"Oct 29, 2018 at 3:22PM"} if (payment.recipient.is_non_profit && payment.sender.is_florida_man) { return "Donation to %s" } return "Payment to %s

Slide 117

Slide 117 text

No content

Slide 118

Slide 118 text

No content

Slide 119

Slide 119 text

No content

Slide 120

Slide 120 text

No content

Slide 121

Slide 121 text

class PaymentRenderer { fun render(payment: Payment): String { … } } PaymentRenderer { fun render(payment: Payment): String { }

Slide 122

Slide 122 text

class RealPaymentRenderer : PaymentRenderer { override fun render(payment: Payment): String { … } } interface PaymentRenderer { fun render(payment: Payment): String }

Slide 123

Slide 123 text

class RealPaymentRenderer : PaymentRenderer { override fun render(payment: Payment): String { … } } interface PaymentRenderer : ZiplineService { fun render(payment: Payment): String }

Slide 124

Slide 124 text

class RealPaymentRenderer : PaymentRenderer { override fun render(payment: Payment): String { … } } interface PaymentRenderer : ZiplineService { fun render(payment: Payment): String }

Slide 125

Slide 125 text

class RealPaymentRenderer : PaymentRenderer { override fun render(payment: Payment): String { … } }

Slide 126

Slide 126 text

class RealPaymentRenderer : PaymentRenderer { override fun render(payment: Payment): String { … } } zipline.bind(RealPaymentRenderer())

Slide 127

Slide 127 text

class RealPaymentRenderer : PaymentRenderer { override fun render(payment: Payment): String { … } } zipline.bind(RealPaymentRenderer()) val renderer = zipline.take() println(renderer.render(Payment(…))

Slide 128

Slide 128 text

class RealPaymentRenderer : PaymentRenderer { override fun render(payment: Payment): String { /* Fancy new impl */ } } zipline.bind(RealPaymentRenderer()) val renderer = zipline.take() println(renderer.render(Payment(…))

Slide 129

Slide 129 text

zipline.bind(SystemLocationManager(…)) // Load Kotlin/JS val renderer = zipline.take() println(renderer.render(Payment(…)) class RealPaymentRenderer : PaymentRenderer { override fun render(payment: Payment): String { /* Fancy new impl */ } } zipline.bind(RealPaymentRenderer())

Slide 130

Slide 130 text

zipline.bind(SystemLocationManager(…)) // Load Kotlin/JS val renderer = zipline.take() println(renderer.render(Payment(…)) class RealPaymentRenderer( private val location: LocationManager, ) : PaymentRenderer { override fun render(payment: Payment): String { /* Fancy new impl */ } } val location = zipline.take() zipline.bind(RealPaymentRenderer(location))

Slide 131

Slide 131 text

interface SomeService : ZiplineService { fun sync(in: String): String }

Slide 132

Slide 132 text

interface SomeService : ZiplineService { fun sync(in: String): String suspend fun async(in: String): String }

Slide 133

Slide 133 text

interface SomeService : ZiplineService { fun sync(in: String): String suspend fun async(in: String): String fun stream(in: String): Flow }

Slide 134

Slide 134 text

interface SomeService : ZiplineService { fun sync(in: String): String suspend fun async(in: String): String fun stream(in: String): Flow fun stateStream(in: String): StateFlow }

Slide 135

Slide 135 text

interface SomeService : ZiplineService { fun sync(in: String): String suspend fun async(in: String): String fun stream(in: Flow): String fun stateStream(in: StateFlow): String }

Slide 136

Slide 136 text

interface SomeService : ZiplineService { fun sync(in: String): String suspend fun async(in: String): String fun stream(in: Flow): String fun stateStream(in: StateFlow): String fun userTypes(in: Payment): RenderedPayment }

Slide 137

Slide 137 text

interface SomeService : ZiplineService { … fun userTypes(in: Payment): RenderedPayment } f u n s y n c ( i n : S t r i n g ) : S t r i n g s u s p e n d f u n a s y n c ( i n : S t r i n g ) : S t r i n g f u n s t r e a m ( i n : F l o w < S t r i n g > ) : S t r i n g f u n s t a t e S t r e a m ( i n : S t a t e F l o w < S t r i n g > ) :S t r i n g

Slide 138

Slide 138 text

interface SomeService : ZiplineService { … fun userTypes(in: Payment): RenderedPayment internal object Adapter : ZiplineAdapter { } }

Slide 139

Slide 139 text

interface SomeService : ZiplineService { … fun userTypes(in: Payment): RenderedPayment internal object Adapter : ZiplineAdapter { override fun outboundService(handler: Handler) } }

Slide 140

Slide 140 text

interface SomeService : ZiplineService { … fun userTypes(in: Payment): RenderedPayment internal object Adapter : ZiplineAdapter { override fun outboundService(handler: Handler) = object : SomeService { override fun userTypes(in: Payment) = handler.call(this, in) as RenderedPayment } } }

Slide 141

Slide 141 text

interface SomeService : ZiplineService { … fun userTypes(in: Payment): RenderedPayment internal object Adapter : ZiplineAdapter { override fun outboundService(handler: Handler) = object : SomeService { override fun userTypes(in: Payment) = handler.call(this, in) as RenderedPayment } } }

Slide 142

Slide 142 text

interface SomeService : ZiplineService { … fun userTypes(in: Payment): RenderedPayment internal object Adapter : ZiplineAdapter { … } } @Serializable class RenderedPayment(…) @Serializable class Payment(…)

Slide 143

Slide 143 text

QuickJS function sayHello() { return ['Hello', 'JavaScript'] .join(' '); }

Slide 144

Slide 144 text

QuickJS function sayHello() { return ['Hello', 'JavaScript'] .join(' '); } hello.js:1: function: sayHello mode: strict stack_size: 3 opcodes: push_atom_value "Hello" push_atom_value "JavaScript" array_from 2 get_field2 join push_atom_value " " tail_call_method 1

Slide 145

Slide 145 text

QuickJS hello.js:1: function: sayHello mode: strict stack_size: 3 opcodes: push_atom_value "Hello" push_atom_value "JavaScript" array_from 2 get_field2 join push_atom_value " " tail_call_method 1 "Hello, JavaScript"

Slide 146

Slide 146 text

QuickJS hello.js:1: function: sayHello mode: strict stack_size: 3 opcodes: push_atom_value "Hello" push_atom_value "JavaScript" array_from 2 get_field2 join push_atom_value " " tail_call_method 1 function sayHello() { return ['Hello', 'JavaScript'] .join(' '); } "Hello, JavaScript" hello.js:1: function: sayHello mode: strict stack_size: 3 opcodes: push_atom_value "Hello" push_atom_value "JavaScript" array_from 2 get_field2 join push_atom_value " " tail_call_method 1

Slide 147

Slide 147 text

hello.js:1: function: sayHello mode: strict stack_size: 3 opcodes: push_atom_value "Hello" push_atom_value "JavaScript" array_from 2 get_field2 join push_atom_value " " tail_call_method 1 function sayHello() { return ['Hello', 'JavaScript'] .join(' '); } "Hello, JavaScript" hello.js:1: function: sayHello mode: strict stack_size: 3 opcodes: push_atom_value "Hello" push_atom_value "JavaScript" array_from 2 get_field2 join push_atom_value " " tail_call_method 1 Server: Client:

Slide 148

Slide 148 text

hello.js:1: function: sayHello mode: strict stack_size: 3 opcodes: push_atom_value "Hello" push_atom_value "JavaScript" array_from 2 get_field2 join push_atom_value " " tail_call_method 1 function sayHello() { return ['Hello', 'JavaScript'] .join(' '); } fun sayHello() { return arrayOf("Hello", "JavaScript") .asDynamic() .join(" ") }

Slide 149

Slide 149 text

hello.js:1: function: sayHello mode: strict stack_size: 3 opcodes: push_atom_value "Hello" push_atom_value "JavaScript" array_from 2 get_field2 join push_atom_value " " tail_call_method 1 function sayHello() { return ['Hello', 'JavaScript'] .join(' '); } fun sayHello() { return arrayOf("Hello", "JavaScript") .asDynamic() .join(" ") }

Slide 150

Slide 150 text

hello.js:1: function: sayHello mode: strict stack_size: 3 opcodes: push_atom_value "Hello" push_atom_value "JavaScript" array_from 2 get_field2 join push_atom_value " " tail_call_method 1 function sayHello() { return ['Hello', 'JavaScript'] .join(' '); } fun sayHello() { return arrayOf("Hello", "JavaScript") .asDynamic() .join(" ") } {"version":3,"sources": ["../../src/commonMain/ kotlin/com/example/ Hello.kt"],"sourcesCont ent":[null],,"names": [],"mappings":";IAsBE,g C;IAMA,wB;IAMA,4B;"}

Slide 151

Slide 151 text

hello.js:1: function: sayHello mode: strict stack_size: 3 opcodes: push_atom_value "Hello" push_atom_value "JavaScript" array_from 2 get_field2 join push_atom_value " " tail_call_method 1 function sayHello() { return ['Hello', 'JavaScript'] .join(' '); } fun sayHello() { return arrayOf("Hello", "JavaScript") .asDynamic() .join(" ") } {"version":3,"sources": ["../../src/commonMain/ kotlin/com/example/ Hello.kt"],"sourcesCont ent":[null],,"names": [],"mappings":";IAsBE,g C;IAMA,wB;IAMA,4B;"}

Slide 152

Slide 152 text

Hello.kt:1: function: sayHello mode: strict stack_size: 3 opcodes: push_atom_value "Hello" push_atom_value "JavaScript" array_from 2 get_field2 join push_atom_value " " tail_call_method 1 function sayHello() { return ['Hello', 'JavaScript'] .join(' '); } fun sayHello() { return arrayOf("Hello", "JavaScript") .asDynamic() .join(" ") } {"version":3,"sources": ["../../src/commonMain/ kotlin/com/example/ Hello.kt"],"sourcesCont ent":[null],,"names": [],"mappings":";IAsBE,g C;IAMA,wB;IAMA,4B;"}

Slide 153

Slide 153 text

Hello.kt:1: function: sayHello mode: strict stack_size: 3 opcodes: push_atom_value "Hello" push_atom_value "JavaScript" array_from 2 get_field2 join push_atom_value " " tail_call_method 1 function sayHello() { return ['Hello', 'JavaScript'] .join(' '); } fun sayHello() { return arrayOf("Hello", "JavaScript") .asDynamic() .join(" ") } {"version":3,"sources": ["../../src/commonMain/ kotlin/com/example/ Hello.kt"],"sourcesCont ent":[null],,"names": [],"mappings":";IAsBE,g C;IAMA,wB;IAMA,4B;"}

Slide 154

Slide 154 text

java.lang.Exception: unexpected timezone: America/Gotham at captureStack (runtime/coreRuntime.kt:86) at IllegalStateException_init (kotlin-kotlin-stdlib-js-ir.js) at (app.cash.worldclock/TimeFormatter.kt:98) at (app.cash.worldclock/WorldClockJs.kt:615) at (InboundService.kt:837) at (zipline-root-zipline.js) at app.cash.zipline.OutboundService.runJob(platform.kt:37) at app.cash.zipline.EventLoop.run(CoroutineEventLoop.kt:57) at j.u.concurrent.Executor.runWorker(ThreadPoolExecutor.java:1167) at j.u.concurrent.Executor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:920)

Slide 155

Slide 155 text

java.lang.Exception: unexpected timezone: America/Gotham at captureStack (runtime/coreRuntime.kt:86) at IllegalStateException_init (kotlin-kotlin-stdlib-js-ir.js) at (app.cash.worldclock/TimeFormatter.kt:98) at (app.cash.worldclock/WorldClockJs.kt:615) at (InboundService.kt:837) at (zipline-root-zipline.js) at app.cash.zipline.OutboundService.runJob(platform.kt:37) at app.cash.zipline.EventLoop.run(CoroutineEventLoop.kt:57) at j.u.concurrent.Executor.runWorker(ThreadPoolExecutor.java:1167) at j.u.concurrent.Executor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:920)

Slide 156

Slide 156 text

Zipline JavaScript VM

Slide 157

Slide 157 text

Zipline JavaScript VM 2015 - 2023 WASM VM Coming 2024

Slide 158

Slide 158 text

Redwood Zipline Treehouse

Slide 159

Slide 159 text

Treehouse val root = findViewById(android.R.id.content)!! val composition = RedwoodComposition( scope = mainScope, container = ViewGroupChildren(root), provider = SchemaWidgetFactories( Counter = AndroidCounterWidgetFactory(this), RedwoodLayout = ViewRedwoodLayoutWidgetFactory(this), ), ) composition.setContent { Counter() } Treehouse Counter Sample

Slide 160

Slide 160 text

Treehouse Counter Sample val root = findViewById(android.R.id.content)!! val composition = RedwoodComposition( scope = mainScope, container = ViewGroupChildren(root), provider = SchemaWidgetFactories( Counter = AndroidCounterWidgetFactory(this), RedwoodLayout = ViewRedwoodLayoutWidgetFactory(this), ), ) composition.setContent { Counter() }

Slide 161

Slide 161 text

Treehouse Counter Sample val root = findViewById(android.R.id.content)!! val composition = RedwoodComposition( scope = mainScope, container = ViewGroupChildren(root), provider = SchemaWidgetFactories( Counter = AndroidCounterWidgetFactory(this), RedwoodLayout = ViewRedwoodLayoutWidgetFactory(this), ), ) composition.setContent { Counter() }

Slide 162

Slide 162 text

Treehouse Counter Sample ) val root = findViewById(android.R.id.content)!! val composition = RedwoodComposition( scope = mainScope, container = ViewGroupChildren(root), provider = SchemaWidgetFactories( Counter = AndroidCounterWidgetFactory(this), RedwoodLayout = ViewRedwoodLayoutWidgetFactory(this), ), ) composition.setContent { Counter() } val = Redwood (

Slide 163

Slide 163 text

val composition = RedwoodComposition( scope = mainScope, ) composition.setContent { Counter() } val root = findViewById(android.R.id.content)!! val rendering = RedwoodRendering( container = ViewGroupChildren(root), provider = SchemaWidgetFactories( Counter = AndroidCounterWidgetFactory(this), RedwoodLayout = ViewRedwoodLayoutWidgetFactory(this), ), ) Presenter Compose Widgets Platform UI Zipline

Slide 164

Slide 164 text

val composition = RedwoodComposition( scope = mainScope, ) composition.setContent { Counter() } Widgets Zipline Presenter Platform UI Compose val root = findViewById(android.R.id.content)!! val container = ViewGroupChildren(root) val provider = SchemaWidgetFactories( Counter = AndroidCounterWidgetFactory(this), RedwoodLayout = ViewRedwoodLayoutWidgetFactory(this), ) val rendering = RedwoodRendering( container = container, provider = provider, )

Slide 165

Slide 165 text

val composition = RedwoodComposition( scope = mainScope, ) composition.setContent { Counter() } Widgets Zipline Presenter Platform UI Compose val root = findViewById(android.R.id.content)!! val container = ViewGroupChildren(root) val provider = SchemaWidgetFactories( Counter = AndroidCounterWidgetFactory(this), RedwoodLayout = ViewRedwoodLayoutWidgetFactory(this), ) val rendering = RedwoodRendering( container = container, provider = provider, )

Slide 166

Slide 166 text

val composition = RedwoodComposition( scope = mainScope, ) composition.setContent { Counter() } Widgets Zipline Presenter Platform UI Compose val root = findViewById(android.R.id.content)!! val container = ViewGroupChildren(root) val provider = SchemaWidgetFactories( Counter = AndroidCounterWidgetFactory(this), RedwoodLayout = ViewRedwoodLayoutWidgetFactory(this), ) val rendering = RedwoodRendering( container = container, provider = provider, )

Slide 167

Slide 167 text

val composition = RedwoodComposition( scope = mainScope, ) composition.setContent { Counter() } Widgets kotlinx serialization Zipline Presenter Platform UI Compose kotlinx serialization val root = findViewById(android.R.id.content)!! val container = ViewGroupChildren(root) val provider = SchemaWidgetFactories( Counter = AndroidCounterWidgetFactory(this), RedwoodLayout = ViewRedwoodLayoutWidgetFactory(this), ) val rendering = RedwoodRendering( container = container, provider = provider, )

Slide 168

Slide 168 text

Schema Widgets Compose

Slide 169

Slide 169 text

Schema Widgets Compose Compose Protocol Widget Protocol

Slide 170

Slide 170 text

Widgets Widget Protocol Zipline Presenter Platform UI Compose Compose Protocol

Slide 171

Slide 171 text

Widgets Widget Protocol Zipline Platform UI

Slide 172

Slide 172 text

Widgets Widget Protocol Zipline Platform UI Presenter Compose Compose Protocol

Slide 173

Slide 173 text

Redwood Protocol data class Column( val children: () -> Unit, ) data class TextInput( val hint: String, val text: String, val onTextChanged: (String) -> Unit, )

Slide 174

Slide 174 text

Redwood Protocol @Widget(1) data class Column( val children: () -> Unit, ) @Widget(2) data class TextInput( val hint: String, val text: String, val onTextChanged: (String) -> Unit, )

Slide 175

Slide 175 text

Redwood Protocol @Widget(1) data class Column( val children: () -> Unit, ) @Widget(2) data class TextInput( @Property(1) val hint: String, @Property(2) val text: String, @Property(3) val onTextChanged: (String) -> Unit, )

Slide 176

Slide 176 text

Redwood Protocol @Widget(1) data class Column( @Children(1) val children: () -> Unit, ) @Widget(2) data class TextInput( @Property(1) val hint: String, @Property(2) val text: String, @Property(3) val onTextChanged: (String) -> Unit, )

Slide 177

Slide 177 text

Widgets Widget Protocol Zipline Platform UI Presenter Compose Compose Protocol

Slide 178

Slide 178 text

Treehouse Widgets Widget Protocol Zipline Platform UI Presenter Compose Compose Protocol

Slide 179

Slide 179 text

Treehouse Demo

Slide 180

Slide 180 text

No content

Slide 181

Slide 181 text

Treehouse Demo

Slide 182

Slide 182 text

Redwood Zipline Treehouse

Slide 183

Slide 183 text

deviceframes.com

Slide 184

Slide 184 text

.com/cashapp/zipline .com/cashapp/redwood

Slide 185

Slide 185 text

@[email protected] Playing in the Treehouse with Redwood and Zipline