using share for android as well, local folder access not friendly

This commit is contained in:
Roland Osborne 2023-08-14 13:55:41 -07:00
parent acead8f30b
commit e496c75f47
4 changed files with 14 additions and 28 deletions

View File

@ -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>

View File

@ -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) {

View File

@ -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>

View File

@ -23,7 +23,7 @@ export const styles = StyleSheet.create({
extension: {
textAlign: 'center',
color: Colors.white,
fontSize: 20,
fontSize: 18,
}
})