import {Component} from 'react';
import Toast from 'react-native-tiny-toast';
import {setSpText} from './util';
export default class ToastBox extends Component {
static show = content => {
// toastShort toastLong
if (this.toast !== undefined) {
Toast.hide(this.toast);
}
this.toast = Toast.show(content.toString(), {
duration: 2000,
position: 0,
shadow: true,
animation: true,
hideOnPress: true,
delay: 0,
textStyle: {fontSize: setSpText(28)}
});
};
static showTop = content => {
// toastShortTop
if (this.toast !== undefined) {
Toast.hide(this.toast);
}
this.toast = Toast.show(content.toString(), {
duration: 2000,
position: 100,
shadow: true,
animation: false,
hideOnPress: true,
delay: 0,
textStyle: {fontSize: setSpText(28)}
});
};
static showBottom = content => {
// toastShortBottom
if (this.toast !== undefined) {
Toast.hide(this.toast);
}
this.toast = Toast.show(content.toString(), {
duration: 2000,
position: -200,
shadow: true,
animation: true,
hideOnPress: true,
delay: 0,
textStyle: {fontSize: setSpText(28)}
});
};
static loading = () => {
if (this.toast !== undefined) {
Toast.hide(this.toast);
}
this.toast = Toast.showLoading();
};
static hide = () => {
if (this.toast !== undefined) {
Toast.hide(this.toast);
}
this.toast = Toast.hide();
};
}
react-native Toast簡單封裝
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.