From 5cf454c6800d6bfe26e08c6b4393b82bff442b4d Mon Sep 17 00:00:00 2001 From: Maksymilian Jopek Date: Thu, 3 Mar 2022 22:57:17 +0100 Subject: Initial commit - v1.0.0 --- components/PhotoBig.js | 104 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 components/PhotoBig.js (limited to 'components/PhotoBig.js') diff --git a/components/PhotoBig.js b/components/PhotoBig.js new file mode 100644 index 0000000..8f26b62 --- /dev/null +++ b/components/PhotoBig.js @@ -0,0 +1,104 @@ +import * as React from 'react'; +import { View, Text, StyleSheet, TouchableOpacity, Image, Dimensions, Alert } from 'react-native'; +// import * as ImageManipulator from "expo-image-manipulator"; +import * as MediaLibrary from "expo-media-library"; +import * as FileSystem from "expo-file-system"; +import { shareAsync } from 'expo-sharing'; + +import { getIp } from "./Settings" + +const w = Dimensions.get("window").width +const h = Dimensions.get("window").height + +export default class PhotoBig extends React.Component { + constructor(props) { + super(props) + this.state = {} + } + + async componentDidMount() { + } + + render() { + const src = this.props.route.params.source; + // (async () => console.log(await isAvailableAsync(), src.uri.replace(/storage\/.*?\//, '')))() + const share = async () => { + let assetUriParts = src.uri.split("/"); + let assetName = assetUriParts[assetUriParts.length - 1]; + let uri = `${FileSystem.documentDirectory}/${assetName}`; + console.log('uri', uri) + await FileSystem.copyAsync({ + from: src.uri, + to: uri, + }); + + // Share the image from the uri that you copied it to + await shareAsync(uri); + await FileSystem.deleteAsync(uri) + // shareAsync(src.uri, {}) + } + const remove = async () => { + await MediaLibrary.deleteAssetsAsync(this.props.route.params.id); + this.props.navigation.goBack(); + } + + const upload = async () => { + const uri = this.props.route.params.source.uri; + const body = new FormData(); + body.append('photo', { + uri: uri, + type: 'image/jpeg', + name: uri.split('/').pop(), + }); + + console.log(body) + const url = await getIp() + "/upload" + await fetch(url, { + method: "POST", + body + }).catch(e => console.log(e, url)) + Alert.alert("Alert", "Galllery - file uploaded and saved!"); + } + return ( + + + + {/* } style={{ flex: 1 }}>SHARE */} + SHARE + DELETE + UPLOAD + + + ) + } +} + +const styles = StyleSheet.create({ + cont: { + flexDirection: "column", + paddingTop: 20, + backgroundColor: "black", + // backgroundColor: "#EB1F63", + justifyContent: "center", + alignItems: "center", + height: "100%", + }, + img: { + width: w * 0.9, + height: h * 0.65, + borderRadius: 15, + }, + h1: { + color: "white", + fontSize: w / 15, + fontWeight: "bold", + }, + txts: { + flex: 1, + flexDirection: "row", + justifyContent: "center", + alignItems: "center", + marginLeft: w / 15, + }, +}) + -- cgit v1.3.1