mirror of
https://github.com/zhigang1992/react-native-web.git
synced 2026-04-24 04:25:27 +08:00
53 lines
1.3 KiB
JavaScript
53 lines
1.3 KiB
JavaScript
import PropTypes from 'prop-types';
|
|
import TweetAction from '../TweetAction';
|
|
import { View, StyleSheet } from 'react-native';
|
|
import React, { PureComponent } from 'react';
|
|
|
|
const actionNames = ['reply', 'retweet', 'like', 'directMessage'];
|
|
|
|
export default class TweetActionsBar extends PureComponent {
|
|
static propTypes = {
|
|
actions: PropTypes.arrayOf(
|
|
PropTypes.shape({
|
|
count: PropTypes.number,
|
|
label: PropTypes.string,
|
|
highlighted: PropTypes.bool,
|
|
name: PropTypes.oneOf(actionNames).isRequired,
|
|
onPress: PropTypes.func
|
|
})
|
|
),
|
|
style: PropTypes.object
|
|
};
|
|
|
|
render() {
|
|
const { actions, style } = this.props;
|
|
|
|
/* eslint-disable react/jsx-handler-names */
|
|
return (
|
|
<View style={[styles.root, style]}>
|
|
{actions.map((action, i) => (
|
|
<TweetAction
|
|
accessibilityLabel={actions.label}
|
|
count={action.count}
|
|
displayMode={action.name}
|
|
highlighted={action.highlighted}
|
|
key={i}
|
|
onPress={action.onPress}
|
|
style={styles.action}
|
|
/>
|
|
))}
|
|
</View>
|
|
);
|
|
}
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
root: {
|
|
flexDirection: 'row'
|
|
},
|
|
action: {
|
|
display: 'block',
|
|
marginRight: '10%'
|
|
}
|
|
});
|