Transition won't work on SolidColor component
- Dominant language
- Kotlin
- Stars
- 7.8k
- Forks
- 768
- PR merge metrics
- No merged PRs in 30d
Description
Transitions isn't working on SolidColor but it works fine in other components such Row, Column, Text, etc.
I'm not sure if it was an intended behaviour. The following might be helpful
Version:
// Litho
implementation 'com.facebook.litho:litho-core:0.29.0'
implementation 'com.facebook.litho:litho-widget:0.29.0'
kapt 'com.facebook.litho:litho-processor:0.29.0'
// SoLoader
implementation 'com.facebook.soloader:soloader:0.6.0'
// For integration with Fresco
implementation 'com.facebook.litho:litho-fresco:0.29.0'
// Sections
implementation 'com.facebook.litho:litho-sections-core:0.29.0'
implementation 'com.facebook.litho:litho-sections-widget:0.29.0'
compileOnly 'com.facebook.litho:litho-sections-annotations:0.29.0'
kapt 'com.facebook.litho:litho-sections-processor:0.29.0'
@LayoutSpec
object UIExpScaleAnimSpec {
@OnCreateInitialState
fun onCrateInitialState(c: ComponentContext,
scale: StateValue
) {
scale.set(1f)
}
@OnCreateLayout
fun onCreateLayout(c: ComponentContext,
@State scale: Float
): Component {
/* return Column.create(c)
.heightPercent(100f)
.child(Column.create(c)
.transitionKey("anim")
.widthDip(scale)
.heightDip(scale)
.backgroundColor(Color.parseColor("#7B241C"))
.build())
.clickHandler(UIExpScaleAnim.onPageClicked(c, scale))
.build()*/
return Column.create(c)
.heightPercent(100f)
.child(SolidColor.create(c)
.transitionKey("anim")
.widthDip(scale)
.heightDip(scale)
.color(Color.parseColor("#7B241C"))
.build())
.clickHandler(UIExpScaleAnim.onPageClicked(c, scale))
.build()
}
@OnCreateTransition
fun onCreateTransition(c: ComponentContext
): Transition {
return Transition.create("anim")
.animate(AnimatedProperties.WIDTH, AnimatedProperties.HEIGHT)
}
@OnUpdateState
fun updateScale(@Param param: Float, scale: StateValue) {
scale.set(param)
}
@OnEvent(ClickEvent::class)
fun onPageClicked(c: ComponentContext,
@Param pCurrentScale: Float
) {
UIExpScaleAnim.updateScale(c, if (pCurrentScale == 1f) 100f else 1f)
}
}
Contributor guide
Assessment
This issue has not been assessed yet.