mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
92f3b4a27f
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
49 lines
1.4 KiB
Java
49 lines
1.4 KiB
Java
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;
|
|
|
|
public class FloatPropsNativeComponentViewManager extends SimpleViewManager<ViewGroup>
|
|
implements FloatPropsNativeComponentViewManagerInterface<ViewGroup> {
|
|
|
|
public static final String REACT_CLASS = "FloatPropsNativeComponentView";
|
|
|
|
@Override
|
|
public String getName() {
|
|
return REACT_CLASS;
|
|
}
|
|
|
|
private void test() {
|
|
FloatPropsNativeComponentViewManagerDelegate<ViewGroup, FloatPropsNativeComponentViewManager>
|
|
delegate = new FloatPropsNativeComponentViewManagerDelegate<>(this);
|
|
}
|
|
|
|
@Override
|
|
public ViewGroup createViewInstance(ThemedReactContext context) {
|
|
throw new IllegalStateException();
|
|
}
|
|
|
|
@Override
|
|
public void setBlurRadius(ViewGroup view, float value) {}
|
|
|
|
@Override
|
|
public void setBlurRadius2(ViewGroup view, float value) {}
|
|
|
|
@Override
|
|
public void setBlurRadius3(ViewGroup view, float value) {}
|
|
|
|
@Override
|
|
public void setBlurRadius4(ViewGroup view, float value) {}
|
|
|
|
@Override
|
|
public void setBlurRadius5(ViewGroup view, float value) {}
|
|
|
|
@Override
|
|
public void setBlurRadius6(ViewGroup view, float value) {}
|
|
|
|
@Override
|
|
public void setBlurRadiusNullable(ViewGroup view, @Nullable Float value) {}
|
|
}
|