mirror of
https://github.com/balzack/databag.git
synced 2025-02-14 12:39:17 +00:00
show copied message when asset copied
This commit is contained in:
parent
6b60098ff3
commit
acead8f30b
@ -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>
|
||||
|
@ -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,
|
||||
|
@ -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 });
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user