mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 02:54:11 +08:00
Merge pull request #7253 from NativeScript/mdonev/release-to-master7250
chore: merge release to master
This commit is contained in:
@ -3,7 +3,6 @@
|
||||
paddingLeftProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty,
|
||||
Length, zIndexProperty, textAlignmentProperty, TextAlignment
|
||||
} from "./button-common";
|
||||
import { androidElevationProperty, androidDynamicElevationOffsetProperty } from "../styling/style-properties";
|
||||
import { profile } from "../../profiling";
|
||||
import { TouchGestureEventData, GestureTypes, TouchAction } from "../gestures";
|
||||
import { device } from "../../platform";
|
||||
@ -151,7 +150,13 @@ export class Button extends ButtonBase {
|
||||
org.nativescript.widgets.ViewHelper.setZIndex(this.nativeViewProtected, value);
|
||||
}
|
||||
|
||||
[androidElevationProperty.getDefault](): number {
|
||||
[textAlignmentProperty.setNative](value: TextAlignment) {
|
||||
// Button initial value is center.
|
||||
const newValue = value === "initial" ? "center" : value;
|
||||
super[textAlignmentProperty.setNative](newValue);
|
||||
}
|
||||
|
||||
protected getDefaultElevation(): number {
|
||||
if (sdkVersion() < 21) {
|
||||
return 0;
|
||||
}
|
||||
@ -162,17 +167,11 @@ export class Button extends ButtonBase {
|
||||
return 2;
|
||||
}
|
||||
|
||||
[androidDynamicElevationOffsetProperty.getDefault](): number {
|
||||
protected getDefaultDynamicElevationOffset(): number {
|
||||
if (sdkVersion() < 21) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 4; // 4dp @dimen/button_pressed_z_material
|
||||
}
|
||||
|
||||
[textAlignmentProperty.setNative](value: TextAlignment) {
|
||||
// Button initial value is center.
|
||||
const newValue = value === "initial" ? "center" : value;
|
||||
super[textAlignmentProperty.setNative](newValue);
|
||||
}
|
||||
}
|
||||
|
@ -720,13 +720,7 @@ export class View extends ViewCommon {
|
||||
}
|
||||
|
||||
[androidElevationProperty.getDefault](): number {
|
||||
if (sdkVersion() < 21) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// NOTE: overriden in Button implementation as for widgets with StateListAnimator (Button)
|
||||
// nativeView.getElevation() returns 0 at the time of the getDefault() query
|
||||
return layout.toDeviceIndependentPixels((<any>this.nativeViewProtected).getElevation());
|
||||
return this.getDefaultElevation();
|
||||
}
|
||||
[androidElevationProperty.setNative](value: number) {
|
||||
if (sdkVersion() < 21) {
|
||||
@ -737,7 +731,7 @@ export class View extends ViewCommon {
|
||||
}
|
||||
|
||||
[androidDynamicElevationOffsetProperty.getDefault](): number {
|
||||
return 0;
|
||||
return this.getDefaultDynamicElevationOffset();
|
||||
}
|
||||
[androidDynamicElevationOffsetProperty.setNative](value: number) {
|
||||
if (sdkVersion() < 21) {
|
||||
@ -747,6 +741,21 @@ export class View extends ViewCommon {
|
||||
this.refreshStateListAnimator();
|
||||
}
|
||||
|
||||
protected getDefaultElevation(): number {
|
||||
if (sdkVersion() < 21) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// NOTE: overriden in Button implementation as for widgets with StateListAnimator (Button)
|
||||
// nativeView.getElevation() returns 0 at the time of the getDefault() query
|
||||
return layout.toDeviceIndependentPixels((<any>this.nativeViewProtected).getElevation());
|
||||
}
|
||||
|
||||
protected getDefaultDynamicElevationOffset() {
|
||||
// NOTE: overriden in Button implementation
|
||||
return 0;
|
||||
}
|
||||
|
||||
private refreshStateListAnimator() {
|
||||
const nativeView: any = this.nativeViewProtected;
|
||||
|
||||
@ -754,9 +763,20 @@ export class View extends ViewCommon {
|
||||
const AnimatorSet = android.animation.AnimatorSet;
|
||||
|
||||
const duration = nativeView.getContext().getResources().getInteger(shortAnimTime) / 2;
|
||||
const elevation = layout.toDevicePixels(this.androidElevation || 0);
|
||||
|
||||
let elevation = this.androidElevation;
|
||||
if (typeof elevation === "undefined" || elevation === null) {
|
||||
elevation = this.getDefaultElevation();
|
||||
}
|
||||
elevation = layout.toDevicePixels(elevation);
|
||||
|
||||
const z = layout.toDevicePixels(0);
|
||||
const pressedZ = layout.toDevicePixels(this.androidDynamicElevationOffset || 0);
|
||||
|
||||
let pressedZ = this.androidDynamicElevationOffset;
|
||||
if (typeof pressedZ === "undefined" || pressedZ === null) {
|
||||
pressedZ = this.getDefaultDynamicElevationOffset();
|
||||
}
|
||||
pressedZ = layout.toDevicePixels(pressedZ);
|
||||
|
||||
const pressedSet = new AnimatorSet();
|
||||
pressedSet.playTogether(java.util.Arrays.asList([
|
||||
|
Reference in New Issue
Block a user