|
20 | 20 | import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
|
21 | 21 | import com.facebook.react.bridge.ReadableArray;
|
22 | 22 | import com.facebook.react.bridge.ReadableMap;
|
| 23 | +import com.facebook.react.config.ReactFeatureFlags; |
23 | 24 | import com.facebook.react.uimanager.IllegalViewOperationException;
|
24 | 25 | import com.facebook.react.uimanager.LayoutShadowNode;
|
25 | 26 | import com.facebook.react.uimanager.NativeViewHierarchyOptimizer;
|
@@ -136,12 +137,23 @@ private static void buildSpannedFromShadowNode(
|
136 | 137 | YogaValue widthValue = child.getStyleWidth();
|
137 | 138 | YogaValue heightValue = child.getStyleHeight();
|
138 | 139 |
|
| 140 | + float width; |
| 141 | + float height; |
139 | 142 | if (widthValue.unit != YogaUnit.POINT || heightValue.unit != YogaUnit.POINT) {
|
140 |
| - throw new IllegalViewOperationException( |
141 |
| - "Views nested within a <Text> must have a width and height"); |
| 143 | + if (ReactFeatureFlags.supportInlineViewsWithDynamicSize) { |
| 144 | + // If the measurement of the child isn't calculated, we calculate the layout for the |
| 145 | + // view using Yoga |
| 146 | + child.calculateLayout(); |
| 147 | + width = child.getLayoutWidth(); |
| 148 | + height = child.getLayoutHeight(); |
| 149 | + } else { |
| 150 | + throw new IllegalViewOperationException( |
| 151 | + "Views nested within a <Text> must have a width and height"); |
| 152 | + } |
| 153 | + } else { |
| 154 | + width = widthValue.value; |
| 155 | + height = heightValue.value; |
142 | 156 | }
|
143 |
| - float width = widthValue.value; |
144 |
| - float height = heightValue.value; |
145 | 157 |
|
146 | 158 | // We make the inline view take up 1 character in the span and put a corresponding character
|
147 | 159 | // into
|
@@ -360,9 +372,7 @@ protected Spannable spannedFromShadowNode(
|
360 | 372 | */
|
361 | 373 | protected @Nullable String mFontFamily = null;
|
362 | 374 |
|
363 |
| - /** |
364 |
| - * @see android.graphics.Paint#setFontFeatureSettings |
365 |
| - */ |
| 375 | + /** @see android.graphics.Paint#setFontFeatureSettings */ |
366 | 376 | protected @Nullable String mFontFeatureSettings = null;
|
367 | 377 |
|
368 | 378 | protected boolean mContainsImages = false;
|
|
0 commit comments