use of com.facebook.react.bridge.ReadableMap in project react-native-camera by lwansbrough.
the class FaceDetectorUtils method rotateFaceX.
public static WritableMap rotateFaceX(WritableMap face, int sourceWidth, double scaleX) {
ReadableMap faceBounds = face.getMap("bounds");
ReadableMap oldOrigin = faceBounds.getMap("origin");
WritableMap mirroredOrigin = positionMirroredHorizontally(oldOrigin, sourceWidth, scaleX);
double translateX = -faceBounds.getMap("size").getDouble("width");
WritableMap translatedMirroredOrigin = positionTranslatedHorizontally(mirroredOrigin, translateX);
WritableMap newBounds = Arguments.createMap();
newBounds.merge(faceBounds);
newBounds.putMap("origin", translatedMirroredOrigin);
for (String landmarkName : landmarkNames) {
ReadableMap landmark = face.hasKey(landmarkName) ? face.getMap(landmarkName) : null;
if (landmark != null) {
WritableMap mirroredPosition = positionMirroredHorizontally(landmark, sourceWidth, scaleX);
face.putMap(landmarkName, mirroredPosition);
}
}
face.putMap("bounds", newBounds);
return face;
}
use of com.facebook.react.bridge.ReadableMap in project native-navigation by airbnb.
the class ReactToolbar method setRightButtons.
/* package */
void setRightButtons(Menu menu, ReadableArray buttons, final ReactInterface component) {
mActionsHolder.clear();
int length = buttons.size();
for (int i = 0; i < length; i++) {
ReadableMap button = buttons.getMap(i);
String title = button.hasKey("title") && button.getType("title") == ReadableType.String ? button.getString("title") : String.format("Item %s", i);
// use `length - i` for ordering so the button ordering is consistent with iOS
MenuItem item = menu.add(Menu.NONE, Menu.NONE, length - i, title);
if (button.hasKey("image")) {
setMenuItemIcon(item, button.getMap("image"));
}
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
final Object data = i;
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
component.emitEvent("onRightPress", data);
return false;
}
});
}
}
use of com.facebook.react.bridge.ReadableMap in project react-native-navigation by wix.
the class NavigationModuleTest method setRoot_delegatesToNavigator.
@Test
public void setRoot_delegatesToNavigator() throws JSONException {
when(reactApplicationContext.getCurrentActivity()).thenReturn(activity);
ReadableMap root = mock(ReadableMap.class);
when(jsonParser.parse(root)).thenReturn(rootJson());
ViewController rootViewController = mock(ViewController.class);
when(layoutFactory.create(any(LayoutNode.class))).thenReturn(rootViewController);
uut.setRoot("1", root, mock(Promise.class));
ShadowLooper.idleMainLooper();
verify(navigator).setRoot(eq(rootViewController), any(), any());
}
Aggregations