mirror of
https://github.com/balzack/databag.git
synced 2025-02-14 20:49:16 +00:00
using share for android as well, local folder access not friendly
This commit is contained in:
parent
acead8f30b
commit
e496c75f47
@ -27,7 +27,7 @@ export function BinaryAsset({ asset, dismiss }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={{ ...styles.container, width: state.width, height: state.height }}>
|
<View style={{ ...styles.container, width: state.width, height: state.height }}>
|
||||||
<Text style={styles.label}>{ asset.label }</Text>
|
<Text style={styles.label} ellipsizeMode='tail' numberOfLines={1}>{ asset.label }</Text>
|
||||||
<TouchableOpacity style={styles.close} onPress={dismiss}>
|
<TouchableOpacity style={styles.close} onPress={dismiss}>
|
||||||
<MatIcons name="window-close" size={32} color={Colors.white} />
|
<MatIcons name="window-close" size={32} color={Colors.white} />
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
@ -48,11 +48,6 @@ export function BinaryAsset({ asset, dismiss }) {
|
|||||||
{ state.downloading && (
|
{ state.downloading && (
|
||||||
<ActivityIndicator color={Colors.white} size="large" />
|
<ActivityIndicator color={Colors.white} size="large" />
|
||||||
)}
|
)}
|
||||||
<View style={styles.copied}>
|
|
||||||
{ state.copied && (
|
|
||||||
<Text style={styles.copiedText}>Copied to App Directory</Text>
|
|
||||||
)}
|
|
||||||
</View>
|
|
||||||
</View>
|
</View>
|
||||||
<Text style={styles.extension}>{ asset.extension }</Text>
|
<Text style={styles.extension}>{ asset.extension }</Text>
|
||||||
</View>
|
</View>
|
||||||
|
@ -12,7 +12,6 @@ export function useBinaryAsset() {
|
|||||||
width: 1,
|
width: 1,
|
||||||
height: 1,
|
height: 1,
|
||||||
downloading: false,
|
downloading: false,
|
||||||
copied: false,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const dimensions = useWindowDimensions();
|
const dimensions = useWindowDimensions();
|
||||||
@ -46,28 +45,20 @@ export function useBinaryAsset() {
|
|||||||
src = blob.path();
|
src = blob.path();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Platform.OS === 'ios') {
|
const path = `${RNFetchBlob.fs.dirs.DocumentDir}`
|
||||||
|
const dst = `${path}/${label}.${extension.toLowerCase()}`
|
||||||
const path = `${RNFetchBlob.fs.dirs.DocumentDir}`
|
if (RNFetchBlob.fs.exists(dst)) {
|
||||||
const dst = `${path}/${label}.${extension.toLowerCase()}`
|
|
||||||
if (RNFetchBlob.fs.exists(dst)) {
|
|
||||||
RNFetchBlob.fs.unlink(dst);
|
|
||||||
}
|
|
||||||
await RNFetchBlob.fs.mv(src, dst);
|
|
||||||
try {
|
|
||||||
await Share.open({ url: dst })
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
console.log(err);
|
|
||||||
}
|
|
||||||
RNFetchBlob.fs.unlink(dst);
|
RNFetchBlob.fs.unlink(dst);
|
||||||
}
|
}
|
||||||
else {
|
await RNFetchBlob.fs.mv(src, dst);
|
||||||
const copy = RNFS.ExternalDirectoryPath + "/" + label + "." + extension;
|
try {
|
||||||
RNFS.copyFile(src, copy);
|
await Share.open({ url: `file://${dst}` })
|
||||||
updateState({ copied: true });
|
|
||||||
setTimeout(() => updateState({ copied: false }), 2000);
|
|
||||||
}
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
RNFetchBlob.fs.unlink(dst);
|
||||||
|
|
||||||
updateState({ downloading: false });
|
updateState({ downloading: false });
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
@ -8,7 +8,7 @@ export function BinaryThumb({ label, extension, onAssetView }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity activeOpacity={1} style={styles.canvas} onPress={onAssetView}>
|
<TouchableOpacity activeOpacity={1} style={styles.canvas} onPress={onAssetView}>
|
||||||
<Text style={styles.label}>{ label }</Text>
|
<Text style={styles.label} ellipsizeMode='tail' numberOfLines={1}>{ label }</Text>
|
||||||
<View style={styles.action}>
|
<View style={styles.action}>
|
||||||
<AntIcons name="download" size={28} color={Colors.white} />
|
<AntIcons name="download" size={28} color={Colors.white} />
|
||||||
</View>
|
</View>
|
||||||
|
@ -23,7 +23,7 @@ export const styles = StyleSheet.create({
|
|||||||
extension: {
|
extension: {
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontSize: 20,
|
fontSize: 18,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user