Skip to content

Commit

Permalink
Allow setting elevation on any type of View
Browse files Browse the repository at this point in the history
Summary:
Moved setElevation from ReactViewManager to BaseViewManager. This allows
setting elevation on any type of view such as Toolbar for exemple.
Closes facebook#5292

Reviewed By: svcscm

Differential Revision: D2837415

Pulled By: androidtrunkagent

fb-gh-sync-id: a5aa7abd95b99303d312cd9c2414539335540925
  • Loading branch information
janicduplessis authored and facebook-github-bot-7 committed Jan 16, 2016
1 parent c9f274c commit 5ac848c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
private static final String PROP_DECOMPOSED_MATRIX_TRANSLATE_X = "translateX";
private static final String PROP_DECOMPOSED_MATRIX_TRANSLATE_Y = "translateY";
private static final String PROP_OPACITY = "opacity";
private static final String PROP_ELEVATION = "elevation";
private static final String PROP_RENDER_TO_HARDWARE_TEXTURE = "renderToHardwareTextureAndroid";
private static final String PROP_ACCESSIBILITY_LABEL = "accessibilityLabel";
private static final String PROP_ACCESSIBILITY_COMPONENT_TYPE = "accessibilityComponentType";
Expand Down Expand Up @@ -63,6 +64,14 @@ public void setDecomposedMatrix(T view, ReadableMap decomposedMatrix) {
public void setOpacity(T view, float opacity) {
view.setAlpha(opacity);
}

@ReactProp(name = PROP_ELEVATION)
public void setElevation(T view, float elevation) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
view.setElevation(PixelUtil.toPixelFromDIP(elevation));
}
// Do nothing on API < 21
}

@ReactProp(name = PROP_RENDER_TO_HARDWARE_TEXTURE)
public void setRenderToHardwareTexture(T view, boolean useHWTexture) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,6 @@ public void setBorderStyle(ReactViewGroup view, @Nullable String borderStyle) {
view.setBorderStyle(borderStyle);
}

@ReactProp(name = "elevation")
public void setElevation(ReactViewGroup view, float elevation) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
view.setElevation(PixelUtil.toPixelFromDIP(elevation));
}
// Do nothing on API < 21
}

@ReactProp(name = "pointerEvents")
public void setPointerEvents(ReactViewGroup view, @Nullable String pointerEventsStr) {
if (pointerEventsStr != null) {
Expand Down

0 comments on commit 5ac848c

Please sign in to comment.