@@ -15,31 +15,34 @@ export default class Button extends NativeBaseComponent {
1515 return {
1616 button : {
1717 padding : 10 ,
18- flex : 1 ,
19- borderColor : 'transparent' ,
20- height : 45 ,
2118 justifyContent : 'space-around' ,
2219 flexDirection : 'row' ,
2320 marginBottom : 10 ,
21+ alignSelf : 'flex-start' ,
2422 backgroundColor : this . getTheme ( ) . btnPrimaryBg ,
25- } ,
26- buttonText : {
27- fontSize : this . getTheme ( ) . btnTextSize ,
28- color : this . getTheme ( ) . btnPrimaryColor
2923 }
3024 }
3125 }
3226 prepareRootProps ( ) {
3327
34- var type = { backgroundColor : ( this . props . primary ) ? this . getTheme ( ) . primary :
28+ var type = { backgroundColor : ( this . props . primary ) ? this . getTheme ( ) . btnPrimaryBg :
29+ ( ( this . props . transparent ) || ( this . props . bordered ) ) ? 'rgba(0,0,0,0)' :
3530 ( this . props . success ) ? this . getTheme ( ) . btnSuccessBg :
3631 ( this . props . danger ) ? this . getTheme ( ) . btnDangerBg :
3732 ( this . props . warning ) ? this . getTheme ( ) . btnWarningBg :
3833 ( this . props . info ) ? this . getTheme ( ) . btnInfoBg :
3934 ( this . props . backgroundColor ) ? this . props . backgroundColor :
40- ( this . props . transparent ) ? 'rgba(0,0,0,0)' :
4135 this . getInitialStyle ( ) . button . backgroundColor ,
42- borderRadius : ( this . props . rounded ) ? this . getTheme ( ) . borderRadiusLarge : this . getTheme ( ) . borderRadiusBase
36+ borderRadius : ( this . props . rounded ) ? this . getTheme ( ) . borderRadiusLarge : this . getTheme ( ) . borderRadiusBase ,
37+ borderWidth : ( this . props . bordered ) ? 1 : 0 ,
38+ borderColor : ( this . props . primary ) ? this . getTheme ( ) . primary :
39+ ( this . props . success ) ? this . getTheme ( ) . btnSuccessBg :
40+ ( this . props . danger ) ? this . getTheme ( ) . btnDangerBg :
41+ ( this . props . warning ) ? this . getTheme ( ) . btnWarningBg :
42+ ( this . props . info ) ? this . getTheme ( ) . btnInfoBg :
43+ this . getInitialStyle ( ) . button . backgroundColor ,
44+ height : ( this . props . large ) ? 60 : ( this . props . small ) ? 35 : 45 ,
45+ alignSelf : ( this . props . block ) ? 'stretch' : 'flex-start' ,
4346 }
4447
4548 var addedProps = _ . merge ( this . getInitialStyle ( ) . button , type ) ;
@@ -54,20 +57,33 @@ export default class Button extends NativeBaseComponent {
5457
5558 getTextStyle ( ) {
5659 var mergedStyle = { } ;
57- return _ . merge ( mergedStyle , this . getInitialStyle ( ) . buttonText , this . props . textStyle ) ;
60+
61+ var btnType = {
62+ color : ( ( this . props . bordered ) && ( this . props . primary ) ) ? this . getTheme ( ) . btnPrimaryBg :
63+ ( ( this . props . bordered ) && ( this . props . success ) ) ? this . getTheme ( ) . btnSuccessBg :
64+ ( ( this . props . bordered ) && ( this . props . danger ) ) ? this . getTheme ( ) . btnDangerBg :
65+ ( ( this . props . bordered ) && ( this . props . warning ) ) ? this . getTheme ( ) . btnWarningBg :
66+ ( ( this . props . bordered ) && ( this . props . info ) ) ? this . getTheme ( ) . btnInfoBg :
67+ this . getTheme ( ) . inverseTextColor ,
68+ fontSize : ( this . props . large ) ? this . getTheme ( ) . btnTextSizeLarge : ( this . props . small ) ? this . getTheme ( ) . btnTextSizeSmall : this . getTheme ( ) . btnTextSize ,
69+ lineHeight : ( this . props . large ) ? 32 : ( this . props . small ) ? 15 : 22
70+ }
71+
72+ var addedBtnProps = _ . merge ( this . getInitialStyle ( ) . buttonText , btnType ) ;
73+ return _ . merge ( mergedStyle , addedBtnProps , this . props . textStyle ) ;
5874 }
5975
6076 renderChildren ( ) {
6177 if ( typeof this . props . children == undefined || typeof this . props . children == "string" ) {
6278 return < TouchableOpacity { ...this . prepareRootProps ( ) } >
63- < Text style = { [ this . getTextStyle ( ) , this . getInitialStyle ( ) . buttonText ] } > { this . props . children } </ Text >
79+ < Text style = { this . getTextStyle ( ) } > { this . props . children } </ Text >
6480 </ TouchableOpacity >
6581 }
6682
6783 else if ( Array . isArray ( this . props . children ) ) {
6884 if ( this . props . children [ 0 ] && ( typeof this . props . children [ 0 ] == "string" || this . props . children [ 0 ] . type == undefined ) )
69- return < TouchableOpacity { ...this . prepareRootProps ( ) } >
70- < Text style = { [ this . getTextStyle ( ) , this . getInitialStyle ( ) . buttonText ] } > { this . props . children [ 0 ] } </ Text >
85+ return < TouchableOpacity { ...this . prepareRootProps ( ) } >
86+ < Text style = { this . getTextStyle ( ) } > { this . props . children [ 0 ] } </ Text >
7187 < Text >
7288 { this . props . children [ 1 ] }
7389 </ Text >
0 commit comments