Skip to content

Commit 2e0182e

Browse files
Haseeb Saeedfacebook-github-bot
authored andcommitted
Convert SavedReplyGlyphComponentSpec to KComponent
Summary: ## This Diff This diff converts `SavedReplyGlyphComponentSpec` to KComponent and updates both the MTV and UTV usages (although UTV code will eventually be deleted). Note: I had to make some changes to core Litho code for this diff. The `StyleCompat` (to be used in Java code) object does not expose a method for setting touch expansion while `Style` (to be used in Kotlin code) does. I added a method to `StyleCompat` to allow us to set this in Java-land, following the example of similar props (e.g. margin). Differential Revision: D67408743 fbshipit-source-id: eeef53e85cb1a14cbce81d5545d879ad9fd91f94
1 parent 7fa45cd commit 2e0182e

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

litho-core/src/main/java/com/facebook/litho/StyleCompat.kt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import com.facebook.litho.view.onClick
4545
import com.facebook.litho.view.onLongClick
4646
import com.facebook.litho.view.onTouch
4747
import com.facebook.litho.view.testKey
48+
import com.facebook.litho.view.touchExpansion
4849
import com.facebook.litho.view.wrapInView
4950
import com.facebook.rendercore.dp
5051
import com.facebook.rendercore.px
@@ -218,6 +219,11 @@ object StyleCompat {
218219

219220
/** @see [JavaStyle.onClick] */
220221
@JvmStatic fun onClick(action: (ClickEvent) -> Unit): JavaStyle = JavaStyle().onClick(action)
222+
223+
/** @see [JavaStyle.touchExpansionDip] */
224+
@JvmStatic
225+
fun touchExpansionDip(yogaEdge: YogaEdge, value: Float): JavaStyle =
226+
JavaStyle().touchExpansionDip(yogaEdge, value)
221227
}
222228

223229
class JavaStyle {
@@ -496,6 +502,23 @@ class JavaStyle {
496502
return this
497503
}
498504

505+
fun touchExpansionDip(yogaEdge: YogaEdge, value: Float): JavaStyle {
506+
val valueDip = value.dp
507+
style =
508+
when (yogaEdge) {
509+
YogaEdge.LEFT -> style.touchExpansion(left = valueDip)
510+
YogaEdge.VERTICAL -> style.touchExpansion(vertical = valueDip)
511+
YogaEdge.TOP -> style.touchExpansion(top = valueDip)
512+
YogaEdge.RIGHT -> style.touchExpansion(right = valueDip)
513+
YogaEdge.BOTTOM -> style.touchExpansion(bottom = valueDip)
514+
YogaEdge.START -> style.touchExpansion(start = valueDip)
515+
YogaEdge.END -> style.touchExpansion(end = valueDip)
516+
YogaEdge.HORIZONTAL -> style.touchExpansion(horizontal = valueDip)
517+
YogaEdge.ALL -> style.touchExpansion(all = valueDip)
518+
}
519+
return this
520+
}
521+
499522
fun build(): Style {
500523
return style
501524
}

0 commit comments

Comments
 (0)