Skip to content

Commit

Permalink
[skip ci] Refactor ViewManager codegen to use new ViewManagerInterface (
Browse files Browse the repository at this point in the history
#48549)

Summary:

Refactor ViewManager codegen to use new ViewManagerInterface

changelog: [internal] internal

Reviewed By: javache

Differential Revision: D67957884
  • Loading branch information
mdvacca authored and facebook-github-bot committed Jan 10, 2025
1 parent 21717b1 commit 3d8e9a7
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ package com.facebook.react.viewmanagers;
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.uimanager.ViewManagerWithGeneratedInterface;
public interface ArrayPropsNativeComponentViewManagerInterface<T extends View> {
public interface ArrayPropsNativeComponentViewManagerInterface<T extends View> extends ViewManagerWithGeneratedInterface {
void setNames(T view, @Nullable ReadableArray value);
void setDisableds(T view, @Nullable ReadableArray value);
void setProgress(T view, @Nullable ReadableArray value);
Expand Down Expand Up @@ -50,8 +51,9 @@ package com.facebook.react.viewmanagers;
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.uimanager.ViewManagerWithGeneratedInterface;
public interface BooleanPropNativeComponentViewManagerInterface<T extends View> {
public interface BooleanPropNativeComponentViewManagerInterface<T extends View> extends ViewManagerWithGeneratedInterface {
void setDisabled(T view, boolean value);
void setDisabledNullable(T view, @Nullable Boolean value);
}
Expand All @@ -74,8 +76,9 @@ package com.facebook.react.viewmanagers;
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.uimanager.ViewManagerWithGeneratedInterface;
public interface ColorPropNativeComponentViewManagerInterface<T extends View> {
public interface ColorPropNativeComponentViewManagerInterface<T extends View> extends ViewManagerWithGeneratedInterface {
void setTintColor(T view, @Nullable Integer value);
}
",
Expand All @@ -97,9 +100,10 @@ package com.facebook.react.viewmanagers;
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.uimanager.ViewManagerWithGeneratedInterface;
import com.facebook.yoga.YogaValue;
public interface DimensionPropNativeComponentViewManagerInterface<T extends View> {
public interface DimensionPropNativeComponentViewManagerInterface<T extends View> extends ViewManagerWithGeneratedInterface {
void setMarginBack(T view, @Nullable YogaValue value);
}
",
Expand All @@ -120,8 +124,9 @@ Object {
package com.facebook.react.viewmanagers;
import android.view.View;
import com.facebook.react.uimanager.ViewManagerWithGeneratedInterface;
public interface EdgeInsetsPropNativeComponentViewManagerInterface<T extends View> {
public interface EdgeInsetsPropNativeComponentViewManagerInterface<T extends View> extends ViewManagerWithGeneratedInterface {
// No props
}
",
Expand All @@ -143,8 +148,9 @@ package com.facebook.react.viewmanagers;
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.uimanager.ViewManagerWithGeneratedInterface;
public interface EnumPropNativeComponentViewManagerInterface<T extends View> {
public interface EnumPropNativeComponentViewManagerInterface<T extends View> extends ViewManagerWithGeneratedInterface {
void setAlignment(T view, @Nullable String value);
void setIntervals(T view, @Nullable Integer value);
}
Expand All @@ -166,8 +172,9 @@ Object {
package com.facebook.react.viewmanagers;
import android.view.View;
import com.facebook.react.uimanager.ViewManagerWithGeneratedInterface;
public interface EventNestedObjectPropsNativeComponentViewManagerInterface<T extends View> {
public interface EventNestedObjectPropsNativeComponentViewManagerInterface<T extends View> extends ViewManagerWithGeneratedInterface {
void setDisabled(T view, boolean value);
}
",
Expand All @@ -188,8 +195,9 @@ Object {
package com.facebook.react.viewmanagers;
import android.view.View;
import com.facebook.react.uimanager.ViewManagerWithGeneratedInterface;
public interface EventPropsNativeComponentViewManagerInterface<T extends View> {
public interface EventPropsNativeComponentViewManagerInterface<T extends View> extends ViewManagerWithGeneratedInterface {
void setDisabled(T view, boolean value);
}
",
Expand All @@ -211,8 +219,9 @@ package com.facebook.react.viewmanagers;
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.uimanager.ViewManagerWithGeneratedInterface;
public interface FloatPropsNativeComponentViewManagerInterface<T extends View> {
public interface FloatPropsNativeComponentViewManagerInterface<T extends View> extends ViewManagerWithGeneratedInterface {
void setBlurRadius(T view, float value);
void setBlurRadius2(T view, float value);
void setBlurRadius3(T view, float value);
Expand Down Expand Up @@ -241,8 +250,9 @@ package com.facebook.react.viewmanagers;
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.uimanager.ViewManagerWithGeneratedInterface;
public interface ImagePropNativeComponentViewManagerInterface<T extends View> {
public interface ImagePropNativeComponentViewManagerInterface<T extends View> extends ViewManagerWithGeneratedInterface {
void setThumbImage(T view, @Nullable ReadableMap value);
}
",
Expand All @@ -263,8 +273,9 @@ Object {
package com.facebook.react.viewmanagers;
import android.view.View;
import com.facebook.react.uimanager.ViewManagerWithGeneratedInterface;
public interface IntegerPropNativeComponentViewManagerInterface<T extends View> {
public interface IntegerPropNativeComponentViewManagerInterface<T extends View> extends ViewManagerWithGeneratedInterface {
void setProgress1(T view, int value);
void setProgress2(T view, int value);
void setProgress3(T view, int value);
Expand All @@ -288,8 +299,9 @@ package com.facebook.react.viewmanagers;
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.uimanager.ViewManagerWithGeneratedInterface;
public interface InterfaceOnlyNativeComponentViewManagerInterface<T extends View> {
public interface InterfaceOnlyNativeComponentViewManagerInterface<T extends View> extends ViewManagerWithGeneratedInterface {
void setTitle(T view, @Nullable String value);
}
",
Expand All @@ -311,8 +323,9 @@ package com.facebook.react.viewmanagers;
import android.view.View;
import com.facebook.react.bridge.Dynamic;
import com.facebook.react.uimanager.ViewManagerWithGeneratedInterface;
public interface MixedPropNativeComponentViewManagerInterface<T extends View> {
public interface MixedPropNativeComponentViewManagerInterface<T extends View> extends ViewManagerWithGeneratedInterface {
void setMixedProp(T view, Dynamic value);
}
",
Expand All @@ -335,8 +348,9 @@ package com.facebook.react.viewmanagers;
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.uimanager.ViewManagerWithGeneratedInterface;
public interface MultiNativePropNativeComponentViewManagerInterface<T extends View> {
public interface MultiNativePropNativeComponentViewManagerInterface<T extends View> extends ViewManagerWithGeneratedInterface {
void setThumbImage(T view, @Nullable ReadableMap value);
void setColor(T view, @Nullable Integer value);
void setThumbTintColor(T view, @Nullable Integer value);
Expand All @@ -360,8 +374,9 @@ Object {
package com.facebook.react.viewmanagers;
import android.view.View;
import com.facebook.react.uimanager.ViewManagerWithGeneratedInterface;
public interface NoPropsNoEventsNativeComponentViewManagerInterface<T extends View> {
public interface NoPropsNoEventsNativeComponentViewManagerInterface<T extends View> extends ViewManagerWithGeneratedInterface {
// No props
}
",
Expand All @@ -384,8 +399,9 @@ package com.facebook.react.viewmanagers;
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.uimanager.ViewManagerWithGeneratedInterface;
public interface ObjectPropsNativeComponentManagerInterface<T extends View> {
public interface ObjectPropsNativeComponentManagerInterface<T extends View> extends ViewManagerWithGeneratedInterface {
void setObjectProp(T view, @Nullable ReadableMap value);
void setObjectArrayProp(T view, @Nullable ReadableMap value);
void setObjectPrimitiveRequiredProp(T view, @Nullable ReadableMap value);
Expand All @@ -410,8 +426,9 @@ package com.facebook.react.viewmanagers;
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.uimanager.ViewManagerWithGeneratedInterface;
public interface PointPropNativeComponentViewManagerInterface<T extends View> {
public interface PointPropNativeComponentViewManagerInterface<T extends View> extends ViewManagerWithGeneratedInterface {
void setStartPoint(T view, @Nullable ReadableMap value);
}
",
Expand All @@ -433,8 +450,9 @@ package com.facebook.react.viewmanagers;
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.uimanager.ViewManagerWithGeneratedInterface;
public interface StringPropNativeComponentViewManagerInterface<T extends View> {
public interface StringPropNativeComponentViewManagerInterface<T extends View> extends ViewManagerWithGeneratedInterface {
void setPlaceholder(T view, @Nullable String value);
void setDefaultValue(T view, @Nullable String value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ package ${packageName};
${imports}
public interface ${className}<T extends ${extendClasses}> {
public interface ${className}<T extends ${extendClasses}> extends ViewManagerWithGeneratedInterface {
${methods}
}
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ function getImports(
): Set<string> {
const imports: Set<string> = new Set();

if (type === 'interface') {
imports.add(
'import com.facebook.react.uimanager.ViewManagerWithGeneratedInterface;',
);
}

component.extendsProps.forEach(extendProps => {
switch (extendProps.type) {
case 'ReactNativeBuiltInType':
Expand Down
Loading

0 comments on commit 3d8e9a7

Please sign in to comment.