1
1
import { VerticalTextAlignment , verticalTextAlignmentProperty } from '@nativescript-community/text' ;
2
2
import { dynamicElevationOffsetProperty , elevationProperty , rippleColorProperty } from '@nativescript-community/ui-material-core' ;
3
3
import { createStateListAnimator , getLayout , isPostLollipop } from '@nativescript-community/ui-material-core/android/utils' ;
4
- import { Background , Color , Length , TextTransform , androidDynamicElevationOffsetProperty , androidElevationProperty , backgroundInternalProperty , profile , textTransformProperty } from '@nativescript/core' ;
4
+ import {
5
+ Background ,
6
+ Color ,
7
+ Length ,
8
+ TextTransform ,
9
+ androidDynamicElevationOffsetProperty ,
10
+ androidElevationProperty ,
11
+ backgroundInternalProperty ,
12
+ profile ,
13
+ textTransformProperty ,
14
+ } from '@nativescript/core' ;
5
15
import { ButtonBase } from './button-common' ;
6
16
7
17
let LayoutInflater : typeof android . view . LayoutInflater ;
8
18
9
19
let textId ;
10
20
let containedId ;
11
21
let flatId ;
22
+ let outlineId ;
12
23
let grayColorStateList : android . content . res . ColorStateList ;
13
24
14
25
export class Button extends ButtonBase {
@@ -22,7 +33,7 @@ export class Button extends ButtonBase {
22
33
let layoutId ;
23
34
const variant = this . variant ;
24
35
// let layoutIdName = 'material_button';
25
- if ( variant === 'text' || variant === 'outline' ) {
36
+ if ( variant === 'text' ) {
26
37
if ( ! textId ) {
27
38
textId = getLayout ( 'material_button_text' ) ;
28
39
}
@@ -32,6 +43,11 @@ export class Button extends ButtonBase {
32
43
flatId = getLayout ( 'material_button_flat' ) ;
33
44
}
34
45
layoutId = flatId ;
46
+ } else if ( variant === 'outline' ) {
47
+ if ( ! outlineId ) {
48
+ outlineId = getLayout ( 'material_button_outline' ) ;
49
+ }
50
+ layoutId = outlineId ;
35
51
} else {
36
52
if ( ! containedId ) {
37
53
containedId = getLayout ( 'material_button' ) ;
@@ -48,15 +64,16 @@ export class Button extends ButtonBase {
48
64
if ( ! LayoutInflater ) {
49
65
LayoutInflater = android . view . LayoutInflater ;
50
66
}
67
+ console . log ( 'test' , this . variant , layoutId ) ;
51
68
const view = android . view . LayoutInflater . from ( this . _context ) . inflate ( layoutId , null , false ) as com . google . android . material . button . MaterialButton ;
52
69
53
- if ( variant === 'outline' ) {
54
- view . setStrokeWidth ( 1 ) ;
55
- if ( ! grayColorStateList ) {
56
- grayColorStateList = android . content . res . ColorStateList . valueOf ( new Color ( 'gray' ) . android ) ;
57
- }
58
- view . setStrokeColor ( grayColorStateList ) ;
59
- }
70
+ // if (variant === 'outline') {
71
+ // view.setStrokeWidth(1);
72
+ // if (!grayColorStateList) {
73
+ // grayColorStateList = android.content.res.ColorStateList.valueOf(new Color('gray').android);
74
+ // }
75
+ // view.setStrokeColor(grayColorStateList);
76
+ // }
60
77
return view ;
61
78
}
62
79
@@ -115,7 +132,7 @@ export class Button extends ButtonBase {
115
132
this . nativeViewProtected . setStrokeWidth ( value ) ;
116
133
}
117
134
[ textTransformProperty . setNative ] ( value : TextTransform ) {
118
- this . nativeViewProtected . setAllCaps ( ( value !== 'none' ) ) ;
135
+ this . nativeViewProtected . setAllCaps ( value !== 'none' ) ;
119
136
}
120
137
[ backgroundInternalProperty . setNative ] ( value : android . graphics . drawable . Drawable | Background ) {
121
138
const view = this . nativeTextViewProtected ;
0 commit comments