upd: modal loading saat open file
Deskripsi: - dokumen divisi - banner - project - kegiatan divisi No Issues
This commit is contained in:
@@ -4,6 +4,7 @@ import BorderBottomItem from "@/components/borderBottomItem"
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader"
|
||||
import DrawerBottom from "@/components/drawerBottom"
|
||||
import MenuItemRow from "@/components/menuItemRow"
|
||||
import ModalLoading from "@/components/modalLoading"
|
||||
import Styles from "@/constants/Styles"
|
||||
import { apiDeleteBanner, apiGetBanner } from "@/lib/api"
|
||||
import { setEntities } from "@/lib/bannerSlice"
|
||||
@@ -34,6 +35,7 @@ export default function BannerList() {
|
||||
const [selectFile, setSelectFile] = useState<Props | null>(null)
|
||||
const dispatch = useDispatch()
|
||||
const [refreshing, setRefreshing] = useState(false)
|
||||
const [loadingOpen, setLoadingOpen] = useState(false)
|
||||
|
||||
const handleDeleteEntity = async () => {
|
||||
try {
|
||||
@@ -66,6 +68,8 @@ export default function BannerList() {
|
||||
};
|
||||
|
||||
const openFile = () => {
|
||||
setModal(false)
|
||||
setLoadingOpen(true)
|
||||
let remoteUrl = 'https://wibu-storage.wibudev.com/api/files/' + selectFile?.image;
|
||||
const fileName = selectFile?.name + '.' + selectFile?.extension;
|
||||
let localPath = `${FileSystem.documentDirectory}/${fileName}`;
|
||||
@@ -93,6 +97,8 @@ export default function BannerList() {
|
||||
}
|
||||
} catch (error) {
|
||||
Alert.alert('INFO', 'Gagal membuka file, tidak ada aplikasi yang dapat membuka file ini');
|
||||
} finally {
|
||||
setLoadingOpen(false)
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -108,7 +114,7 @@ export default function BannerList() {
|
||||
headerRight: () => <HeaderRightBannerList />
|
||||
}}
|
||||
/>
|
||||
|
||||
<ModalLoading isVisible={loadingOpen} setVisible={setLoadingOpen} />
|
||||
<ScrollView
|
||||
refreshControl={
|
||||
<RefreshControl
|
||||
|
||||
@@ -8,6 +8,7 @@ import DrawerBottom from "@/components/drawerBottom";
|
||||
import { InputForm } from "@/components/inputForm";
|
||||
import MenuItemRow from "@/components/menuItemRow";
|
||||
import ModalFloat from "@/components/modalFloat";
|
||||
import ModalLoading from "@/components/modalLoading";
|
||||
import ModalSelectMultiple from "@/components/modalSelectMultiple";
|
||||
import Skeleton from "@/components/skeleton";
|
||||
import { ColorsStatus } from "@/constants/ColorsStatus";
|
||||
@@ -81,6 +82,7 @@ export default function DocumentDivision() {
|
||||
const arrSkeleton = Array.from({ length: 3 })
|
||||
const update = useSelector((state: any) => state.dokumenUpdate)
|
||||
const [refreshing, setRefreshing] = useState(false)
|
||||
const [loadingOpen, setLoadingOpen] = useState(false)
|
||||
const [bodyRename, setBodyRename] = useState({
|
||||
id: "",
|
||||
name: "",
|
||||
@@ -268,6 +270,7 @@ export default function DocumentDivision() {
|
||||
|
||||
|
||||
const openFile = (item: Props) => {
|
||||
setLoadingOpen(true)
|
||||
let remoteUrl = 'https://wibu-storage.wibudev.com/api/files/' + item.idStorage;
|
||||
const fileName = item.name + '.' + item.extension;
|
||||
let localPath = `${FileSystem.documentDirectory}/${fileName}`;
|
||||
@@ -276,7 +279,6 @@ export default function DocumentDivision() {
|
||||
FileSystem.downloadAsync(remoteUrl, localPath).then(async ({ uri }) => {
|
||||
const contentURL = await FileSystem.getContentUriAsync(uri);
|
||||
try {
|
||||
|
||||
if (Platform.OS == 'android') {
|
||||
// open with android intent
|
||||
await startActivityAsync(
|
||||
@@ -288,13 +290,15 @@ export default function DocumentDivision() {
|
||||
}
|
||||
);
|
||||
// or
|
||||
// Sharing.shareAsync(localPath);
|
||||
// Sharing.shareAsync(localPath);
|
||||
|
||||
} else if (Platform.OS == 'ios') {
|
||||
Sharing.shareAsync(localPath);
|
||||
}
|
||||
} catch (error) {
|
||||
Alert.alert('INFO', 'Gagal membuka file, tidak ada aplikasi yang dapat membuka file ini');
|
||||
} finally {
|
||||
setLoadingOpen(false)
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -345,6 +349,7 @@ export default function DocumentDivision() {
|
||||
),
|
||||
}}
|
||||
/>
|
||||
<ModalLoading isVisible={loadingOpen} setVisible={setLoadingOpen} />
|
||||
<ScrollView
|
||||
style={{ height: "100%" }}
|
||||
refreshControl={
|
||||
|
||||
Reference in New Issue
Block a user