mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-21 14:09:34 +01:00
53 lines
1.3 KiB
JavaScript
53 lines
1.3 KiB
JavaScript
|
|
import React from 'react';
|
||
|
|
import {View} from 'react-native';
|
||
|
|
import FileViewer from 'react-native-file-viewer';
|
||
|
|
import Share from 'react-native-share';
|
||
|
|
import {ToastEvent} from '../../services/EventManager';
|
||
|
|
import {SIZE} from '../../utils/SizeUtils';
|
||
|
|
import {Button} from '../Button';
|
||
|
|
|
||
|
|
export const ShareComponent = ({uri, name, padding}) => {
|
||
|
|
return (
|
||
|
|
<View
|
||
|
|
style={{
|
||
|
|
paddingHorizontal: padding
|
||
|
|
}}>
|
||
|
|
<Button
|
||
|
|
title="Open"
|
||
|
|
type="accent"
|
||
|
|
width="100%"
|
||
|
|
fontSize={SIZE.md}
|
||
|
|
onPress={async () => {
|
||
|
|
FileViewer.open(uri, {
|
||
|
|
showOpenWithDialog: true,
|
||
|
|
showAppsSuggestions: true
|
||
|
|
}).catch(e => {
|
||
|
|
ToastEvent.show({
|
||
|
|
heading: 'Cannot open',
|
||
|
|
message: `No application found to open ${name} file.`,
|
||
|
|
type: 'success',
|
||
|
|
context: 'local'
|
||
|
|
});
|
||
|
|
});
|
||
|
|
}}
|
||
|
|
height={50}
|
||
|
|
/>
|
||
|
|
<Button
|
||
|
|
title="Share"
|
||
|
|
type="shade"
|
||
|
|
width="100%"
|
||
|
|
fontSize={SIZE.md}
|
||
|
|
style={{
|
||
|
|
marginTop: 10
|
||
|
|
}}
|
||
|
|
onPress={async () => {
|
||
|
|
Share.open({
|
||
|
|
url: uri
|
||
|
|
}).catch(console.log);
|
||
|
|
}}
|
||
|
|
height={50}
|
||
|
|
/>
|
||
|
|
</View>
|
||
|
|
);
|
||
|
|
};
|