-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port "setAndroidLayoutDirection" to Paper (#45422)
Summary: Pull Request resolved: #45422 When `ReactNativeFeatureFlags.setAndroidLayoutDirection()` is set, we assume in components like ReactHorizontalScrolView that the Yoga contextual layout direction has been set on the underlying component, and skip using I18nManager global direction. These native views are also used in Paper, so we need to make the change there as well to avoid regressions. This change mechanically ports the change from Fabric to Paper, at the same layer as used in Fabric (applying ShadowNode layout to the Android view tree). Changelog: [Internal] Reviewed By: rshest Differential Revision: D59708408 fbshipit-source-id: 52d6fa80c102250eae7ccccedd7184569f6a727f
- Loading branch information
1 parent
26df440
commit 1292480
Showing
6 changed files
with
85 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...act-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/LayoutDirectionUtil.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
package com.facebook.react.uimanager | ||
|
||
import android.view.View | ||
import com.facebook.yoga.YogaDirection | ||
|
||
internal object LayoutDirectionUtil { | ||
@JvmStatic | ||
public fun toAndroidFromYoga(direction: YogaDirection): Int = | ||
when (direction) { | ||
YogaDirection.LTR -> View.LAYOUT_DIRECTION_LTR | ||
YogaDirection.RTL -> View.LAYOUT_DIRECTION_RTL | ||
else -> View.LAYOUT_DIRECTION_INHERIT | ||
} | ||
|
||
@JvmStatic | ||
public fun toYogaFromAndroid(direction: Int): YogaDirection = | ||
when (direction) { | ||
View.LAYOUT_DIRECTION_LTR -> YogaDirection.LTR | ||
View.LAYOUT_DIRECTION_RTL -> YogaDirection.RTL | ||
else -> YogaDirection.INHERIT | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters