mirror of
https://github.com/status-im/react-native.git
synced 2025-01-14 19:44:13 +00:00
Adding custom view to swipeable component
Summary: as title Reviewed By: fred2028 Differential Revision: D8550184 fbshipit-source-id: 5ba72538fae11d75a82568774dd937b4493e7292
This commit is contained in:
parent
8de402d754
commit
886d70516e
@ -11,7 +11,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const Image = require('Image');
|
const Image = require('Image');
|
||||||
const PropTypes = require('prop-types');
|
|
||||||
const React = require('React');
|
const React = require('React');
|
||||||
const Text = require('Text');
|
const Text = require('Text');
|
||||||
const TouchableHighlight = require('TouchableHighlight');
|
const TouchableHighlight = require('TouchableHighlight');
|
||||||
@ -27,43 +26,37 @@ import type {ImageSource} from 'ImageSource';
|
|||||||
*/
|
*/
|
||||||
class SwipeableQuickActionButton extends React.Component<{
|
class SwipeableQuickActionButton extends React.Component<{
|
||||||
accessibilityLabel?: string,
|
accessibilityLabel?: string,
|
||||||
imageSource: ImageSource | number,
|
imageSource?: ?(ImageSource | number),
|
||||||
imageStyle?: ?ViewPropTypes.style,
|
imageStyle?: ?ViewPropTypes.style,
|
||||||
|
mainView?: ?React.Node,
|
||||||
onPress?: Function,
|
onPress?: Function,
|
||||||
style?: ?ViewPropTypes.style,
|
style?: ?ViewPropTypes.style,
|
||||||
testID?: string,
|
testID?: string,
|
||||||
text?: ?(string | Object | Array<string | Object>),
|
text?: ?(string | Object | Array<string | Object>),
|
||||||
textStyle?: ?ViewPropTypes.style,
|
textStyle?: ?ViewPropTypes.style,
|
||||||
}> {
|
}> {
|
||||||
static propTypes = {
|
|
||||||
accessibilityLabel: PropTypes.string,
|
|
||||||
imageSource: Image.propTypes.source.isRequired,
|
|
||||||
imageStyle: Image.propTypes.style,
|
|
||||||
onPress: PropTypes.func,
|
|
||||||
style: ViewPropTypes.style,
|
|
||||||
testID: PropTypes.string,
|
|
||||||
text: PropTypes.string,
|
|
||||||
textStyle: Text.propTypes.style,
|
|
||||||
};
|
|
||||||
|
|
||||||
render(): React.Node {
|
render(): React.Node {
|
||||||
if (!this.props.imageSource && !this.props.text) {
|
if (!this.props.imageSource && !this.props.text && !this.props.mainView) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
const mainView = this.props.mainView ? (
|
||||||
|
this.props.mainView
|
||||||
|
) : (
|
||||||
|
<View style={this.props.style}>
|
||||||
|
<Image
|
||||||
|
accessibilityLabel={this.props.accessibilityLabel}
|
||||||
|
source={this.props.imageSource}
|
||||||
|
style={this.props.imageStyle}
|
||||||
|
/>
|
||||||
|
<Text style={this.props.textStyle}>{this.props.text}</Text>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
return (
|
return (
|
||||||
<TouchableHighlight
|
<TouchableHighlight
|
||||||
onPress={this.props.onPress}
|
onPress={this.props.onPress}
|
||||||
testID={this.props.testID}
|
testID={this.props.testID}
|
||||||
underlayColor="transparent">
|
underlayColor="transparent">
|
||||||
<View style={this.props.style}>
|
<View style={this.props.style}>{mainView}</View>
|
||||||
<Image
|
|
||||||
accessibilityLabel={this.props.accessibilityLabel}
|
|
||||||
source={this.props.imageSource}
|
|
||||||
style={this.props.imageStyle}
|
|
||||||
/>
|
|
||||||
<Text style={this.props.textStyle}>{this.props.text}</Text>
|
|
||||||
</View>
|
|
||||||
</TouchableHighlight>
|
</TouchableHighlight>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user