| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,7 +3,6 @@ | |||
| 3 | 3 | paddingLeftProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty, | |
| 4 | 4 | Length, zIndexProperty, textAlignmentProperty, TextAlignment | |
| 5 | 5 | } from "./button-common"; | |
| 6 | - import { androidElevationProperty, androidDynamicElevationOffsetProperty } from "../styling/style-properties"; | ||
| 7 | 6 | import { profile } from "../../profiling"; | |
| 8 | 7 | import { TouchGestureEventData, GestureTypes, TouchAction } from "../gestures"; | |
| 9 | 8 | import { device } from "../../platform"; | |
@@ -151,7 +150,13 @@ export class Button extends ButtonBase { | |||
| 151 | 150 | org.nativescript.widgets.ViewHelper.setZIndex(this.nativeViewProtected, value); | |
| 152 | 151 | } | |
| 153 | 152 | ||
| 154 | - [androidElevationProperty.getDefault](): number { | ||
| 153 | + [textAlignmentProperty.setNative](value: TextAlignment) { | ||
| 154 | + // Button initial value is center. | ||
| 155 | + const newValue = value === "initial" ? "center" : value; | ||
| 156 | + super[textAlignmentProperty.setNative](newValue); | ||
| 157 | + } | ||
| 158 | + | ||
| 159 | + protected getDefaultElevation(): number { | ||
| 155 | 160 | if (sdkVersion() < 21) { | |
| 156 | 161 | return 0; | |
| 157 | 162 | } | |
@@ -162,17 +167,11 @@ export class Button extends ButtonBase { | |||
| 162 | 167 | return 2; | |
| 163 | 168 | } | |
| 164 | 169 | ||
| 165 | - [androidDynamicElevationOffsetProperty.getDefault](): number { | ||
| 170 | + protected getDefaultDynamicElevationOffset(): number { | ||
| 166 | 171 | if (sdkVersion() < 21) { | |
| 167 | 172 | return 0; | |
| 168 | 173 | } | |
| 169 | 174 | ||
| 170 | 175 | return 4; // 4dp @dimen/button_pressed_z_material | |
| 171 | 176 | } | |
| 172 | - | ||
| 173 | - [textAlignmentProperty.setNative](value: TextAlignment) { | ||
| 174 | - // Button initial value is center. | ||
| 175 | - const newValue = value === "initial" ? "center" : value; | ||
| 176 | - super[textAlignmentProperty.setNative](newValue); | ||
| 177 | - } | ||
| 178 | 177 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -720,13 +720,7 @@ export class View extends ViewCommon { | |||
| 720 | 720 | } | |
| 721 | 721 | ||
| 722 | 722 | [androidElevationProperty.getDefault](): number { | |
| 723 | - if (sdkVersion() < 21) { | ||
| 724 | - return 0; | ||
| 725 | - } | ||
| 726 | - | ||
| 727 | - // NOTE: overriden in Button implementation as for widgets with StateListAnimator (Button) | ||
| 728 | - // nativeView.getElevation() returns 0 at the time of the getDefault() query | ||
| 729 | - return layout.toDeviceIndependentPixels((<any>this.nativeViewProtected).getElevation()); | ||
| 723 | + return this.getDefaultElevation(); | ||
| 730 | 724 | } | |
| 731 | 725 | [androidElevationProperty.setNative](value: number) { | |
| 732 | 726 | if (sdkVersion() < 21) { | |
@@ -737,7 +731,7 @@ export class View extends ViewCommon { | |||
| 737 | 731 | } | |
| 738 | 732 | ||
| 739 | 733 | [androidDynamicElevationOffsetProperty.getDefault](): number { | |
| 740 | - return 0; | ||
| 734 | + return this.getDefaultDynamicElevationOffset(); | ||
| 741 | 735 | } | |
| 742 | 736 | [androidDynamicElevationOffsetProperty.setNative](value: number) { | |
| 743 | 737 | if (sdkVersion() < 21) { | |
@@ -747,16 +741,42 @@ export class View extends ViewCommon { | |||
| 747 | 741 | this.refreshStateListAnimator(); | |
| 748 | 742 | } | |
| 749 | 743 | ||
| 744 | + protected getDefaultElevation(): number { | ||
| 745 | + if (sdkVersion() < 21) { | ||
| 746 | + return 0; | ||
| 747 | + } | ||
| 748 | + | ||
| 749 | + // NOTE: overriden in Button implementation as for widgets with StateListAnimator (Button) | ||
| 750 | + // nativeView.getElevation() returns 0 at the time of the getDefault() query | ||
| 751 | + return layout.toDeviceIndependentPixels((<any>this.nativeViewProtected).getElevation()); | ||
| 752 | + } | ||
| 753 | + | ||
| 754 | + protected getDefaultDynamicElevationOffset() { | ||
| 755 | + // NOTE: overriden in Button implementation | ||
| 756 | + return 0; | ||
| 757 | + } | ||
| 758 | + | ||
| 750 | 759 | private refreshStateListAnimator() { | |
| 751 | 760 | const nativeView: any = this.nativeViewProtected; | |
| 752 | 761 | ||
| 753 | 762 | const ObjectAnimator = android.animation.ObjectAnimator; | |
| 754 | 763 | const AnimatorSet = android.animation.AnimatorSet; | |
| 755 | 764 | ||
| 756 | 765 | const duration = nativeView.getContext().getResources().getInteger(shortAnimTime) / 2; | |
| 757 | - const elevation = layout.toDevicePixels(this.androidElevation || 0); | ||
| 766 | + | ||
| 767 | + let elevation = this.androidElevation; | ||
| 768 | + if (typeof elevation === "undefined" || elevation === null) { | ||
| 769 | + elevation = this.getDefaultElevation(); | ||
| 770 | + } | ||
| 771 | + elevation = layout.toDevicePixels(elevation); | ||
| 772 | + | ||
| 758 | 773 | const z = layout.toDevicePixels(0); | |
| 759 | - const pressedZ = layout.toDevicePixels(this.androidDynamicElevationOffset || 0); | ||
| 774 | + | ||
| 775 | + let pressedZ = this.androidDynamicElevationOffset; | ||
| 776 | + if (typeof pressedZ === "undefined" || pressedZ === null) { | ||
| 777 | + pressedZ = this.getDefaultDynamicElevationOffset(); | ||
| 778 | + } | ||
| 779 | + pressedZ = layout.toDevicePixels(pressedZ); | ||
| 760 | 780 | ||
| 761 | 781 | const pressedSet = new AnimatorSet(); | |
| 762 | 782 | pressedSet.playTogether(java.util.Arrays.asList([ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments