Add support for logoName for ToolbarAndroid. Fixes #371

This commit is contained in:
Joel Arvidsson
2017-01-05 21:39:17 +01:00
parent 380b3a5661
commit 54ad85c8bc
2 changed files with 9 additions and 0 deletions

View File

@@ -320,6 +320,7 @@ Simply use `Icon.ToolbarAndroid` instead of `React.ToolbarAndroid`, this is comp
| Prop | Description | Default |
|---|---|---|
|**`logoName`**|Name of the navigation logo icon (similar to `ToolbarAndroid` `logo`)|*None*|
|**`navIconName`**|Name of the navigation icon (similar to `ToolbarAndroid` `navIcon`)|*None*|
|**`overflowIconName`**|Name of the overflow icon (similar to `ToolbarAndroid` `overflowIcon`). |*none*|
|**`actions`**|Possible actions on the toolbar as part of the action menu, takes the additional arguments `iconName`, `iconColor` and `iconSize`. |*none*|

View File

@@ -13,6 +13,7 @@ import {
export default function createToolbarAndroidComponent(IconNamePropType, getImageSource) {
return class IconToolbarAndroid extends Component {
static propTypes = {
logoIconName: IconNamePropType,
navIconName: IconNamePropType,
overflowIconName: IconNamePropType,
actions: PropTypes.arrayOf(PropTypes.shape({
@@ -34,6 +35,10 @@ export default function createToolbarAndroidComponent(IconNamePropType, getImage
updateIconSources(props) {
const size = props.iconSize;
const color = props.iconColor || props.titleColor;
if (props.logoName) {
getImageSource(props.logoName, size, color)
.then(logo => this.setState({ logo }));
}
if (props.navIconName) {
getImageSource(props.navIconName, size, color)
.then(navIcon => this.setState({ navIcon }));
@@ -60,6 +65,9 @@ export default function createToolbarAndroidComponent(IconNamePropType, getImage
const keys = Object.keys(IconToolbarAndroid.propTypes);
if (!isEqual(pick(nextProps, keys), pick(this.props, keys))) {
const stateToEvict = {};
if (!nextProps.logoName) {
stateToEvict.logo = undefined;
}
if (!nextProps.navIconName) {
stateToEvict.navIcon = undefined;
}