Skip to content

Commit

Permalink
Fix commands with no args
Browse files Browse the repository at this point in the history
Summary: Fixing a typo

Reviewed By: JoshuaGross

Differential Revision: D16434634

fbshipit-source-id: 72a6b698bcd0ba9c10dfbdf264011e0a31ea06b6
  • Loading branch information
elicwhite authored and facebook-github-bot committed Jul 24, 2019
1 parent 4eca2e2 commit fbd5dee
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,14 @@ const COMMANDS: SchemaType = {
events: [],
props: [],
commands: [
{
name: 'flashScrollIndicators',
optional: false,
typeAnnotation: {
type: 'FunctionTypeAnnotation',
params: [],
},
},
{
name: 'hotspotUpdate',
optional: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit fbd5dee

Please sign in to comment.