jiti-meet/react/features/toolbox/components/ToolbarButton.native.js

61 lines
1.7 KiB
JavaScript
Raw Normal View History

import React from 'react';
import { TouchableHighlight } from 'react-native';
import { connect } from 'react-redux';
2017-01-17 14:44:50 +00:00
import { Icon } from '../../base/font-icons';
import AbstractToolbarButton from './AbstractToolbarButton';
/**
2017-07-19 21:25:06 +00:00
* Represents a button in {@link Toolbar} on React Native.
*
* @extends AbstractToolbarButton
*/
class ToolbarButton extends AbstractToolbarButton {
/**
2017-07-19 21:25:06 +00:00
* {@code ToolbarButton} component's property types.
*
* @static
*/
static propTypes = {
...AbstractToolbarButton.propTypes,
/**
2017-07-19 21:25:06 +00:00
* Indicates whether this {@code ToolbarButton} is disabled.
*/
disabled: React.PropTypes.bool
};
/**
2017-07-19 21:25:06 +00:00
* Renders the button of this {@code ToolbarButton}.
*
* @param {Object} children - The children, if any, to be rendered inside
2017-07-19 21:25:06 +00:00
* the button. Presumably, contains the icon of this {@code ToolbarButton}.
* @protected
2017-07-19 21:25:06 +00:00
* @returns {ReactElement} The button of this {@code ToolbarButton}.
*/
_renderButton(children) {
const props = {};
'disabled' in this.props && (props.disabled = this.props.disabled);
'onClick' in this.props && (props.onPress = event => {
this.props.onClick(event);
});
'style' in this.props && (props.style = this.props.style);
'underlayColor' in this.props
&& (props.underlayColor = this.props.underlayColor);
return React.createElement(TouchableHighlight, props, children);
}
// eslint-disable-next-line valid-jsdoc
/**
* @inheritdoc
*/
_renderIcon() {
return super._renderIcon(Icon);
}
}
export default connect()(ToolbarButton);