Add setNativeValue command to ReactSwitchManager

Summary: Fabric doesn't support setNativeProps, so we have to use commands instead to set the value of the native component.

Reviewed By: JoshuaGross

Differential Revision: D17736274

fbshipit-source-id: 18c47365926c3c2cfc3551f4b5b6cc72e4162367
This commit is contained in:
Oleksandr Melnykov
2019-10-07 03:52:32 -07:00
committed by Facebook Github Bot
parent 6166645560
commit 3560093115
4 changed files with 54 additions and 7 deletions
@@ -11,6 +11,7 @@ package com.facebook.react.viewmanagers;
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.BaseViewManagerInterface;
import com.facebook.react.uimanager.LayoutShadowNode;
@@ -53,4 +54,12 @@ public class AndroidSwitchManagerDelegate<T extends View, U extends BaseViewMana
super.setProperty(view, propName, value);
}
}
public void receiveCommand(AndroidSwitchManagerInterface<T> viewManager, T view, String commandName, ReadableArray args) {
switch (commandName) {
case "setNativeValue":
viewManager.setNativeValue(view, args.getBoolean(0));
break;
}
}
}