Fakultas Ilmu Komputer UI

Commit 65a294db authored by wulanmantiri's avatar wulanmantiri
Browse files

[REFACTOR] Add toast for downloading files

parent 3a3a2623
import { PermissionsAndroid } from 'react-native';
import RNFetchBlob from 'rn-fetch-blob';
import { FileType } from './schema';
import Toast from 'react-native-toast-message';
const useDownloadFiles = (
url = '',
......@@ -22,13 +23,19 @@ const useDownloadFiles = (
return;
}
Toast.show({
type: 'success',
text1: `Mengunduh ${fileName}...`,
text2: 'Notifikasi akan muncul setelah unduh selesai. Mohon menunggu.',
});
const dirs = RNFetchBlob.fs.dirs;
RNFetchBlob.config({
addAndroidDownloads: {
useDownloadManager: true,
notification: true,
mime: fileType,
title: 'Mengunduh ' + title + '...',
title: title || fileName,
mediaScannable: true,
path: dirs.DownloadDir + `/${fileName}`,
},
......
......@@ -15,11 +15,7 @@ import { Props } from './types';
const ReadOnlyDietRecommendation: FC<Props> = ({ children, data }) => {
const url = API_BASE_URL + data?.client_plan_meal;
const { download, fileName } = useDownloadFiles(
url,
'rencana makan',
FileType.PDF,
);
const { download, fileName } = useDownloadFiles(url, '', FileType.PDF);
const hasValues = (obj: DietRecommendationResponse) =>
[obj.client_plan_meal, obj.nutritional_advice, obj.lifestyle_advice].reduce(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment