use DynamicFromObject to avoid maps

Summary:
Changes our property access pattern to iterate through props once and pass the Object value directly rather than looking the value up in the map with the key.

Note some ViewManagers methods (especially yoga related ones on shadow nodes) expect a `Dyanamic`, so this diff also creates Dynamic's only when needed by the hand-written code, and introduces a new `DynamicWithObject` to create them that simply wraps the underlying object (as opposed to `DynamicWithMap` which wraps the map and does a lookup any time the `Dynamic` is accessed.

Reviewed By: mdvacca

Differential Revision: D14453300

fbshipit-source-id: df98567b6eff1e6b7c611f179eb11e413fb94e5d
This commit is contained in:
Spencer Ahrens authored and Facebook Github Bot committed 2019-03-25 12:12:10 -07:00
1 parent af38a0cf87
commit a46fba5dd3
8 files changed
+422 -246

No files matched your search

@@ -9,6 +9,7 @@ package com.facebook.react.uimanager;
import java.util.Map;
import android.graphics.drawable.ColorDrawable;
import android.view.View;
import com.facebook.react.bridge.ReadableMap;
@@ -94,6 +95,20 @@ public class SimpleViewPropertyTest {
assertThat(view.getAlpha()).isEqualTo(1.0f);
}
@Test
public void testBackgroundColor() {
View view = mManager.createView(mThemedContext, new JSResponderHandler());
mManager.updateProperties(view, buildStyles());
assertThat(view.getBackground()).isEqualTo(null);
mManager.updateProperties(view, buildStyles("backgroundColor", 12));
assertThat(((ColorDrawable)view.getBackground()).getColor()).isEqualTo(12);
mManager.updateProperties(view, buildStyles("backgroundColor", null));
assertThat(((ColorDrawable)view.getBackground()).getColor()).isEqualTo(0);
}
@Test
public void testGetNativeProps() {
Map<String, String> nativeProps = mManager.getNativeProps();