You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- New property `shouldHideAfterDelay` : Tell the MessageBar whether or not it should hide after a delay defined in the `duration` property. If `false`, the MessageBar remain shown
- New property `shouldHideOnTap` : Tell the MessageBar whether or not it should hide or not when the user tap the alert. If `false`, the MessageBar will not hide, but the `onTapped` function is triggered, if defined. In addition, if `false`, the `onHide` function will not be triggered. The property `shouldHideAfterDelay` take precedence over `shouldHideOnTap`. That means if `shouldHideAfterDelay` is `false`, the value of `shouldHideOnTap` is not taken into account, since the MessageBar will not ever be hidden
- New property `titleNumberOfLines` : Number of lines of the title. `0` means unlimited
- New property `messageNumberOfLines` : Number of lines of the message. `0` means unlimited
- New property `titleStyle` : Style of the title
- New property `messageStyle` : Style of the message
- New property `avatarStyle` : Style of the icon/avatar
## Bug Fixes
- When a MessageBar alert is shown it hide the existing one and display a new one, instead of replacing the existing one with its new state (formerly using properties)
## Breaking Changes
- Property `type` renamed to `alertType`
@@ -154,7 +106,7 @@ class MessageBar extends Component {
154
106
title: "Error",
155
107
message: error.message,
156
108
type: 'error',
157
-
avatarUrl: null,
109
+
messageNumberOfLines: 0,
158
110
});
159
111
}
160
112
@@ -185,53 +137,59 @@ class MessageBar extends Component {
185
137
return(
186
138
<Viewstyle={styles.container}>
187
139
188
-
<MessageBarAlertref="alert"
189
-
/* Cusomisation of the alert: Title, Message, Icon URL, Alert Type (error, success, warning, info), Duration for Alert keep shown */
190
-
title={this.state.alertTitle}// Title of the alert
191
-
message={this.state.alertMessage}// Message of the alert
192
-
avatarUrl={this.state.alertIconUrl}// Avatar/Icon URL of the alert
193
-
type={this.state.alertType}// Alert Type: you can select one of 'success', 'error', 'warning', 'error', or 'custom' (use custom if you use a 5th stylesheet, all are customizable). Default is 'info'
194
-
duration={this.state.alertDuration}// Number of ms the alert is displayed. Default is 3000 ms (3 seconds)
195
-
196
-
/* Hide setters */
197
-
shouldHideAfterDelay={true}// Define if the MessabeBar should hidden after the `duration`. Please refer yourself to the documentation for component behaviour outputs by setting these 2 properties
198
-
shouldHideOnTap={true}// Define if the MessabeBar should be hidden when user tap the alert. Please refer yourself to the documentation for component behaviour outputs by setting these 2 properties
199
-
200
-
/* Callbacks method on Alert Tapped, on Alert Show, on Alert Hide */
201
-
onTapped={this.state.alertCallback}// This function is executed on alert tap
202
-
onShow={this.alertShow.bind(this)}// This function is executed when alert is shown
203
-
onHide={this.alertHide.bind(this)}// This function is executed when alert is hidden
204
-
205
-
/* Customize the stylesheets and/or provide an additional one 'extra' */
206
-
stylesheetInfo={{backgroundColor : '#007bff',strokeColor : '#006acd'}}// Default are blue colors
207
-
stylesheetSuccess={{backgroundColor : 'darkgreen',strokeColor : '#b40000'}}// Default are Green colors
208
-
stylesheetWarning={{backgroundColor : '#ff9c00',strokeColor : '#f29400'}}// Default are orange colors
209
-
stylesheetError={{backgroundColor : '#ff3232',strokeColor : '#FF0000'}}// Default are red colors
210
-
stylesheetExtra={{backgroundColor : 'black',strokeColor : 'gray'}}// Default are blue colors, same as info
211
-
212
-
/* Customize the duration of the animation */
213
-
durationToShow={500}// Default is 350
214
-
durationToHide={300}// Default is 350
215
-
216
-
/* Offset of the View, useful if you have a navigation bar or if you want the alert be shown below another component instead of the top of the screen */
217
-
viewTopOffset={0}// Default is 0
218
-
viewLeftOffset={0}// Default is 0
219
-
viewRightOffset={0}// Default is 0
220
-
221
-
/* Inset of the view, useful if you want to apply a padding at your alert content */
222
-
viewTopInset={15}// Default is 0
223
-
viewLeftInset={0}// Default is 0
224
-
viewRightInset={0}// Default is 0
225
-
226
-
/* Number of Lines for Title and Message */
227
-
titleNumberOfLines={1}
228
-
messageNumberOfLines={0}// Unlimited number of lines
// Otherwise, You can directly declare a MessageBar alert with its properties and display it by using its reference this.refs.alert.showMessageBarAlert()
144
+
145
+
// <MessageBarAlert ref="alert"
146
+
// /* Cusomisation of the alert: Title, Message, Icon URL, Alert Type (error, success, warning, info), Duration for Alert keep shown */
147
+
// title={this.state.alertTitle} // Title of the alert
148
+
// message={this.state.alertMessage} // Message of the alert
149
+
// avatarUrl={this.state.alertIconUrl} // Avatar/Icon URL of the alert
150
+
// type={this.state.alertType} // Alert Type: you can select one of 'success', 'error', 'warning', 'error', or 'custom' (use custom if you use a 5th stylesheet, all are customizable). Default is 'info'
151
+
// duration={this.state.alertDuration} // Number of ms the alert is displayed. Default is 3000 ms (3 seconds)
152
+
//
153
+
// /* Hide setters */
154
+
// shouldHideAfterDelay={true} // Define if the MessabeBar should hidden after the `duration`. Please refer yourself to the documentation for component behaviour outputs by setting these 2 properties
155
+
// shouldHideOnTap={true} // Define if the MessabeBar should be hidden when user tap the alert. Please refer yourself to the documentation for component behaviour outputs by setting these 2 properties
156
+
//
157
+
// /* Callbacks method on Alert Tapped, on Alert Show, on Alert Hide */
158
+
// onTapped={this.state.alertCallback} // This function is executed on alert tap
159
+
// onShow={this.alertShow.bind(this)} // This function is executed when alert is shown
160
+
// onHide={this.alertHide.bind(this)} // This function is executed when alert is hidden
161
+
//
162
+
// /* Customize the stylesheets and/or provide an additional one 'extra' */
163
+
// stylesheetInfo = {{ backgroundColor : '#007bff', strokeColor : '#006acd' }}// Default are blue colors
164
+
// stylesheetSuccess = {{ backgroundColor : 'darkgreen', strokeColor : '#b40000' }} // Default are Green colors
// stylesheetError = {{ backgroundColor : '#ff3232', strokeColor : '#FF0000' }} // Default are red colors
167
+
// stylesheetExtra = {{ backgroundColor : 'black', strokeColor : 'gray' }} // Default are blue colors, same as info
168
+
//
169
+
// /* Customize the duration of the animation */
170
+
// durationToShow = {500} // Default is 350
171
+
// durationToHide = {300} // Default is 350
172
+
//
173
+
// /* Offset of the View, useful if you have a navigation bar or if you want the alert be shown below another component instead of the top of the screen */
174
+
// viewTopOffset = {0} // Default is 0
175
+
// viewLeftOffset = {0} // Default is 0
176
+
// viewRightOffset = {0} // Default is 0
177
+
//
178
+
// /* Inset of the view, useful if you want to apply a padding at your alert content */
179
+
// viewTopInset = {15} // Default is 0
180
+
// viewLeftInset = {0} // Default is 0
181
+
// viewRightInset = {0} // Default is 0
182
+
//
183
+
// /* Number of Lines for Title and Message */
184
+
// titleNumberOfLines={1}
185
+
// messageNumberOfLines={0} // Unlimited number of lines
186
+
//
187
+
// /* Style for the text elements and the avatar */
Copy file name to clipboardExpand all lines: CustomChildComponent.js
+3-4Lines changed: 3 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -29,13 +29,12 @@ class CustomChildComponent extends Component {
29
29
// the classic method showCurrentAlert(state) where state is the new state of the message bar alert
30
30
31
31
// Declare the new state of the parent's message bar alert
32
-
varnewState={
32
+
MessageBarManager.showCurrentAlert({
33
33
title: 'Alert triggered from child component',
34
34
message: "You can show an alert which is located on its parent's page. You can then declare only one MessageBar. This is useful to fix absolute position in child component",
0 commit comments