@@ -2,6 +2,7 @@ import { createStateListAnimator, getEnabledColorStateList, getLayout, isPostLol
2
2
import { dynamicElevationOffsetProperty , elevationProperty , rippleColorProperty , verticalTextAlignmentProperty } from 'nativescript-material-core/cssproperties' ;
3
3
import { Color } from '@nativescript/core/color' ;
4
4
import { Background } from '@nativescript/core/ui/styling/background' ;
5
+ import { TextBase } from '@nativescript/core/ui/text-base' ;
5
6
import { androidDynamicElevationOffsetProperty , androidElevationProperty , backgroundInternalProperty , Length } from '@nativescript/core/ui/styling/style-properties' ;
6
7
import { ButtonBase } from './button-common' ;
7
8
import { VerticalTextAlignment } from 'nativescript-material-core' ;
@@ -13,6 +14,7 @@ let textId;
13
14
let containedId ;
14
15
let flatId ;
15
16
let grayColorStateList : android . content . res . ColorStateList ;
17
+
16
18
export class Button extends ButtonBase {
17
19
nativeViewProtected : com . google . android . material . button . MaterialButton ;
18
20
@@ -21,7 +23,7 @@ export class Button extends ButtonBase {
21
23
get android ( ) : com . google . android . material . button . MaterialButton {
22
24
return this . nativeView ;
23
25
}
24
-
26
+
25
27
@profile
26
28
public createNativeView ( ) {
27
29
let layoutId ;
@@ -64,11 +66,25 @@ export class Button extends ButtonBase {
64
66
}
65
67
return view ;
66
68
}
69
+
70
+ // initNativeView() {
71
+ // TextBase.prototype.initNativeView.call(this);
72
+ // const nativeView = this.nativeViewProtected;
73
+ // const clickListener = new android.view.View.OnClickListener({
74
+ // onClick:()=>{
75
+ // console.log('overriden button onClick');
76
+ // this._emit(ButtonBase.tapEvent);
77
+ // }
78
+ // });
79
+ // nativeView.setOnClickListener(clickListener);
80
+ // (<any>nativeView).clickListener = clickListener;
81
+ // }
67
82
[ rippleColorProperty . setNative ] ( color : Color ) {
68
83
this . nativeViewProtected . setRippleColor ( android . content . res . ColorStateList . valueOf ( color . android ) ) ;
69
84
}
70
85
71
86
getDefaultElevation ( ) : number {
87
+ console . log ( 'getDefaultElevation' , 2 , new Error ( ) . stack ) ;
72
88
return 2 ; // 2dp @dimen/mtrl_btn_elevation
73
89
}
74
90
@@ -80,14 +96,16 @@ export class Button extends ButtonBase {
80
96
if ( isPostLollipop ( ) ) {
81
97
createStateListAnimator ( this , this . nativeViewProtected ) ;
82
98
} else {
83
- this . nativeViewProtected . setElevation ( value ) ;
99
+ const newValue = Length . toDevicePixels ( typeof value === 'string' ? Length . parse ( value ) : value , 0 ) ;
100
+ this . nativeViewProtected . setElevation ( newValue ) ;
84
101
}
85
102
}
86
103
[ dynamicElevationOffsetProperty . setNative ] ( value : number ) {
87
104
if ( isPostLollipop ( ) ) {
88
105
createStateListAnimator ( this , this . nativeViewProtected ) ;
89
106
} else {
90
- this . nativeViewProtected . setTranslationZ ( value ) ;
107
+ const newValue = Length . toDevicePixels ( typeof value === 'string' ? Length . parse ( value ) : value , 0 ) ;
108
+ this . nativeViewProtected . setTranslationZ ( newValue ) ;
91
109
}
92
110
}
93
111
[ androidElevationProperty . setNative ] ( value : number ) {
@@ -98,12 +116,12 @@ export class Button extends ButtonBase {
98
116
}
99
117
100
118
setCornerRadius ( value ) {
101
- const newValue = Length . toDevicePixels ( typeof value === 'string' ? Length . parse ( value ) : value , 0 ) ;
102
- this . nativeViewProtected . setCornerRadius ( newValue ) ;
119
+ // const newValue = Length.toDevicePixels(typeof value === 'string' ? Length.parse(value) : value, 0);
120
+ this . nativeViewProtected . setCornerRadius ( value ) ;
103
121
}
104
122
setStrokeWidth ( value ) {
105
- const newValue = Length . toDevicePixels ( typeof value === 'string' ? Length . parse ( value ) : value , 0 ) ;
106
- this . nativeViewProtected . setStrokeWidth ( newValue ) ;
123
+ // const newValue = Length.toDevicePixels(typeof value === 'string' ? Length.parse(value) : value, 0);
124
+ this . nativeViewProtected . setStrokeWidth ( value ) ;
107
125
}
108
126
[ backgroundInternalProperty . setNative ] ( value : android . graphics . drawable . Drawable | Background ) {
109
127
const view = this . nativeTextViewProtected ;
0 commit comments