Loading.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import React from "react";
  2. import { StyleSheet } from "react-native";
  3. import {
  4. Modal,
  5. Card,
  6. Text,
  7. Button,
  8. Layout,
  9. Spinner,
  10. Icon,
  11. } from "@ui-kitten/components";
  12. import { useModel, setModel } from "flooks";
  13. import loadingModel from "../models/loadingModel";
  14. import Textarea from "react-native-textarea";
  15. setModel("loadingModel", loadingModel);
  16. export default function Loading(props) {
  17. const { tip, confirm, cancel, getWordsStr } = useModel("wordsModel");
  18. const { show, title, status } = useModel("loadingModel");
  19. return (
  20. <Modal visible={show} backdropStyle={styles.backdrop}>
  21. {status === "loading" && (
  22. <Layout style={styles.loadingBox}>
  23. <Spinner size='giant' status='control' />
  24. <Text style={styles.text}>{getWordsStr("loading")}</Text>
  25. </Layout>
  26. )}
  27. {status == "success" && (
  28. <Layout style={styles.loadingBox}>
  29. <Icon style={styles.icon} name='checkmark' fill='#fff' />
  30. <Text style={styles.text}>{title}</Text>
  31. </Layout>
  32. )}
  33. {status == "warn" && (
  34. <Layout style={styles.warning}>
  35. <Text style={{ color: "#fff", textAlign: "center" }}>
  36. {title}
  37. </Text>
  38. </Layout>
  39. )}
  40. </Modal>
  41. );
  42. }
  43. const styles = StyleSheet.create({
  44. backdrop: {
  45. // backgroundColor: "rgba(0, 0, 0, 0.5)",
  46. },
  47. loadingBox: {
  48. width: 120,
  49. height: 120,
  50. borderRadius: 10,
  51. backgroundColor: "rgba(0,0,0,0.8)",
  52. alignItems: "center",
  53. justifyContent: "center",
  54. },
  55. text: {
  56. color: "#fff",
  57. marginTop: 10,
  58. },
  59. icon: {
  60. width: 60,
  61. height: 60,
  62. },
  63. warning: {
  64. paddingHorizontal: 15,
  65. paddingVertical: 5,
  66. backgroundColor: "rgba(0,0,0,0.8)",
  67. borderRadius: 3,
  68. marginHorizontal: 20,
  69. },
  70. });