mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Allow null as default value for float props
Summary:
Some props must have their default values set by native. To be able to support this, we have to introduce a null as a supported default value for some types. In this diff I'm adding support for null default values for float props. An example of this to be useful is `ReactDrawerLayoutManager`:
```
Override
public void setDrawerWidth(ReactDrawerLayout view, Nullable Float width) {
int widthInPx =
width == null
? LayoutParams.MATCH_PARENT
: Math.round(PixelUtil.toPixelFromDIP(width));
view.setDrawerWidth(widthInPx);
}
```
We need to be able to generate an interface method, that accepts a boxed `Float` value instead of the primitive `float` so that the native code can decide what value to use by default (`LayoutParams.MATCH_PARENT` in this case).
Reviewed By: rickhanlonii
Differential Revision: D17343172
fbshipit-source-id: 7662a4e0e495f58d05a92892f063535a359d09ae
This commit is contained in:
1 parent
2e7545cf7e
commit
92f3b4a27f
11 files changed
+46
-19
No files matched your search
+4
@@ -1,6 +1,7 @@
|
||||
package com.facebook.react.uimanager;
|
||||
|
||||
import android.view.ViewGroup;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.react.viewmanagers.FloatPropsNativeComponentViewManagerDelegate;
|
||||
import com.facebook.react.viewmanagers.FloatPropsNativeComponentViewManagerInterface;
|
||||
|
||||
@@ -41,4 +42,7 @@ public class FloatPropsNativeComponentViewManager extends SimpleViewManager<View
|
||||
|
||||
@Override
|
||||
public void setBlurRadius6(ViewGroup view, float value) {}
|
||||
|
||||
@Override
|
||||
public void setBlurRadiusNullable(ViewGroup view, @Nullable Float value) {}
|
||||
}
|
||||
Reference in new issue
Block a user