Nenhuma descrição

ToastMsg.js 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /**
  2. * Created by zack on 2017/5/8.
  3. */
  4. import Toast from 'react-native-root-toast'
  5. const ToastMsg = {
  6. show: (msg, durationSet) => {
  7. let message = msg
  8. let time = 2000
  9. if (durationSet === 2000) {
  10. time = 2000
  11. }else if (durationSet === 3000) {
  12. time = 3000
  13. }else if (durationSet === 4000) {
  14. time = 4000
  15. }else if (durationSet === 5000) {
  16. time = 5000
  17. }else if (durationSet === 6000) {
  18. time = 6000
  19. }else if (durationSet === 7000) {
  20. time = 7000
  21. }else if (durationSet === 8000) {
  22. time = 8000
  23. }else if (durationSet === 9000) {
  24. time = 9000
  25. }else if (durationSet === 10000) {
  26. time = 10000
  27. }else {
  28. time = 2000
  29. }
  30. const messageParam = {
  31. duration: time,
  32. position: Toast.positions.CENTER,
  33. shadow: true,
  34. animation: true,
  35. hideOnPress: false,
  36. delay: 0,
  37. }
  38. let toast = Toast.show(message, messageParam);
  39. // You can manually hide the Toast, or it will automatically disappear after a `duration` ms timeout.
  40. // setTimeout(function () {
  41. // Toast.hide(toast);
  42. // }, 10000);
  43. }
  44. }
  45. export default ToastMsg