Skip to content

Commit

Permalink
using share for android as well, local folder access not friendly
Browse files Browse the repository at this point in the history
  • Loading branch information
balzack committed Aug 14, 2023
1 parent acead8f commit e496c75
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export function useBinaryAsset() {
width: 1,
height: 1,
downloading: false,
copied: false,
});

const dimensions = useWindowDimensions();
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const styles = StyleSheet.create({
extension: {
textAlign: 'center',
color: Colors.white,
fontSize: 20,
fontSize: 18,
}
})

0 comments on commit e496c75

Please sign in to comment.