Skip to content

Commit 1199e47

Browse files
cortinicoRiccardo Cipolleschi
authored andcommitted
Add examples of Direct Manipulation in Fabric Intrerop (facebook#36724)
Summary: Pull Request resolved: facebook#36724 Similarly to iOS, this adds some examples of direct manipulation on Android using all the various methods. Changelog: [Internal] [Changed] - Add examples of Direct Manipulation in Fabric Intrerop Reviewed By: cipolleschi Differential Revision: D44541437 fbshipit-source-id: b6e10ac0a815f41ff3c980236b7d8c6937e92065
1 parent cb30323 commit 1199e47

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

packages/rn-tester/NativeComponentExample/js/MyNativeView.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,16 +168,16 @@ export default function MyNativeView(props: {}): React.Node {
168168
}}
169169
/>
170170

171-
<Text style={{textAlign: 'center'}}>
171+
<Text style={{color: 'green', textAlign: 'center'}}>
172172
&gt; Interop Layer Measurements &lt;
173173
</Text>
174-
<Text style={{textAlign: 'center'}}>
174+
<Text style={{color: 'green', textAlign: 'center'}}>
175175
measure {getTextFor(legacyMeasure)}
176176
</Text>
177-
<Text style={{textAlign: 'center'}}>
177+
<Text style={{color: 'green', textAlign: 'center'}}>
178178
InWindow {getTextFor(legacyMeasureInWindow)}
179179
</Text>
180-
<Text style={{textAlign: 'center'}}>
180+
<Text style={{color: 'green', textAlign: 'center'}}>
181181
InLayout {getTextFor(legacyMeasureLayout)}
182182
</Text>
183183
<Button

packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/component/MyLegacyViewManager.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ public void setColor(@NonNull MyNativeView view, @Nullable String color) {
5959
view.setBackgroundColor(Color.parseColor(color));
6060
}
6161

62+
@ReactProp(name = "cornerRadius")
63+
public void setCornerRadius(@NonNull MyNativeView view, @Nullable float cornerRadius) {
64+
view.setCornerRadius(cornerRadius);
65+
}
66+
6267
@Override
6368
public final Map<String, Object> getExportedViewConstants() {
6469
return Collections.singletonMap("PI", 3.14);

packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/component/MyNativeView.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import android.content.Context;
1111
import android.graphics.Color;
12+
import android.graphics.drawable.GradientDrawable;
1213
import android.view.View;
1314
import com.facebook.react.bridge.Arguments;
1415
import com.facebook.react.bridge.ReactContext;
@@ -18,20 +19,28 @@
1819
class MyNativeView extends View {
1920

2021
private int currentColor = 0;
22+
private GradientDrawable background;
2123

2224
public MyNativeView(Context context) {
2325
super(context);
26+
background = new GradientDrawable();
2427
}
2528

2629
@Override
2730
public void setBackgroundColor(int color) {
28-
super.setBackgroundColor(color);
2931
if (color != currentColor) {
32+
background.setColor(color);
3033
currentColor = color;
3134
emitNativeEvent(color);
35+
setBackground(background);
3236
}
3337
}
3438

39+
public void setCornerRadius(float cornerRadius) {
40+
background.setCornerRadius(cornerRadius);
41+
setBackground(background);
42+
}
43+
3544
private void emitNativeEvent(int color) {
3645
WritableMap event = Arguments.createMap();
3746
WritableMap backgroundColor = Arguments.createMap();

0 commit comments

Comments
 (0)