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

56 lines
1.4 KiB
JavaScript
Raw Normal View History

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/event-manager";
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) => {
2021-10-21 13:20:12 +05:00
ToastEvent.show({
heading: "Cannot open",
2021-10-21 13:20:12 +05:00
message: `No application found to open ${name} file.`,
type: "success",
context: "local"
2021-10-21 13:20:12 +05:00
});
});
}}
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>
);
};