-
Notifications
You must be signed in to change notification settings - Fork 455
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
6,718 additions
and
1,539 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import React, { PropTypes } from 'react'; | ||
import { Platform } from 'react-native'; | ||
|
||
import { connectStyle } from '@shoutem/theme'; | ||
|
||
import { | ||
TouchableOpacity, | ||
TouchableNativeFeedback, | ||
View, | ||
} from '../index'; | ||
|
||
/** | ||
* A universal touchable component with a | ||
* platform specific feedback. This | ||
* component displays a TouchableOpacity on | ||
* iOS, and a TouchableNativeFeedback on | ||
* Android. | ||
*/ | ||
function Touchable(props) { | ||
const style = { ...props.style }; | ||
delete style.touchableOpacity; | ||
delete style.touchableNativeFeedback; | ||
|
||
if (Platform.OS === 'android') { | ||
return ( | ||
<TouchableNativeFeedback | ||
{...props} | ||
style={props.style.touchableNativeFeedback} | ||
> | ||
<View | ||
virtual | ||
style={style} | ||
styleName={props.styleName} | ||
> | ||
{props.children} | ||
</View> | ||
</TouchableNativeFeedback> | ||
); | ||
} | ||
|
||
return ( | ||
<TouchableOpacity | ||
{...props} | ||
style={{ | ||
...style, | ||
...props.style.touchableOpacity, | ||
}} | ||
> | ||
{props.children} | ||
</TouchableOpacity> | ||
); | ||
} | ||
|
||
Touchable.propTypes = { | ||
...TouchableOpacity.propTypes, | ||
...TouchableNativeFeedback.propTypes, | ||
style: PropTypes.object, | ||
}; | ||
|
||
const StyledTouchable = connectStyle('shoutem.ui.Touchable', { | ||
touchableNativeFeedback: {}, | ||
touchableOpacity: {}, | ||
})(Touchable); | ||
|
||
export { | ||
StyledTouchable as Touchable, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React, { PropTypes } from 'react'; | ||
import { TouchableNativeFeedback as RNTouchableNativeFeedback } from 'react-native'; | ||
|
||
import { connectStyle } from '@shoutem/theme'; | ||
|
||
function TouchableNativeFeedback(props) { | ||
// Remove the props that are not valid | ||
// style keys. | ||
const style = { | ||
...props.style, | ||
}; | ||
delete style.background; | ||
delete style.useForeground; | ||
|
||
return ( | ||
<RNTouchableNativeFeedback | ||
{...props} | ||
style={style} | ||
background={props.style.background} | ||
useForeground={props.style.useForeground} | ||
> | ||
{props.children} | ||
</RNTouchableNativeFeedback> | ||
); | ||
} | ||
|
||
TouchableNativeFeedback.propTypes = { | ||
...RNTouchableNativeFeedback.propTypes, | ||
style: PropTypes.shape({ | ||
background: PropTypes.object, | ||
useForeground: PropTypes.bool, | ||
}), | ||
}; | ||
|
||
const StyledTouchableNativeFeedback = | ||
connectStyle('shoutem.ui.TouchableNativeFeedback')(TouchableNativeFeedback); | ||
|
||
export { | ||
StyledTouchableNativeFeedback as TouchableNativeFeedback, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.