Copy and Paste  -   An Application to Copy/Paste Text  

 
S.No 5874 Name cam_expo Date/Time 21-Dec-2023 10:13:11 AM

Copy text from below
import React, { useEffect, useRef, useState } from 'react';
import { Text, View, StyleSheet, TouchableOpacity, Platform } from 'react-native';
import { Camera } from 'expo-camera';
import * as MediaLibrary from 'expo-media-library';

const App = () => {
const [cameraType, setCameraType] = useState(Camera.Constants.Type.back);
const [recordingStatus, setRecordingStatus] = useState(false);
const cameraRef = useRef(null);

useEffect(() => {
(async () => {
const { status:camera } = await Camera.requestCameraPermissionsAsync();
if (camera !== 'granted') {
alert('Camera permission not granted');
}
const { status:audio } = await Camera.requestMicrophonePermissionsAsync();
if (audio !== 'granted') {
alert('audio permission not granted');
}
})();
}, []);

const flipCamera = () => {
setCameraType(
cameraType === Camera.Constants.Type.back
? Camera.Constants.Type.front
: Camera.Constants.Type.back
);
};

const takePhoto = async () => {
if (cameraRef.current) {
const photo = await cameraRef.current.takePictureAsync();

if (Platform.OS === 'android' || Platform.OS === 'ios') {
await MediaLibrary.saveToLibraryAsync(photo.uri);
} else {
console.log('Saving to library not supported on this platform.');
}
}
};

const startRecording = async () => {
setRecordingStatus(true);
if (cameraRef.current) {
const video = await cameraRef.current.recordAsync();

if (Platform.OS === 'android' || Platform.OS === 'ios') {
await MediaLibrary.saveToLibraryAsync(video.uri);
} else {
console.warn('Saving to library not supported on this platform.');
}
}
};

const stopRecording = async () => {
setRecordingStatus(false);
if (cameraRef.current) {
cameraRef.current.stopRecording();
}
};

return (
<View style={styles.container}>
<Camera style={styles.camera} type={cameraType} ref={cameraRef} />

<View style={styles.controls}>
<TouchableOpacity style={styles.button} onPress={flipCamera}>
<Text style={styles.buttonText}>Flip</Text>
</TouchableOpacity>

<TouchableOpacity style={styles.button} onPress={takePhoto}>
<Text style={styles.buttonText}>Photo</Text>
</TouchableOpacity>

<TouchableOpacity
style={[
styles.button,
{ backgroundColor: recordingStatus ? 'red' : '#DDDDDD' },
]}
onPress={() => (recordingStatus ? stopRecording() : startRecording())}
>
<Text style={styles.buttonText}>
{recordingStatus ? 'Stop Recording' : 'Start Recording'}
</Text>
</TouchableOpacity>
</View>
</View>
);
};

const styles = StyleSheet.create({
container: {
flex: 1,
},
camera: {
flex: 0.9,
},
controls: {
flex: 0.1,
flexDirection: 'row',
backgroundColor: 'grey',
justifyContent: 'space-around',
alignItems: 'center',
},
button: {
alignItems: 'center',
padding: 15,
margin: 5,
},
buttonText: {
fontSize: 20,
fontWeight: 'bold',
},
});

export default App;




comments powered by Disqus
NEW ENTRIES
S.No Name Entry Time/Date
5845 New Kids 04-Nov-2023 06:45:51 AM
5844 BMP 31-Oct-2023 06:41:06 PM
5843 ab 29-Oct-2023 08:51:02 PM
5842 a 29-Oct-2023 08:44:33 PM
5841 c++ program 29-Oct-2023 08:42:28 PM
5840 Child Vids 26-Oct-2023 07:07:04 AM
5839 23-Oct-2023 08:11:25 PM
5838 22-Oct-2023 06:29:37 PM
5837 Organic Loom 17-Oct-2023 07:02:03 PM
5836 Test 1 17-Oct-2023 11:16:30 AM
5835 PAF-IAST MET 17-Oct-2023 11:15:49 AM
5834 for jazz 16-Oct-2023 09:26:26 PM
5833 New Kid 16-Oct-2023 07:08:13 AM
5832 test 12-Oct-2023 10:38:09 AM
5831 a 12-Oct-2023 10:28:26 AM
5830 75 Videos 12-Oct-2023 09:32:23 AM
5829 11-Oct-2023 05:45:55 PM
5828 q44 10-Oct-2023 05:47:12 PM
5827 q4 10-Oct-2023 05:40:56 PM
5826 jflex q3 10-Oct-2023 05:37:43 PM
5825 q3 10-Oct-2023 05:33:13 PM
5824 q2 10-Oct-2023 05:32:15 PM
5823 jflex 10-Oct-2023 05:30:32 PM
5822 dddd 10-Oct-2023 04:41:21 PM
5821 nn 09-Oct-2023 11:55:27 AM
5820 Jarvo 09-Oct-2023 11:44:19 AM
5819 NEW CHILD 07-Oct-2023 11:16:57 AM
5818 05-Oct-2023 06:32:33 PM
5817 LandscapeLay 05-Oct-2023 11:42:00 AM
5813 responsive 02-Oct-2023 11:44:41 AM

[First] [Prev] 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 [Next] [Last]
 
web counter
web counter


To report any error messages or bugs, or other issues, please send email at: info@pakproject.com