-
Notifications
You must be signed in to change notification settings - Fork 6
/
App.js
66 lines (61 loc) · 1.49 KB
/
App.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
import React, {useRef} from 'react';
import {
findNodeHandle,
Platform,
Pressable,
StyleSheet,
UIManager,
View,
} from 'react-native';
import {CameraView} from './CameraView';
const App = () => {
const componentRef = useRef(null);
const dispatchCaptureCommand = () => {
Platform.OS === 'android'
? UIManager?.dispatchViewManagerCommand(
findNodeHandle(componentRef?.current),
UIManager?.RNCSTMCamera?.Commands?.captureImage?.toString(),
[findNodeHandle(componentRef?.current)],
)
: UIManager.dispatchViewManagerCommand(
findNodeHandle(componentRef?.current),
UIManager.getViewManagerConfig('RNCSTMCamera').Commands.captureImage,
[],
);
};
return (
<View style={styles.container}>
<CameraView ref={componentRef} style={styles.cameraView} />
<View style={styles.captureBtnContainer}>
<Pressable style={styles.captureBtn} onPress={dispatchCaptureCommand} />
</View>
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'white',
},
cameraView: {
flex: 1,
},
captureBtnContainer: {
backgroundColor: '#0006',
position: 'absolute',
bottom: 60,
alignSelf: 'center',
alignItems: 'center',
justifyContent: 'center',
height: 100,
width: 100,
borderRadius: 60,
},
captureBtn: {
height: 75,
width: 75,
borderRadius: 37.5,
backgroundColor: '#fff',
},
});
export default App;