upd: modal loading saat open file

Deskripsi:
- dokumen divisi
- banner
- project
- kegiatan divisi

No Issues
This commit is contained in:
2025-07-21 18:07:45 +08:00
parent a7655b1cc0
commit 88dd6165f2
4 changed files with 29 additions and 5 deletions

View File

@@ -15,6 +15,7 @@ import AlertKonfirmasi from "../alertKonfirmasi";
import BorderBottomItem from "../borderBottomItem";
import DrawerBottom from "../drawerBottom";
import MenuItemRow from "../menuItemRow";
import ModalLoading from "../modalLoading";
import Skeleton from "../skeleton";
type Props = {
@@ -27,13 +28,14 @@ type Props = {
export default function SectionFileTask() {
const [isModal, setModal] = useState(false)
const { token, decryptToken } = useAuthSession()
const { detail } = useLocalSearchParams<{ detail: string }>();
const { detail } = useLocalSearchParams<{ detail: string }>()
const [data, setData] = useState<Props[]>([])
const update = useSelector((state: any) => state.taskUpdate)
const dispatch = useDispatch()
const [loading, setLoading] = useState(true)
const arrSkeleton = Array.from({ length: 5 })
const [selectFile, setSelectFile] = useState<Props | null>(null)
const [loadingOpen, setLoadingOpen] = useState(false)
async function handleLoad(loading: boolean) {
try {
@@ -57,6 +59,8 @@ export default function SectionFileTask() {
}, [])
const openFile = () => {
setModal(false)
setLoadingOpen(true)
let remoteUrl = 'https://wibu-storage.wibudev.com/api/files/' + selectFile?.idStorage;
const fileName = selectFile?.name + '.' + selectFile?.extension;
let localPath = `${FileSystem.documentDirectory}/${fileName}`;
@@ -65,7 +69,6 @@ export default function SectionFileTask() {
FileSystem.downloadAsync(remoteUrl, localPath).then(async ({ uri }) => {
const contentURL = await FileSystem.getContentUriAsync(uri);
try {
if (Platform.OS == 'android') {
// open with android intent
await startActivityAsync(
@@ -84,6 +87,8 @@ export default function SectionFileTask() {
}
} catch (error) {
Alert.alert('INFO', 'Gagal membuka file, tidak ada aplikasi yang dapat membuka file ini');
} finally {
setLoadingOpen(false)
}
});
};
@@ -109,6 +114,7 @@ export default function SectionFileTask() {
return (
<>
<ModalLoading isVisible={loadingOpen} setVisible={setLoadingOpen} />
<View style={[Styles.mb15]}>
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>File</Text>
<View style={[Styles.wrapPaper]}>