# Shoutem UI Toasts :bread:
New component used for multiple types of alerts, or simple action prompts. The component is based on the [react-native-toast-message ](https://github.com/calintamas/react-native-toast-message)package, with our wrapper implementation defining custom styled toast types
> You are still free to use the react-native-toast-message show/hide methods directly, through our default export, if you so desire.
## Usage
Most of the time, you will want to use one of the four standard methods of showing a toast using this package.
- Toast.showInfo
- Toast.showAlert
- Toast.showError
- Toast.showSuccess
- Toast.show() and Toast.hide() methods are identical to the ones in the parent library. So if you want to use your own components for alerts, you can do it just like you would normally.
Each of these accepts same set or props / params, but implements different styling and color schemes, according to it's semantic significance. Below are a couple of examples of commonly used methods.
```jsx
import { Toast } from '@shoutem/ui';
...
Toast.showInfo({
title: 'Hello world!',
message: `This is a message!`,
iconSource: {
uri: 'https://townsquare.media/site/341/files/2012/05/Mr.-Trololo.jpg',
},
});
...
```
```jsx
import { Toast } from '@shoutem/ui';
...
Toast.showAlert({
title: 'Stop',
message: `Hammer time`,
iconSource: require('../assets/actionIcon.png'),
cancelButtonText: 'absolutely not',
confirmButtonText: `Hammer zeit!`,
onCancel: Toast.hide,
onConfirm: () => {
console.log('A man of culture....');
Toast.hide();
}
});
...
```
```jsx
import { Toast } from '@shoutem/ui';
...
Toast.showError({
title: 'Error',
message: `We've failed to charge your credit card. Please check your CC data`,
iconName: 'error',
confirmButtonText: `Take me to payment details`,
onConfirm: () => {
navigateTo('PaymentDetailsScreen');
Toast.hide();
}
autoHide: false,
});
...
```
### Props
Currently supported props mainly include "native" props from the parent library, with both, a few exclusions and a some additions. Also, you can pass any kind of custom prop you want, and it will be passed in to your custom toast component
| **Name** | **Type** | **Default** | **Description** |
|---------------------------------------------|-------------------|-------------|----------------------------------------------------------------------------------------------------------------------------------|
| title | String | Required | Title of the toast message |
| message | String | Required | Description of the toast message |
| iconName | String | Info | Name of the existing icon in the UI toolkit that will be used as a leading image |
| iconSource | ImageSourceType | undefined | Standard image source ( uri object, direct require, ... ). If this prop is passed in, it will take presedence over iconName prop |
| durationIndicator | Bool | true | Displays the duration indicator line below the toast, in the duration of the `visibilityTime` prop |
| onConfirm | Function | undefined | Callback called when pressing the confirm button |
| onCancel | Function | undefined | Callback called when pressing the cancel button |
| confirmButtonText | String | undefined | |
| cancelButtonText | String | undefined | |
| `-- props supported from parent library --` | | | |
| position | `top` or `bottom` | top | |
| visibilityTime | Number | 4000 | How long is the toast displayed |
| autoHide | Bool | true | Hide automatically after visibilityTime has expired |
| topOffset | Number | 40 | |
| bottomOffset | Number | 40 | |
| keyboardOffset | Number | 10 | |
| onShow | Function | | |
| onHide | Function | | |
| onPress | Function | | |
## BaseToast
This component also exports our base component that contains all of the internal logic that understand how to compose and handle toast message. If you'd like to create a new Toast component, feel free to use the BaseToast, and inject `customToastStyle` prop that will be merged with the default styles, and / or any other prop manipualtion you require.
没有合适的资源?快使用搜索试试~ 我知道了~
ReactNative应用程序的可定制组件集_JavaScript_下载.zip
共272个文件
svg:122个
js:122个
ttf:11个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 138 浏览量
2023-04-21
11:02:52
上传
评论
收藏 1.08MB ZIP 举报
温馨提示
ReactNative应用程序的可定制组件集_JavaScript_下载.zip
资源推荐
资源详情
资源评论
收起资源包目录
ReactNative应用程序的可定制组件集_JavaScript_下载.zip (272个子文件)
.editorconfig 421B
.eslintignore 131B
.gitignore 117B
theme.js 79KB
HorizontalPager.js 10KB
ListView.js 10KB
index.js 9KB
SimpleHtml.js 9KB
DropDownModal.js 8KB
YearRangePickerModal.js 8KB
Html.js 7KB
DateTimePicker.js 6KB
Inline.js 6KB
ActionSheet.js 5KB
ImageGallery.js 4KB
InlineDropDownMenu.js 4KB
HtmlParser.js 4KB
ImageGalleryOverlay.js 4KB
InlineGallery.js 4KB
index.js 4KB
NumberInput.js 4KB
ScrollView.js 3KB
NavigationBar.js 3KB
BaseToast.js 3KB
TabMenu.js 3KB
Image.js 3KB
YearRangePicker.js 3KB
ImageBackground.js 3KB
Image.js 3KB
ScrollDriverProvider.js 3KB
DropDownMenu.js 3KB
TextInput.js 3KB
index.js 3KB
GridRow.js 2KB
toastMessage.js 2KB
variableResolver.js 2KB
PageIndicators.js 2KB
A.js 2KB
ImagePreview.js 2KB
SearchField.js 2KB
device-selector.js 2KB
InlineDropDownMenuItem.js 2KB
composeChildren.js 2KB
Switch.js 2KB
Video.js 2KB
ShareButton.js 2KB
TabMenuItem.js 2KB
Text.js 2KB
YearRangePickerButton.js 2KB
VideoSourceReader.js 2KB
LoadingContainer.js 2KB
View-test.js 2KB
EmptyListImage.js 2KB
EmptyStateView.js 2KB
ToastProgressBar.js 2KB
icons.js 2KB
Touchable.js 2KB
CategoryPicker.js 1KB
NavigationBarAnimations.js 1KB
Gallery.js 1KB
add-native-deps.js 1KB
ElementRegistry.js 1KB
LinearGradient.js 1KB
Video.js 1KB
Category.js 1KB
View.js 1022B
TouchableNativeFeedback.js 1021B
Block.js 1007B
ActionSheetOption.js 953B
Ul.js 843B
Text.js 841B
Ol.js 838B
Page.js 778B
const.js 771B
Icon.js 765B
TouchableOpacity.js 744B
renderItems.js 720B
Button.js 698B
Li.js 664B
Spinner.js 655B
keyboard.js 654B
LoadingIndicator.js 647B
FormGroup.js 627B
Lightbox.js 587B
Img.js 584B
Number.js 502B
SuccessToast.js 432B
ActionToast.js 427B
ErrorToast.js 424B
init.js 371B
InfoToast.js 365B
index.js 358B
index.js 338B
Bullet.js 322B
Overlay.js 278B
Divider.js 278B
Screen.js 273B
Tile.js 263B
Card.js 263B
Row.js 258B
共 272 条
- 1
- 2
- 3
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9154
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功