80 lines
2.1 KiB
TypeScript
80 lines
2.1 KiB
TypeScript
// Metro module 11816 (f11817).
|
|
import { useRef, useCallback, useEffect } from "react";
|
|
import { Modal, View } from "react-native";
|
|
import { createStyles } from "../../../design/components/Styles/native/createStyles";
|
|
import { ActivityIndicator } from "../../../design/components/ActivityIndicator/native/ActivityIndicator.native";
|
|
const useStyles = createStyles({
|
|
modalBackground: {
|
|
flex: 1,
|
|
alignItems: "center",
|
|
flexDirection: "column",
|
|
justifyContent: "center"
|
|
}
|
|
});
|
|
let c8103_7 = {
|
|
OPENING: 0,
|
|
0: "OPENING",
|
|
SHOWN: 1,
|
|
1: "SHOWN",
|
|
DISMISSED: 2,
|
|
2: "DISMISSED"
|
|
};
|
|
export default function SimpleLoadingModal(props) {
|
|
let c19193_2, c19193_3, c19193_4, ref, callback, callback2, callback3;
|
|
const { operation, onResolved = () => {} } = props;
|
|
let c19193_1 = onResolved;
|
|
let onRejected = props.onRejected;
|
|
if (onRejected === void 0) {
|
|
onRejected = () => {};
|
|
}
|
|
c19193_2 = onRejected;
|
|
let cancelable = props.cancelable;
|
|
if (cancelable === void 0) {
|
|
cancelable = false;
|
|
}
|
|
c19193_3 = cancelable;
|
|
let onDismissed = props.onDismissed;
|
|
if (onDismissed === void 0) {
|
|
onDismissed = () => {};
|
|
}
|
|
c19193_4 = onDismissed;
|
|
ref = void 0;
|
|
callback = void 0;
|
|
callback2 = void 0;
|
|
callback3 = void 0;
|
|
const styles = useStyles();
|
|
ref = useRef(c8103_7.OPENING);
|
|
callback = useCallback(() => {
|
|
if (ref.current === c8103_7.SHOWN) {
|
|
c19193_4();
|
|
}
|
|
ref.current = c8103_7.DISMISSED;
|
|
}, [onDismissed]);
|
|
callback2 = useCallback((a0) => {
|
|
c19193_1(a0);
|
|
callback();
|
|
}, [callback, onResolved]);
|
|
callback3 = useCallback((a0) => {
|
|
c19193_2(a0);
|
|
callback();
|
|
}, [callback, onRejected]);
|
|
useEffect(() => {
|
|
operation().then((result) => callback2(result)).catch((error) => callback3(error));
|
|
}, [operation, callback2, callback3]);
|
|
return <Modal transparent animationType="none" onShow={() => {
|
|
if (ref.current === c8103_7.DISMISSED) {
|
|
c19193_4();
|
|
} else {
|
|
ref.current = c8103_7.SHOWN;
|
|
}
|
|
}} onRequestClose={() => {
|
|
if (c19193_3) {
|
|
callback();
|
|
}
|
|
}}>
|
|
<View style={styles.modalBackground}>
|
|
<ActivityIndicator />
|
|
</View>
|
|
</Modal>;
|
|
};
|