jiti-meet/react/features/base/toolbox/components/ToolboxItem.native.js

87 lines
2.4 KiB
JavaScript
Raw Normal View History

// @flow
import React from 'react';
import { Text, TouchableHighlight, View } from 'react-native';
2019-08-30 16:39:06 +00:00
import { Icon } from '../../icons';
import AbstractToolboxItem from './AbstractToolboxItem';
import type { Props } from './AbstractToolboxItem';
/**
* Native implementation of {@code AbstractToolboxItem}.
*/
export default class ToolboxItem extends AbstractToolboxItem<Props> {
/**
2018-05-16 21:49:03 +00:00
* Renders the {@code Icon} part of this {@code ToolboxItem}.
*
* @private
* @returns {ReactElement}
*/
_renderIcon() {
const { styles } = this.props;
return (
<Icon
2019-08-30 16:39:06 +00:00
src = { this.props.icon }
style = { styles && styles.iconStyle } />
);
}
/**
2018-05-16 21:49:03 +00:00
* Renders this {@code ToolboxItem}. Invoked by {@link AbstractToolboxItem}.
*
2018-05-16 21:49:03 +00:00
* @override
* @protected
* @returns {ReactElement}
*/
_renderItem() {
const {
disabled,
elementAfter,
onClick,
showLabel,
styles,
toggled
} = this.props;
2018-05-16 21:49:03 +00:00
let children = this._renderIcon();
// XXX When using a wrapper View, apply the style to it instead of
// applying it to the TouchableHighlight.
let style = styles && styles.style;
if (showLabel) {
2018-05-16 21:49:03 +00:00
// XXX TouchableHighlight requires 1 child. If there's a need to
// show both the icon and the label, then these two need to be
// wrapped in a View.
children = (
2018-05-16 21:49:03 +00:00
<View style = { style }>
{ children }
<Text style = { styles && styles.labelStyle }>
{ this.label }
</Text>
{ elementAfter }
</View>
);
2018-05-16 21:49:03 +00:00
// XXX As stated earlier, the style was applied to the wrapper View
// (above).
style = undefined;
}
return (
<TouchableHighlight
fix(i18n) Accessiblity labels translations (#3071) * fix(toolbar): accessibilityLabel should be translatable. This commit adds a helper property to get the accessibilityLabel of an item, providing a translation if one is available. This mimics the behavior of label and tooltip. * fix(toolbar) 'hangup' button accessibilityLabel i18n * fix(toolbar) 'mute' button accessibilityLabel i18n * fix(toolbar) 'videomute' button accessibilityLabel i18n * fix(toolbar) 'moreActions' button accessibilityLabel i18n * fix(toolbar) 'shareRoom' button accessibilityLabel i18n * fix(toolbar) 'audioRoute' button accessibilityLabel i18n * fix(toolbar) 'toggleCamera' button accessibilityLabel i18n * fix(toolbar) 'audioOnly' button accessibilityLabel i18n * fix(toolbar) 'roomLock' button accessibilityLabel i18n * fix(toolbar) 'pip' button accessibilityLabel i18n * fix(toolbar) 'invite' button accessibilityLabel i18n * fix(toolbar) 'raiseHand' button accessibilityLabel i18n * fix(toolbar) 'chat' button accessibilityLabel i18n * fix(toolbar) 'shareYourScreen' button accessibilityLabel i18n * fix(toolbar) 'fullScreen' button accessibilityLabel i18n * fix(toolbar) 'sharedvideo' button accessibilityLabel i18n * fix(toolbar) 'document' button accessibilityLabel i18n * fix(toolbar) 'speakerStats' button accessibilityLabel i18n * fix(toolbar) 'feedback' button accessibilityLabel i18n * fix(toolbar) 'shortcuts' button accessibilityLabel i18n * fix(toolbar) 'recording' button accessibilityLabel i18n * fix(toolbar) 'settings' button accessibilityLabel i18n * fix(welcomepage) accessibilityLabels i18n * fix(toolbar) 'info' button accessibilityLabel i18n * fix(i18n): Add translation to various aria-label property values. * fix(i18n): Differentiate between overflow menu and button.
2018-06-07 20:32:18 +00:00
accessibilityLabel = { this.accessibilityLabel }
accessibilityRole = 'button'
2022-01-07 10:54:42 +00:00
accessibilityState = {{ 'selected': Boolean(toggled) }}
disabled = { disabled }
onPress = { onClick }
style = { style }
underlayColor = { styles && styles.underlayColor } >
{ children }
</TouchableHighlight>
);
}
}