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

Commit

Permalink
Improved backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Ehesp committed Dec 29, 2015
1 parent 472383d commit ea38639
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 13 deletions.
10 changes: 9 additions & 1 deletion lib/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,15 @@ export default class Button extends Component {
rippleColor={rippleColor}
onPress={!disabled ? onPress : null}
onLongPress={!disabled ? onLongPress : null}
style={Object.assign({}, styles.button, buttonStyle, { backgroundColor: buttonStyle && buttonStyle.backgroundColor })}
style={[
styles.button,
buttonStyle, {
backgroundColor: buttonStyle && buttonStyle.backgroundColor,
}, raised && !isCompatible('elevation') && {
borderWidth: 1,
borderColor: 'rgba(0,0,0,.12)'
}
]}
>
<Text style={[TYPO.paperFontButton, textStyle]}>
{value}
Expand Down
10 changes: 9 additions & 1 deletion lib/Card/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { Component, PropTypes, View } from 'react-native';
import { isCompatible } from '../helpers';

import Media from './Media';
import Body from './Body';
Expand All @@ -25,7 +26,14 @@ export default class Card extends Component {
const { elevation, children } = this.props;

return (
<View style={Object.assign(styles.container, { elevation })}>
<View style={[
styles.container, {
elevation
}, !isCompatible('elevation') && {
borderWidth: 1,
borderColor: 'rgba(0,0,0,.12)'
}]}
>
{children}
</View>
);
Expand Down
12 changes: 8 additions & 4 deletions lib/Drawer/Section.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,16 @@ export default class Section extends Component {
return (
<Ripple
key={i}
rippleColor={'rgba(153,153,153,.4)'}
rippleColor="rgba(153,153,153,.4)"
onPress={item.onPress}
onLongPress={item.onLongPress}
style={{
flex: 1,
flexDirection: 'row',
backgroundColor: item.active ? ACTIVE_COLOR : null
}}
>
<View style={item.active ? { backgroundColor: ACTIVE_COLOR } : {}}>
{this.renderRow(item, i, TEXT_COLOR)}
</View>
{this.renderRow(item, i, TEXT_COLOR)}
</Ripple>
);
}
Expand All @@ -126,6 +129,7 @@ export default class Section extends Component {

const styles = {
section: {
flex: 1,
marginTop: 8
},
item: {
Expand Down
9 changes: 5 additions & 4 deletions lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,18 @@ export function getColor(string) {

/**
* Detect whether a specific feature is compatible with the device
* @param feature
* @param string
* @returns bool
*/
export function isCompatible(feature) {
const version = Platform.Version;

switch(feature) {
case 'TouchableNativeFeedback':
const required = 21;

return version >= required;
return version >= 21;
break;
case 'elevation':
return version >= 21;
break;
default:
return true;
Expand Down
5 changes: 2 additions & 3 deletions lib/polyfill/Ripple.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default class Ripple extends Component {
elevation: PropTypes.array,
onPress: PropTypes.func,
onLongPress: PropTypes.func,
style: PropTypes.object,
style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
children: PropTypes.element.isRequired
};

Expand All @@ -49,7 +49,7 @@ export default class Ripple extends Component {
<View
elevation={elevation ? elevation : 0}
ref='container'
style={Object.assign(styles.container, style)}
style={style || {}}
{...this._responder}
>
<Animated.View style={[
Expand Down Expand Up @@ -150,7 +150,6 @@ export default class Ripple extends Component {

const styles = {
container: {
backgroundColor: 'rgba(0,0,0,0)',
overflow: 'hidden'
},
background: {
Expand Down

0 comments on commit ea38639

Please sign in to comment.