railbird-gql/component/video/capture-button.tsx

45 lines
1.1 KiB
TypeScript

import React from 'react';
import { TouchableOpacity, StyleSheet } from 'react-native';
export const RecordingButton = ({ style, camera, onMediaCaptured, enabled, setIsPressingButton }) => {
const handlePressIn = () => {
setIsPressingButton(true);
// Additional functionality when the button is pressed
console.log('pressed in')
};
const handlePressOut = () => {
setIsPressingButton(false);
// Stop recording and handle media capture
if (camera && enabled) {
// Assuming you have a method in your camera object to capture media
const media = camera.captureMedia();
if (onMediaCaptured) {
onMediaCaptured(media);
}
}
};
return (
<TouchableOpacity
style={[styles.captureButton, style]}
onPressIn={handlePressIn}
onPressOut={handlePressOut}
disabled={!enabled}
/>
);
};
const styles = StyleSheet.create({
captureButton: {
height: 70,
width: 70,
borderRadius: 35,
backgroundColor: '#FF3B30',
justifyContent: 'center',
alignItems: 'center',
},
});
export default RecordingButton;