-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp copy.js
114 lines (108 loc) · 2.81 KB
/
App copy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import { StatusBar } from "expo-status-bar";
import {
Button,
StyleSheet,
Text,
View,
Image,
Dimensions,
} from "react-native";
import { useEffect, useRef, useState } from "react";
import { Canvas, Circle, Group } from "@shopify/react-native-skia";
import { makeImageFromView } from "@shopify/react-native-skia";
import { captureRef } from "react-native-view-shot";
import ImagePickerExample from "./src/ImagePicker";
import Animated, { useSharedValue, withSpring } from "react-native-reanimated";
const HelloWorld = () => {
const size = 256;
const r = size * 0.33;
return (
<Canvas style={{ flex: 1 }}>
<Group blendMode="multiply">
<Circle cx={r} cy={r} r={r} color="cyan" />
<Circle cx={size - r} cy={r} r={r} color="magenta" />
<Circle cx={size / 2} cy={size - r} r={r} color="yellow" />
</Group>
</Canvas>
);
};
const Reanimated = () => {
const width = useSharedValue(100);
const increase = useRef(true);
const handlePress = () => {
console.log(increase.current);
let newValue = width.value;
if (increase.current) {
newValue += 100;
} else {
newValue -= 100;
}
width.value = withSpring(newValue);
increase.current = !increase.current;
};
return (
<View style={styles.container}>
<Animated.View style={{ ...styles.box, width }} />
<Button onPress={handlePress} title="Click me" />
</View>
);
};
export default function App() {
const viewRef = useRef(null);
const [snapshot, setSnapshot] = useState(null);
const takeSnapshot = async () => {
const data = await captureRef(viewRef);
console.log(data);
setSnapshot(data);
return;
if (viewRef.current == null) {
return;
}
// Take the snapshot of the view
const snapshot = await makeImageFromView(viewRef);
const image = snapshot.encodeToBytes()
console.log(snapshot);
};
return (
<>
<View
style={{
height: 200,
width: 200,
backgroundColor: "green",
}}
ref={viewRef}
></View>
<Button onPress={takeSnapshot} title="Screenshot" />
<View style={styles.container}>
{/* <Reanimated /> */}
<Image
source={{ uri: snapshot }}
style={{
width: 300,
height: 300,
}}
/>
<ImagePickerExample />
<Text>Open up App.js to start working on your app!</Text>
{/* <HelloWorld /> */}
</View>
</>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
width: Dimensions.get("screen").width,
height: Dimensions.get("screen").height,
// justifyContent: "center",
},
box: {
height: 100,
backgroundColor: "#b58df1",
borderRadius: 20,
marginVertical: 64,
},
});