show copied message when asset copied

This commit is contained in:
balzack 2023-08-13 22:28:56 -07:00
parent 6b60098ff3
commit acead8f30b
3 changed files with 19 additions and 2 deletions

View File

@ -48,6 +48,11 @@ export function BinaryAsset({ asset, dismiss }) {
{ state.downloading && (
<ActivityIndicator color={Colors.white} size="large" />
)}
<View style={styles.copied}>
{ state.copied && (
<Text style={styles.copiedText}>Copied to App Directory</Text>
)}
</View>
</View>
<Text style={styles.extension}>{ asset.extension }</Text>
</View>

View File

@ -26,6 +26,14 @@ export const styles = StyleSheet.create({
alignItems: 'center',
justifyContent: 'center',
},
copied: {
height: 32,
paddingTop: 8,
},
copiedText: {
color: Colors.white,
fontSize: 18,
},
extension: {
textAlign: 'center',
fontSize: 48,

View File

@ -12,6 +12,7 @@ export function useBinaryAsset() {
width: 1,
height: 1,
downloading: false,
copied: false,
});
const dimensions = useWindowDimensions();
@ -45,7 +46,8 @@ export function useBinaryAsset() {
src = blob.path();
}
if (Platform.OS === 'iOS') {
if (Platform.OS === 'ios') {
const path = `${RNFetchBlob.fs.dirs.DocumentDir}`
const dst = `${path}/${label}.${extension.toLowerCase()}`
if (RNFetchBlob.fs.exists(dst)) {
@ -61,8 +63,10 @@ export function useBinaryAsset() {
RNFetchBlob.fs.unlink(dst);
}
else {
const copy = RNFS.ExternalDirectoryPath + "/" label + "." + extension;
const copy = RNFS.ExternalDirectoryPath + "/" + label + "." + extension;
RNFS.copyFile(src, copy);
updateState({ copied: true });
setTimeout(() => updateState({ copied: false }), 2000);
}
updateState({ downloading: false });
}