|
|
@@ -68,6 +68,11 @@ export default class AbstractButton<P: Props, S: *> extends Component<P, S> {
|
|
68
|
68
|
*/
|
|
69
|
69
|
label: string;
|
|
70
|
70
|
|
|
|
71
|
+ /**
|
|
|
72
|
+ * The label for this button, when toggled.
|
|
|
73
|
+ */
|
|
|
74
|
+ toggledLabel: string;
|
|
|
75
|
+
|
|
71
|
76
|
/**
|
|
72
|
77
|
* The name of the icon of this button, when toggled.
|
|
73
|
78
|
*
|
|
|
@@ -119,6 +124,19 @@ export default class AbstractButton<P: Props, S: *> extends Component<P, S> {
|
|
119
|
124
|
|| this.iconName;
|
|
120
|
125
|
}
|
|
121
|
126
|
|
|
|
127
|
+ /**
|
|
|
128
|
+ * Gets the current label, taking the toggled state into account. If no
|
|
|
129
|
+ * toggled label is provided, the regular label will also be used in the
|
|
|
130
|
+ * toggled state.
|
|
|
131
|
+ *
|
|
|
132
|
+ * @private
|
|
|
133
|
+ * @returns {string}
|
|
|
134
|
+ */
|
|
|
135
|
+ _getLabel() {
|
|
|
136
|
+ return (this._isToggled() ? this.toggledLabel : this.label)
|
|
|
137
|
+ || this.label;
|
|
|
138
|
+ }
|
|
|
139
|
+
|
|
122
|
140
|
/**
|
|
123
|
141
|
* Gets the current styles, taking the toggled state into account. If no
|
|
124
|
142
|
* toggled styles are provided, the regular styles will also be used in the
|
|
|
@@ -179,7 +197,7 @@ export default class AbstractButton<P: Props, S: *> extends Component<P, S> {
|
|
179
|
197
|
...this.props,
|
|
180
|
198
|
accessibilityLabel: this.accessibilityLabel,
|
|
181
|
199
|
iconName: this._getIconName(),
|
|
182
|
|
- label: this.label,
|
|
|
200
|
+ label: this._getLabel(),
|
|
183
|
201
|
styles: this._getStyles(),
|
|
184
|
202
|
tooltip: this.tooltip
|
|
185
|
203
|
};
|