Fix commands with no args

Summary: Fixing a typo

Reviewed By: JoshuaGross

Differential Revision: D16434634

fbshipit-source-id: 72a6b698bcd0ba9c10dfbdf264011e0a31ea06b6
This commit is contained in:
Eli White
2019-07-24 12:45:16 -07:00
committed by Facebook Github Bot
parent 4eca2e226c
commit fbd5dee1e4
6 changed files with 30 additions and 12 deletions
@@ -129,15 +129,14 @@ function getCommandArgJavaType(param) {
}
function getCommandArguments(command: CommandTypeShape): string {
const commandArgs = command.typeAnnotation.params
.map((param, index) => {
return [
'view',
...command.typeAnnotation.params.map((param, index) => {
const commandArgJavaType = getCommandArgJavaType(param);
return `args.${commandArgJavaType}(${index})`;
})
.join(', ');
return `view, ${commandArgs}`;
}),
].join(', ');
}
function generateCommandCasesString(
@@ -107,15 +107,14 @@ function getCommandArguments(
command: CommandTypeShape,
componentName: string,
): string {
const commandArgs = command.typeAnnotation.params
.map(param => {
return [
'T view',
...command.typeAnnotation.params.map(param => {
const commandArgJavaType = getCommandArgJavaType(param);
return `${commandArgJavaType} ${param.name}`;
})
.join(', ');
return `T view, ${commandArgs}`;
}),
].join(', ');
}
function generateCommandsString(
@@ -921,6 +921,14 @@ const COMMANDS: SchemaType = {
events: [],
props: [],
commands: [
{
name: 'flashScrollIndicators',
optional: false,
typeAnnotation: {
type: 'FunctionTypeAnnotation',
params: [],
},
},
{
name: 'hotspotUpdate',
optional: false,
@@ -96,6 +96,9 @@ public class CommandNativeComponentViewManagerDelegate<T extends View> {
}
public void receiveCommand(CommandNativeComponentInterface<T> viewManager, T view, String commandName, ReadableArray args) {
case \\"flashScrollIndicators\\":
viewManager.flashScrollIndicators(view);
break;
case \\"hotspotUpdate\\":
viewManager.hotspotUpdate(view, args.getInt(0), args.getInt(1));
break;
@@ -61,6 +61,7 @@ import android.view.View;
public interface CommandNativeComponentViewManagerInterface<T extends View> {
// No props
void flashScrollIndicators(T view);
void hotspotUpdate(T view, int x, int y);
void scrollTo(T view, int y, boolean animated);
}
@@ -144,6 +144,14 @@ export const __INTERNAL_VIEW_CONFIG = CommandNativeComponentViewConfig;
export default nativeComponentName;
export const Commands = {
flashScrollIndicators(ref) {
UIManager.dispatchViewCommand(
findNodeHandle(ref),
UIManager.getViewManagerConfig(\\"CommandNativeComponent\\").Commands.flashScrollIndicators,
[]
);
},
hotspotUpdate(ref, x, y) {
UIManager.dispatchViewCommand(
findNodeHandle(ref),