Loading.js 1.9 KB

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