2022-08-26 16:19:39 +05:00
|
|
|
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
|
2022-08-26 16:19:39 +05:00
|
|
|
}).catch((e) => {
|
2021-10-21 13:20:12 +05:00
|
|
|
ToastEvent.show({
|
2022-08-26 16:19:39 +05:00
|
|
|
heading: "Cannot open",
|
2021-10-21 13:20:12 +05:00
|
|
|
message: `No application found to open ${name} file.`,
|
2022-08-26 16:19:39 +05:00
|
|
|
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>
|
|
|
|
|
);
|
|
|
|
|
};
|