11'use strict' ;
22
3- const React = require ( 'react' ) ;
4- const {
5- PropTypes
6- } = React ;
7-
8- const {
3+ import React , { PropTypes } from 'react' ;
4+ import {
95 View ,
106 TouchableOpacity ,
117 Text ,
128 StyleSheet ,
139 ActivityIndicator ,
1410 TouchableNativeFeedback ,
1511 Platform
16- } = require ( 'react-native' ) ;
17-
18- const isEqual = require ( 'lodash.isequal' ) ;
12+ } from 'react-native' ;
13+ import isEqual from 'lodash.isequal' ;
1914
2015const Button = React . createClass ( {
2116 propTypes : {
@@ -26,8 +21,8 @@ const Button = React.createClass({
2621 PropTypes . node ,
2722 PropTypes . element
2823 ] ) ,
29- activeOpacity : PropTypes . number ,
3024 accessibilityLabel : PropTypes . string ,
25+ activeOpacity : PropTypes . number ,
3126 allowFontScaling : PropTypes . bool ,
3227 isLoading : PropTypes . bool ,
3328 isDisabled : PropTypes . bool ,
@@ -94,38 +89,37 @@ const Button = React.createClass({
9489 { this . _renderInnerText ( ) }
9590 </ View >
9691 ) ;
97- } else {
98- // Extract Touchable props
99- let touchableProps = {
100- accessibilityLabel : this . props . accessibilityLabel ,
101- onPress : this . props . onPress ,
102- onPressIn : this . props . onPressIn ,
103- onPressOut : this . props . onPressOut ,
104- onLongPress : this . props . onLongPress ,
105- activeOpacity : this . props . activeOpacity ,
106- delayLongPress : this . props . delayLongPress ,
107- delayPressIn : this . props . delayPressIn ,
108- delayPressOut : this . props . delayPressOut ,
109- } ;
110- if ( Button . isAndroid ) {
111- touchableProps = Object . assign ( touchableProps , {
112- background : this . props . background || TouchableNativeFeedback . SelectableBackground ( )
113- } ) ;
114- return (
115- < TouchableNativeFeedback { ...touchableProps } >
116- < Text style = { [ styles . button , this . props . style ] } >
117- { this . _renderInnerText ( ) }
118- </ Text >
119- </ TouchableNativeFeedback >
120- )
121- } else {
122- return (
123- < TouchableOpacity { ...touchableProps }
124- style = { [ styles . button , this . props . style ] } >
92+ }
93+ // Extract Touchable props
94+ let touchableProps = {
95+ accessibilityLabel : this . props . accessibilityLabel ,
96+ onPress : this . props . onPress ,
97+ onPressIn : this . props . onPressIn ,
98+ onPressOut : this . props . onPressOut ,
99+ onLongPress : this . props . onLongPress ,
100+ activeOpacity : this . props . activeOpacity ,
101+ delayLongPress : this . props . delayLongPress ,
102+ delayPressIn : this . props . delayPressIn ,
103+ delayPressOut : this . props . delayPressOut ,
104+ } ;
105+ if ( Button . isAndroid ) {
106+ touchableProps = Object . assign ( touchableProps , {
107+ background : this . props . background || TouchableNativeFeedback . SelectableBackground ( )
108+ } ) ;
109+ return (
110+ < TouchableNativeFeedback { ...touchableProps } >
111+ < View style = { [ styles . button , this . props . style ] } >
125112 { this . _renderInnerText ( ) }
126- </ TouchableOpacity >
127- ) ;
128- }
113+ </ View >
114+ </ TouchableNativeFeedback >
115+ )
116+ } else {
117+ return (
118+ < TouchableOpacity { ...touchableProps }
119+ style = { [ styles . button , this . props . style ] } >
120+ { this . _renderInnerText ( ) }
121+ </ TouchableOpacity >
122+ ) ;
129123 }
130124 }
131125} ) ;
@@ -134,15 +128,18 @@ const styles = StyleSheet.create({
134128 button : {
135129 height : 44 ,
136130 flexDirection : 'row' ,
131+ alignItems : 'center' ,
137132 borderWidth : 1 ,
138133 borderRadius : 8 ,
139134 marginBottom : 10 ,
140135 alignSelf : 'stretch' ,
141136 justifyContent : 'center' ,
142137 } ,
143138 textButton : {
139+ flex : 1 ,
144140 fontSize : 18 ,
145- alignSelf : 'center' ,
141+ textAlign : 'center' ,
142+ backgroundColor : 'transparent' ,
146143 } ,
147144 spinner : {
148145 alignSelf : 'center' ,
0 commit comments