11import React , { Component , PropTypes } from 'react' ;
22import { StyleSheet , Text , View , Animated ,
33 TouchableNativeFeedback , TouchableWithoutFeedback , Dimensions , Platform } from 'react-native' ;
4- import { shadowStyle , alignItemsMap , Touchable , isAndroid , touchableBackground } from './shared' ;
4+ import { shadowStyle , alignItemsMap , getTouchableComponent , isAndroid , touchableBackground , DEFAULT_ACTIVE_OPACITY } from './shared' ;
55
66const { width : WIDTH } = Dimensions . get ( 'window' ) ;
77const SHADOW_SPACE = 10 ;
8+ const TEXT_HEIGHT = 22 ;
9+
810const TextTouchable = isAndroid ? TouchableNativeFeedback : TouchableWithoutFeedback ;
911
1012export default class ActionButtonItem extends Component {
1113 static get defaultProps ( ) {
1214 return {
1315 active : true ,
14- spaceBetween : 15
16+ spaceBetween : 15 ,
17+ useNativeFeedback : true ,
18+ activeOpacity : DEFAULT_ACTIVE_OPACITY ,
1519 } ;
1620 }
1721
1822 static get propTypes ( ) {
1923 return {
2024 active : PropTypes . bool ,
25+ useNativeFeedback : PropTypes . bool ,
26+ activeOpacity : PropTypes . number ,
2127 }
2228 }
2329
@@ -51,15 +57,17 @@ export default class ActionButtonItem extends Component {
5157 height : size ,
5258 borderRadius : size / 2 ,
5359 backgroundColor : this . props . buttonColor || this . props . btnColor ,
54- }
60+ } ;
5561
5662 if ( position !== 'center' ) buttonStyle [ position ] = ( this . props . parentSize - size ) / 2 ;
5763
64+ const Touchable = getTouchableComponent ( this . props . useNativeFeedback ) ;
65+
5866 return (
5967 < Animated . View pointerEvents = "box-none" style = { animatedViewStyle } >
6068 < Touchable
6169 background = { touchableBackground }
62- activeOpacity = { this . props . activeOpacity || 0.85 }
70+ activeOpacity = { this . props . activeOpacity || DEFAULT_ACTIVE_OPACITY }
6371 onPress = { this . props . onPress } >
6472 < View
6573 style = { [ buttonStyle , ! hideShadow && shadowStyle , this . props . style ] }
@@ -90,7 +98,7 @@ export default class ActionButtonItem extends Component {
9098 return (
9199 < TextTouchable
92100 background = { touchableBackground }
93- activeOpacity = { this . props . activeOpacity || 0.85 }
101+ activeOpacity = { this . props . activeOpacity || DEFAULT_ACTIVE_OPACITY }
94102 onPress = { this . props . onPress } >
95103 < View style = { textStyles } >
96104 < Text style = { [ styles . text , this . props . textStyle ] } > { this . props . title } </ Text >
@@ -100,7 +108,6 @@ export default class ActionButtonItem extends Component {
100108 }
101109}
102110
103- const TEXT_HEIGHT = 22 ;
104111
105112const styles = StyleSheet . create ( {
106113 textContainer : {
0 commit comments