mirror of
https://github.com/balzack/databag.git
synced 2025-02-14 12:39:17 +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 (
|
||||
<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}>
|
||||
<MatIcons name="window-close" size={32} color={Colors.white} />
|
||||
</TouchableOpacity>
|
||||
@ -48,11 +48,6 @@ 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>
|
||||
|
@ -12,7 +12,6 @@ export function useBinaryAsset() {
|
||||
width: 1,
|
||||
height: 1,
|
||||
downloading: false,
|
||||
copied: false,
|
||||
});
|
||||
|
||||
const dimensions = useWindowDimensions();
|
||||
@ -46,28 +45,20 @@ export function useBinaryAsset() {
|
||||
src = blob.path();
|
||||
}
|
||||
|
||||
if (Platform.OS === 'ios') {
|
||||
|
||||
const path = `${RNFetchBlob.fs.dirs.DocumentDir}`
|
||||
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);
|
||||
}
|
||||
const path = `${RNFetchBlob.fs.dirs.DocumentDir}`
|
||||
const dst = `${path}/${label}.${extension.toLowerCase()}`
|
||||
if (RNFetchBlob.fs.exists(dst)) {
|
||||
RNFetchBlob.fs.unlink(dst);
|
||||
}
|
||||
else {
|
||||
const copy = RNFS.ExternalDirectoryPath + "/" + label + "." + extension;
|
||||
RNFS.copyFile(src, copy);
|
||||
updateState({ copied: true });
|
||||
setTimeout(() => updateState({ copied: false }), 2000);
|
||||
await RNFetchBlob.fs.mv(src, dst);
|
||||
try {
|
||||
await Share.open({ url: `file://${dst}` })
|
||||
}
|
||||
catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
RNFetchBlob.fs.unlink(dst);
|
||||
|
||||
updateState({ downloading: false });
|
||||
}
|
||||
catch (err) {
|
||||
|
@ -8,7 +8,7 @@ export function BinaryThumb({ label, extension, onAssetView }) {
|
||||
|
||||
return (
|
||||
<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}>
|
||||
<AntIcons name="download" size={28} color={Colors.white} />
|
||||
</View>
|
||||
|
@ -23,7 +23,7 @@ export const styles = StyleSheet.create({
|
||||
extension: {
|
||||
textAlign: 'center',
|
||||
color: Colors.white,
|
||||
fontSize: 20,
|
||||
fontSize: 18,
|
||||
}
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user