Add custom image loader and start job status.
This commit is contained in:
43
components/job-documents/image-loader.jsx
Normal file
43
components/job-documents/image-loader.jsx
Normal file
@@ -0,0 +1,43 @@
|
||||
import { useMemo, useState } from "react";
|
||||
import { Image } from "react-native";
|
||||
import { ActivityIndicator } from "react-native-paper";
|
||||
|
||||
const ImageLoader = ({ style, source, ...props }) => {
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
const handleLoadStart = () => {
|
||||
setLoading(true);
|
||||
};
|
||||
|
||||
const handleLoadEnd = () => {
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
const handleLoad = () => {
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
const memorizedImage = useMemo(
|
||||
() => (
|
||||
<Image
|
||||
{...props}
|
||||
style={style}
|
||||
source={source}
|
||||
//onLoadStart={handleLoadStart}
|
||||
onLoadEnd={handleLoadEnd}
|
||||
onLoad={handleLoad}
|
||||
/>
|
||||
),
|
||||
[source]
|
||||
);
|
||||
if (loading)
|
||||
return (
|
||||
<>
|
||||
<ActivityIndicator style={{ ...style, position: "absolute" }} />
|
||||
{memorizedImage}
|
||||
</>
|
||||
);
|
||||
return memorizedImage;
|
||||
};
|
||||
|
||||
export default ImageLoader;
|
||||
Reference in New Issue
Block a user