mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Pass surface ID to measure function in Java to retrieve themed Context
Summary: We use `ViewManager.onMeasure` to perform measurements of Android views and pass the measured size back to Yoga. For Android in order to the report correct dimensions of a View, this View must be created using a Context that has a theme associated with it. Before, `onMeasure` only had ReactApplicationContext passed as the first parameter and ReactSwitch, for example, could not be measured correctly (because it uses the size of the thumb drawable, which is extracted from the current theme). This diff adds surfaceId as the first parameter of `FabricUIManager.measure`, so that we can retrieve ThemedReactContext and pass it to `ViewManager.onMeasure`. The size of the Switch component is still incorrect, but at least the size reported back to Yoga is the same as in Paper. So there is more investigation necessary why this happens in Fabric. I will investigate and publish another diff with the fix. Reviewed By: JoshuaGross, shergin Differential Revision: D17625959 fbshipit-source-id: 48197a61240fb13042bef3e9f5d681acacc702fb
This commit is contained in:
committed by
Facebook Github Bot
parent
d0dd1aed29
commit
299c984964
@@ -333,6 +333,7 @@ public class FabricUIManager implements UIManager, LifecycleEventListener {
|
||||
@DoNotStrip
|
||||
@SuppressWarnings("unused")
|
||||
private long measure(
|
||||
int rootTag,
|
||||
String componentName,
|
||||
ReadableMap localData,
|
||||
ReadableMap props,
|
||||
@@ -341,7 +342,29 @@ public class FabricUIManager implements UIManager, LifecycleEventListener {
|
||||
float maxWidth,
|
||||
float minHeight,
|
||||
float maxHeight) {
|
||||
return mMountingManager.measure(
|
||||
mReactContextForRootTag.get(rootTag),
|
||||
componentName,
|
||||
localData,
|
||||
props,
|
||||
state,
|
||||
getYogaSize(minWidth, maxWidth),
|
||||
getYogaMeasureMode(minWidth, maxWidth),
|
||||
getYogaSize(minHeight, maxHeight),
|
||||
getYogaMeasureMode(minHeight, maxHeight));
|
||||
}
|
||||
|
||||
@DoNotStrip
|
||||
@SuppressWarnings("unused")
|
||||
private long measure(
|
||||
String componentName,
|
||||
ReadableMap localData,
|
||||
ReadableMap props,
|
||||
ReadableMap state,
|
||||
float minWidth,
|
||||
float maxWidth,
|
||||
float minHeight,
|
||||
float maxHeight) {
|
||||
return mMountingManager.measure(
|
||||
mReactApplicationContext,
|
||||
componentName,
|
||||
|
||||
Reference in New Issue
Block a user