Skip to content
This repository has been archived by the owner on Feb 4, 2021. It is now read-only.

Commit

Permalink
Add Ripple component for compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Ehesp committed Jan 12, 2016
1 parent fe694a0 commit a0fc633
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
51 changes: 51 additions & 0 deletions lib/Ripple.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import React, { Component, PropTypes, View, Text, TouchableNativeFeedback } from 'react-native';
import { default as PolyfillRipple } from './polyfill/Ripple';
import { isCompatible } from './helpers';

export default class RippleMain extends Component {

static propTypes = {
color: PropTypes.string,
onPress: PropTypes.func,
onLongPress: PropTypes.func,
children: PropTypes.node.isRequired
};

static defaultProps = {
color: 'rgba(0,0,0,.2)'
};

render() {
const { color, onPress, onLongPress, children, ...other } = this.props;

if (!isCompatible('TouchableNativeFeedback')) {
return (
<PolyfillRipple
rippleColor={color}
onPress={onPress}
onLongPress={onLongPress}
{...other}
>
{/* Stops fatal crash with out of bounds animation */}
<View style={{ marginHorizontal: .2 }}>
{children}
</View>
</PolyfillRipple>
)
}

return (
<TouchableNativeFeedback
background={TouchableNativeFeedback.Ripple(color)}
onPress={onPress}
onLongPress={onLongPress}
>
<View {...other}>
{children}
</View>
</TouchableNativeFeedback>
);
}

}

2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export { default as Icon } from './Icon';
export { default as IconToggle } from './IconToggle';
//export { default as List } from './List';
export { default as RadioButton } from './RadioButton';
export { default as Ripple } from './polyfill/Ripple';
export { default as Ripple } from './Ripple';
export { default as RadioButtonGroup } from './RadioButtonGroup';
export { default as Subheader } from './Subheader';
export { default as Toolbar } from './Toolbar';

0 comments on commit a0fc633

Please sign in to comment.