CREATE LAYOUTSTATE
Measure with Yoga
Collect a list of items to be
drawn and their positions
Row
Image
Column
Text Text
(0, 0 - 640, 96)
(88, 0 - 640, 96)
(16, 16 - 80, 80)
(88, 16 - 624, 48) (88, 48 - 624, 80)
Root Text
Image
Row
Image
Column
Text Text
(0, 0 - 640, 96)
(88, 0 - 640, 96)
(16, 16 - 80, 80)
(88, 16 - 624, 48) (88, 48 - 624, 80)
Text
Slide 79
Slide 79 text
Root Text
Image
Row
Image
Column
Text Text
(0, 0 - 640, 96)
(88, 0 - 640, 96)
(16, 16 - 80, 80)
(88, 16 - 624, 48) (88, 48 - 624, 80)
Text
LayoutState
Slide 80
Slide 80 text
Root Text
Image
Row
Image
Column
Text Text
(0, 0 - 640, 96)
(88, 0 - 640, 96)
(16, 16 - 80, 80)
(88, 16 - 624, 48) (88, 48 - 624, 80)
Text
Im
ageDraw
able
TextDraw
able
TextDraw
able
LayoutState
Slide 81
Slide 81 text
MOUNT LAYOUTSTATE
Root Text
Image Text
Im
ageDraw
able
TextDraw
able
TextDraw
able
LayoutState
Slide 82
Slide 82 text
MOUNT LAYOUTSTATE
The only step that always
happens on UI thread
Root Text
Image Text
Im
ageDraw
able
TextDraw
able
TextDraw
able
LayoutState
Slide 83
Slide 83 text
MOUNT LAYOUTSTATE
The only step that always
happens on UI thread
Text
Image
Text
Root Text
Image Text
Im
ageDraw
able
TextDraw
able
TextDraw
able
LayoutState
Slide 84
Slide 84 text
MOUNT LAYOUTSTATE
The only step that always
happens on UI thread
Text
Image
Text
Root Text
Image Text
Im
ageDraw
able
TextDraw
able
TextDraw
able
LayoutState
Slide 85
Slide 85 text
BUILDING BLOCKS
Slide 86
Slide 86 text
BUILDING BLOCKS
✦ @LayoutSpec
Slide 87
Slide 87 text
BUILDING BLOCKS
✦ @LayoutSpec
ListItemWithImage
ListItem
Slide 88
Slide 88 text
BUILDING BLOCKS
✦ @LayoutSpec
✦ Row / Column
Slide 89
Slide 89 text
BUILDING BLOCKS
✦ @LayoutSpec
✦ Row / Column
Row
Column
Slide 90
Slide 90 text
BUILDING BLOCKS
Image
Text Text
✦ @LayoutSpec
✦ Row / Column
Slide 91
Slide 91 text
BUILDING BLOCKS
✦ @LayoutSpec
✦ Row / Column
✦ Image
Text Text
...?
✦ @LayoutSpec
✦ Row / Column
Slide 92
Slide 92 text
BUILDING BLOCKS
✦ @LayoutSpec
✦ Row / Column
✦ Image
Text Text
✦ @MountSpec
✦ @LayoutSpec
✦ Row / Column
ANIMATIONS
onCreateTransition is called on every onCreateLayout
Slide 161
Slide 161 text
ANIMATIONS
onCreateTransition is called on every onCreateLayout
Even if you don't need to animate that specific UI update
Slide 162
Slide 162 text
ANIMATIONS
onCreateTransition is called on every onCreateLayout
Even if you don't need to animate that specific UI update
More granular control?
Slide 163
Slide 163 text
@OnCreateTransition
fun onCreateTransition(c: ComponentContext): Transition {
return Transition.allLayout()
}
Slide 164
Slide 164 text
@OnCreateTransition
fun onCreateTransition(c: ComponentContext,
@Prop prop: Diff,
@State state: Diff): Transition? {
return if (canAnimate(prop, state)) Transition.allLayout() else null
}
Slide 165
Slide 165 text
@OnCreateTransition
fun onCreateTransition(c: ComponentContext,
@Prop prop: Diff,
@State state: Diff): Transition? {
return if (canAnimate(prop, state)) Transition.allLayout() else null
}
Slide 166
Slide 166 text
@OnCreateTransition
fun onCreateTransition(c: ComponentContext,
@Prop prop: Diff,
@State state: Diff): Transition? {
return if (canAnimate(prop, state)) Transition.allLayout() else null
}
public final class Diff {
public T getPrevious()
public T getNext()
}
Slide 167
Slide 167 text
GOTCHAS
Slide 168
Slide 168 text
GOTCHAS
Use Diff for more granular control over transitions
Slide 169
Slide 169 text
GRADUAL ADOPTION
Slide 170
Slide 170 text
GRADUAL ADOPTION
Slide 171
Slide 171 text
GRADUAL ADOPTION
Can't migrate the whole screen at once? Do step by step:
Slide 172
Slide 172 text
GRADUAL ADOPTION
Can't migrate the whole screen at once? Do step by step:
• Complex UI parts can be replaced with a LithoView and
underlying Component structure
Slide 173
Slide 173 text
GRADUAL ADOPTION
Can't migrate the whole screen at once? Do step by step:
• Complex UI parts can be replaced with a LithoView and
underlying Component structure
• Custom Views can be wrapped in MountSpecs