mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-04 22:56:32 +08:00
Add support for shadows to RCTVirtualText
Summary: React provides properties to support shadows for Text, this diff implements it for Nodes. Reviewed By: ahmedre Differential Revision: D2817212
This commit is contained in:
committed by
Ahmed El-Helw
parent
f98a288c2a
commit
76abec8894
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* 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.text.TextPaint;
|
||||
import android.text.style.CharacterStyle;
|
||||
|
||||
/* package */ final class ShadowStyleSpan extends CharacterStyle {
|
||||
|
||||
/* package */ static final ShadowStyleSpan INSTANCE = new ShadowStyleSpan(0, 0, 0, 0, true);
|
||||
|
||||
private float mDx;
|
||||
private float mDy;
|
||||
private float mRadius;
|
||||
private int mColor;
|
||||
private boolean mFrozen;
|
||||
|
||||
private ShadowStyleSpan(float dx, float dy, float radius, int color, boolean frozen) {
|
||||
mDx = dx;
|
||||
mDy = dy;
|
||||
mRadius = radius;
|
||||
mColor = color;
|
||||
mFrozen = frozen;
|
||||
}
|
||||
|
||||
public boolean offsetMatches(float dx, float dy) {
|
||||
return mDx == dx && mDy == dy;
|
||||
}
|
||||
|
||||
public void setOffset(float dx, float dy) {
|
||||
mDx = dx;
|
||||
mDy = dy;
|
||||
}
|
||||
|
||||
public float getRadius() {
|
||||
return mRadius;
|
||||
}
|
||||
|
||||
public void setRadius(float radius) {
|
||||
mRadius = radius;
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return mColor;
|
||||
}
|
||||
|
||||
public void setColor(int color) {
|
||||
mColor = color;
|
||||
}
|
||||
|
||||
/* package */ ShadowStyleSpan mutableCopy() {
|
||||
return new ShadowStyleSpan(mDx, mDy, mRadius, mColor, false);
|
||||
}
|
||||
|
||||
/* package */ boolean isFrozen() {
|
||||
return mFrozen;
|
||||
}
|
||||
|
||||
/* package */ void freeze() {
|
||||
mFrozen = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDrawState(TextPaint textPaint) {
|
||||
textPaint.setShadowLayer(mRadius, mDx, mDy, mColor);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user