Skip to content

Commit

Permalink
Rename method to make it clear
Browse files Browse the repository at this point in the history
Summary: rename few functions as they are just callbacks to react on events.

Reviewed By: fabiocarballo

Differential Revision: D51756466

fbshipit-source-id: 46b3c4f139b6d844c2c0d2b872ee4dcd651bc9af
  • Loading branch information
Peng Jiang authored and facebook-github-bot committed Dec 4, 2023
1 parent 9aa0328 commit bd31a1e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Version 0.49.0-SNAPSHOT

* [BREAKING] Removed `Component.canResolve()` and `Component.resolve(ResolveContext, ComponentContext)` methods. All classes extending Component must now implement the new `Component.resolve(ResolveContext, ScopedComponentInfo, int, int, ComponentsLogger)` method which is always used in the resolution flow.
* [BREAKING] Rename `Style.performAccessibilityAction`, `Style.sendAccessibilityEvent` and `Style.sendAccessibilityEventUnchecked` methods.

For more details, see the [full diff](https://github.com/facebook/litho/compare/v0.48.0...master).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,29 +202,29 @@ inline fun Style.onRequestSendAccessibilityEvent(
onRequestSendAccessibilityEventHandler)

/**
* Performs the specified accessibility action on the view.
* Called when performs the specified accessibility action on the view.
*
* See [android.view.View.AccessibilityDelegateCompat#performAccessibilityAction].
*/
inline fun Style.performAccessibilityAction(
noinline performAccessibilityActionHandler: (PerformAccessibilityActionEvent) -> Unit
inline fun Style.onPerformAccessibilityAction(
noinline onPerformAccessibilityActionHandler: (PerformAccessibilityActionEvent) -> Unit
): Style =
this +
AccessibilityStyleItem(
AccessibilityField.PERFORM_ACCESSIBILITY_ACTION, performAccessibilityActionHandler)
AccessibilityField.PERFORM_ACCESSIBILITY_ACTION, onPerformAccessibilityActionHandler)

/**
* Sends an accessibility event of the given type. If accessibility is not enabled this method has
* no effect.
* Called when Sends an accessibility event of the given type. If accessibility is not enabled this
* method has no effect.
*
* See [android.view.View.AccessibilityDelegateCompat#sendAccessibilityEvent].
*/
inline fun Style.sendAccessibilityEvent(
noinline sendAccessibilityEventHandler: (SendAccessibilityEventEvent) -> Unit
inline fun Style.onSendAccessibilityEvent(
noinline onSendAccessibilityEventHandler: (SendAccessibilityEventEvent) -> Unit
): Style =
this +
AccessibilityStyleItem(
AccessibilityField.SEND_ACCESSIBILITY_EVENT, sendAccessibilityEventHandler)
AccessibilityField.SEND_ACCESSIBILITY_EVENT, onSendAccessibilityEventHandler)

/**
* Sends an accessibility event. This method behaves exactly as sendAccessibilityEvent() but takes
Expand All @@ -233,13 +233,14 @@ inline fun Style.sendAccessibilityEvent(
*
* See [android.view.View.AccessibilityDelegateCompat#sendAccessibilityEventUnchecked].
*/
inline fun Style.sendAccessibilityEventUnchecked(
noinline sendAccessibilityEventUncheckedHandler: (SendAccessibilityEventUncheckedEvent) -> Unit
inline fun Style.onSendAccessibilityEventUnchecked(
noinline onSendAccessibilityEventUncheckedHandler:
(SendAccessibilityEventUncheckedEvent) -> Unit
): Style =
this +
AccessibilityStyleItem(
AccessibilityField.SEND_ACCESSIBILITY_EVENT_UNCHECKED,
sendAccessibilityEventUncheckedHandler)
onSendAccessibilityEventUncheckedHandler)

/**
* Initializes an [AccessibilityNodeInfoCompat] with information about the host view.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,12 @@ class AccessibilityStylesTest {

/** See comment on [onInitializeAccessibilityNodeInfo_whenNotSet_isNotSetOnView] above. */
@Test
fun performAccessibilityAction_whenSet_isSetOnView() {
fun onPerformAccessibilityAction_whenSet_isSetOnView() {
val eventHandler: EventHandler<PerformAccessibilityActionEvent> = mock()

class TestComponentWithHandler : KComponent() {
override fun ComponentScope.render(): Component? {
return Row(style = Style.performAccessibilityAction { eventHandler })
return Row(style = Style.onPerformAccessibilityAction { eventHandler })
}
}
val testLithoView = lithoViewRule.render { TestComponentWithHandler() }
Expand All @@ -268,7 +268,7 @@ class AccessibilityStylesTest {

/** See comment on [onInitializeAccessibilityNodeInfo_whenNotSet_isNotSetOnView] above. */
@Test
fun sendAccessibilityEvent_whenNotSet_isNotSetOnView() {
fun onSendAccessibilityEvent_whenNotSet_isNotSetOnView() {
class TestComponent : KComponent() {
override fun ComponentScope.render(): Component? {
return Row(style = Style.width(200.px))
Expand All @@ -282,12 +282,12 @@ class AccessibilityStylesTest {

/** See comment on [onInitializeAccessibilityNodeInfo_whenNotSet_isNotSetOnView] above. */
@Test
fun sendAccessibilityEvent_whenSet_isSetOnView() {
fun onSendAccessibilityEvent_whenSet_isSetOnView() {
val eventHandler: EventHandler<SendAccessibilityEventEvent> = mock()

class TestComponentWithHandler : KComponent() {
override fun ComponentScope.render(): Component? {
return Row(style = Style.sendAccessibilityEvent { eventHandler })
return Row(style = Style.onSendAccessibilityEvent { eventHandler })
}
}
val testLithoView = lithoViewRule.render { TestComponentWithHandler() }
Expand All @@ -298,7 +298,7 @@ class AccessibilityStylesTest {

/** See comment on [onInitializeAccessibilityNodeInfo_whenNotSet_isNotSetOnView] above. */
@Test
fun sendAccessibilityEventUnchecked_whenNotSet_isNotSetOnView() {
fun onSendAccessibilityEventUnchecked_whenNotSet_isNotSetOnView() {
class TestComponent : KComponent() {
override fun ComponentScope.render(): Component? {
return Row(style = Style.width(200.px))
Expand All @@ -312,12 +312,12 @@ class AccessibilityStylesTest {

/** See comment on [onInitializeAccessibilityNodeInfo_whenNotSet_isNotSetOnView] above. */
@Test
fun sendAccessibilityEventUnchecked_whenSet_isSetOnView() {
fun onSendAccessibilityEventUnchecked_whenSet_isSetOnView() {
val eventHandler: EventHandler<SendAccessibilityEventUncheckedEvent> = mock()

class TestComponentWithHandler : KComponent() {
override fun ComponentScope.render(): Component? {
return Row(style = Style.sendAccessibilityEventUnchecked { eventHandler })
return Row(style = Style.onSendAccessibilityEventUnchecked { eventHandler })
}
}
val testLithoView = lithoViewRule.render { TestComponentWithHandler() }
Expand Down

0 comments on commit bd31a1e

Please sign in to comment.