2016-10-05 14:36:59 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { TouchableHighlight } from 'react-native';
|
2017-06-04 03:12:04 +00:00
|
|
|
import { connect } from 'react-redux';
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2017-01-17 14:44:50 +00:00
|
|
|
import { Icon } from '../../base/font-icons';
|
2016-10-05 14:36:59 +00:00
|
|
|
|
|
|
|
import AbstractToolbarButton from './AbstractToolbarButton';
|
|
|
|
|
|
|
|
/**
|
2017-07-19 21:25:06 +00:00
|
|
|
* Represents a button in {@link Toolbar} on React Native.
|
2016-10-05 14:36:59 +00:00
|
|
|
*
|
|
|
|
* @extends AbstractToolbarButton
|
|
|
|
*/
|
2017-06-04 03:12:04 +00:00
|
|
|
class ToolbarButton extends AbstractToolbarButton {
|
2016-12-01 01:52:39 +00:00
|
|
|
/**
|
2017-07-19 21:25:06 +00:00
|
|
|
* {@code ToolbarButton} component's property types.
|
2016-12-01 01:52:39 +00:00
|
|
|
*
|
|
|
|
* @static
|
|
|
|
*/
|
2017-06-04 03:12:04 +00:00
|
|
|
static propTypes = {
|
|
|
|
...AbstractToolbarButton.propTypes,
|
|
|
|
|
|
|
|
/**
|
2017-07-19 21:25:06 +00:00
|
|
|
* Indicates whether this {@code ToolbarButton} is disabled.
|
2017-06-04 03:12:04 +00:00
|
|
|
*/
|
2017-07-19 09:50:24 +00:00
|
|
|
disabled: React.PropTypes.bool
|
2017-06-04 03:12:04 +00:00
|
|
|
};
|
2016-10-05 14:36:59 +00:00
|
|
|
|
|
|
|
/**
|
2017-07-19 21:25:06 +00:00
|
|
|
* Renders the button of this {@code ToolbarButton}.
|
2016-10-05 14:36:59 +00:00
|
|
|
*
|
|
|
|
* @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}.
|
2016-10-05 14:36:59 +00:00
|
|
|
* @protected
|
2017-07-19 21:25:06 +00:00
|
|
|
* @returns {ReactElement} The button of this {@code ToolbarButton}.
|
2016-10-05 14:36:59 +00:00
|
|
|
*/
|
|
|
|
_renderButton(children) {
|
|
|
|
const props = {};
|
|
|
|
|
2017-07-19 09:50:24 +00:00
|
|
|
'disabled' in this.props && (props.disabled = this.props.disabled);
|
2017-07-19 21:26:27 +00:00
|
|
|
'onClick' in this.props && (props.onPress = this._onClick);
|
2016-10-05 14:36:59 +00:00
|
|
|
'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);
|
|
|
|
}
|
|
|
|
}
|
2017-06-04 03:12:04 +00:00
|
|
|
|
|
|
|
export default connect()(ToolbarButton);
|