Files
react-native/ReactAndroid/src/main/java/com/facebook/react/flat/DrawTextLayout.java
Denis Koroskin 5c2f536e9a Add support for RCTText under FlatUIImplementation
Summary: @public Initial version of FlatUIImplementation lacks any primitives support (such as RCTText, RCTImageView or RCTView). This diff add the first part, RCTText (alongside with RCTVirtualText and RCTRawText).

Reviewed By: sriramramani

Differential Revision: D2693348
2016-12-19 13:40:15 -08:00

43 lines
974 B
Java

/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package com.facebook.react.flat;
import android.graphics.Canvas;
import android.text.Layout;
/**
* DrawTextLayout is a DrawCommand that draw {@link Layout}.
*/
/* package */ final class DrawTextLayout extends AbstractDrawCommand {
private Layout mLayout;
/* package */ DrawTextLayout(Layout layout) {
mLayout = layout;
}
/**
* Assigns a new {@link Layout} to draw.
*/
public void setLayout(Layout layout) {
mLayout = layout;
}
@Override
public void draw(Canvas canvas) {
float left = getLeft();
float top = getTop();
canvas.translate(left, top);
mLayout.draw(canvas);
canvas.translate(-left, -top);
}
}