Fakultas Ilmu Komputer UI
Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ppl-fasilkom-ui
2021
Kelas D
PT Gizi Sehat - Dietela
Dietela Mobile
Commits
65a294db
Commit
65a294db
authored
Jun 29, 2021
by
wulanmantiri
Browse files
[REFACTOR] Add toast for downloading files
parent
3a3a2623
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/hooks/useDownloadFiles/index.ts
View file @
65a294db
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
}
`
,
},
...
...
src/scenes/questionnaire/ReadOnlyDietRecommendation/index.tsx
View file @
65a294db
...
...
@@ -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
(
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment