|
@@ -0,0 +1,40 @@
|
|
1
|
+//@flow
|
|
2
|
+import React, { useState, useCallback } from 'react';
|
|
3
|
+import { SafeAreaView, Image, View } from 'react-native';
|
|
4
|
+import ViewShot from 'react-native-view-shot';
|
|
5
|
+import SvgUri from 'react-native-svg-uri';
|
|
6
|
+import Desc from './Desc';
|
|
7
|
+
|
|
8
|
+const OffscreenViewShot = ({ width, height, ...rest }) => (
|
|
9
|
+ <ViewShot {...rest} style={{ width, height, position: 'absolute', right: -width - 5 }} />
|
|
10
|
+);
|
|
11
|
+
|
|
12
|
+const SvgUriExample = () => {
|
|
13
|
+ const [source, setSource] = useState(null);
|
|
14
|
+ const onCapture = useCallback(uri => setSource({ uri }), []);
|
|
15
|
+
|
|
16
|
+ const width = 300;
|
|
17
|
+ const height = 300;
|
|
18
|
+
|
|
19
|
+ return (
|
|
20
|
+ <SafeAreaView>
|
|
21
|
+ <Desc desc="We have rendered this SVG as image offscreen:" />
|
|
22
|
+ <Image source={source} style={{ width, height }} />
|
|
23
|
+
|
|
24
|
+ <OffscreenViewShot
|
|
25
|
+ captureMode="continuous"
|
|
26
|
+ onCapture={onCapture}
|
|
27
|
+ width={width}
|
|
28
|
+ height={height}
|
|
29
|
+ >
|
|
30
|
+ <SvgUri width={200} height={200} source={require('./homer-simpson.svg')} />
|
|
31
|
+ </OffscreenViewShot>
|
|
32
|
+ </SafeAreaView>
|
|
33
|
+ );
|
|
34
|
+};
|
|
35
|
+
|
|
36
|
+SvgUriExample.navigationOptions = {
|
|
37
|
+ title: 'Offscreen',
|
|
38
|
+};
|
|
39
|
+
|
|
40
|
+export default SvgUriExample;
|