Files
notesnook/apps/mobile/app/components/sheets/export-notes/share.js

56 lines
1.4 KiB
JavaScript
Raw Normal View History

2021-10-21 13:20:12 +05:00
import React from 'react';
2022-01-22 12:57:05 +05:00
import { View } from 'react-native';
2021-10-21 13:20:12 +05:00
import FileViewer from 'react-native-file-viewer';
import Share from 'react-native-share';
2022-02-28 23:25:18 +05:00
import { ToastEvent } from '../../../services/event-manager';
2022-02-28 15:32:55 +05:00
import { SIZE } from '../../../utils/size';
import { Button } from '../../ui/button';
2021-10-21 13:20:12 +05:00
2022-01-22 12:57:05 +05:00
export const ShareComponent = ({ uri, name, padding }) => {
2021-10-21 13:20:12 +05:00
return (
<View
style={{
paddingHorizontal: padding
2022-01-22 12:57:05 +05:00
}}
>
2021-10-21 13:20:12 +05:00
<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 () => {
2021-10-28 11:32:05 +05:00
FileViewer.open(uri, {
showOpenWithDialog: true,
showAppsSuggestions: true,
shareFile: true
2021-10-21 13:20:12 +05:00
}).catch(console.log);
}}
height={50}
/>
</View>
);
};