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
5876 Test 3 22-Dec-2023 11:04:29 AM
5875 hamza jadoon 21-Dec-2023 10:23:58 AM
5874 cam_expo 21-Dec-2023 10:13:11 AM
5873 camera code 21-Dec-2023 10:05:49 AM
5872 code 20-Dec-2023 10:38:07 AM
5871 Updated Kid 20-Dec-2023 07:09:59 AM
5870 Alpha 18-Dec-2023 10:52:22 PM
5869 code 07-Dec-2023 10:41:02 AM
5868 HMZ1 07-Dec-2023 08:50:55 AM
5867 HMZ 07-Dec-2023 08:41:31 AM
5866 Child New 05-Dec-2023 08:45:17 AM
5865 Danielle Simpson 29-Nov-2023 10:52:32 PM
5864 comp 28-Nov-2023 03:37:04 PM
5863 New Kids 27-Nov-2023 07:07:09 AM
5862 Jdh 24-Nov-2023 08:10:16 PM
5861 111 24-Nov-2023 03:02:22 PM
5860 modal 20-Nov-2023 03:02:57 PM
5859 omar 19-Nov-2023 04:27:23 PM
5858 ss 17-Nov-2023 05:14:03 PM
5857 ARCode 17-Nov-2023 02:55:42 PM
5856 Jarvo 17-Nov-2023 08:28:14 AM
5855 K1Ds Vids 17-Nov-2023 06:55:00 AM
5854 best 16-Nov-2023 07:07:10 PM
5853 matchsummary 16-Nov-2023 06:38:13 PM
5852 findindex 16-Nov-2023 06:30:48 PM
5851 loops 16-Nov-2023 05:44:20 PM
5850 sorting 16-Nov-2023 05:36:34 PM
5849 test 16-Nov-2023 05:06:51 PM
5848 New Sexy 16-Nov-2023 07:13:16 AM
5847 455555555 13-Nov-2023 02:52:30 PM

[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