Merge pull request #3014 from saghul/toolbox-toggled-labels

[RN] Toolbox toggled item labels
This commit is contained in:
Zoltan Bettenbuk 2018-05-22 21:00:32 +02:00 committed by GitHub
commit a72463a302
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 3 deletions

View File

@ -74,6 +74,8 @@
"toolbar": { "toolbar": {
"addPeople": "Add people to your call", "addPeople": "Add people to your call",
"audioonly": "Enable / Disable audio only mode (saves bandwidth)", "audioonly": "Enable / Disable audio only mode (saves bandwidth)",
"audioOnlyOn": "Enable audio only mode (saves bandwidth)",
"audioOnlyOff": "Disable audio only mode",
"audioRoute": "Select the audio route", "audioRoute": "Select the audio route",
"callQuality": "Manage call quality", "callQuality": "Manage call quality",
"enterFullScreen": "View full screen", "enterFullScreen": "View full screen",
@ -278,6 +280,7 @@
"reservationError": "Reservation system error", "reservationError": "Reservation system error",
"reservationErrorMsg": "Error code: __code__, message: __msg__", "reservationErrorMsg": "Error code: __code__, message: __msg__",
"password": "Enter password", "password": "Enter password",
"unlockRoom": "Unlock room",
"userPassword": "user password", "userPassword": "user password",
"token": "token", "token": "token",
"tokenAuthFailedTitle": "Authentication failed", "tokenAuthFailedTitle": "Authentication failed",

View File

@ -74,6 +74,11 @@ export default class AbstractButton<P: Props, S: *> extends Component<P, S> {
*/ */
label: string; label: string;
/**
* The label for this button, when toggled.
*/
toggledLabel: string;
/** /**
* The name of the icon of this button, when toggled. * The name of the icon of this button, when toggled.
* *
@ -125,6 +130,19 @@ export default class AbstractButton<P: Props, S: *> extends Component<P, S> {
|| this.iconName; || this.iconName;
} }
/**
* Gets the current label, taking the toggled state into account. If no
* toggled label is provided, the regular label will also be used in the
* toggled state.
*
* @private
* @returns {string}
*/
_getLabel() {
return (this._isToggled() ? this.toggledLabel : this.label)
|| this.label;
}
/** /**
* Gets the current styles, taking the toggled state into account. If no * Gets the current styles, taking the toggled state into account. If no
* toggled styles are provided, the regular styles will also be used in the * toggled styles are provided, the regular styles will also be used in the
@ -188,7 +206,7 @@ export default class AbstractButton<P: Props, S: *> extends Component<P, S> {
...this.props, ...this.props,
accessibilityLabel: this.accessibilityLabel, accessibilityLabel: this.accessibilityLabel,
iconName: this._getIconName(), iconName: this._getIconName(),
label: this.label, label: this._getLabel(),
styles: this._getStyles(), styles: this._getStyles(),
tooltip: this.tooltip tooltip: this.tooltip
}; };

View File

@ -34,8 +34,9 @@ type Props = AbstractButtonProps & {
class RoomLockButton extends AbstractButton<Props, *> { class RoomLockButton extends AbstractButton<Props, *> {
accessibilityLabel = 'Room lock'; accessibilityLabel = 'Room lock';
iconName = 'security'; iconName = 'security';
label = 'toolbar.lock'; label = 'dialog.lockRoom';
toggledIconName = 'security-locked'; toggledIconName = 'security-locked';
toggledLabel = 'dialog.unlockRoom';
/** /**
* Handles clicking / pressing the button. * Handles clicking / pressing the button.

View File

@ -29,8 +29,9 @@ type Props = AbstractButtonProps & {
class AudioOnlyButton extends AbstractButton<Props, *> { class AudioOnlyButton extends AbstractButton<Props, *> {
accessibilityLabel = 'Audio only mode'; accessibilityLabel = 'Audio only mode';
iconName = 'visibility'; iconName = 'visibility';
label = 'toolbar.audioonly'; label = 'toolbar.audioOnlyOn';
toggledIconName = 'visibility-off'; toggledIconName = 'visibility-off';
toggledLabel = 'toolbar.audioOnlyOff';
/** /**
* Handles clicking / pressing the button. * Handles clicking / pressing the button.