Copy and Paste  -   An Application to Copy/Paste Text  

 
S.No 5872 Name code Date/Time 20-Dec-2023 10:38:07 AM

Copy text from below

import React, { useState, useRef } from 'react';

import { StyleSheet, Text, View, TouchableOpacity } from 'react-native';

import { Camera } from 'expo-camera';

import { Video } from 'expo-av';

 

export default function App() {

  const [hasPermission, setHasPermission] = useState(null);

  const [cameraType, setCameraType] = useState(Camera.Constants.Type.back);

  const [isRecording, setIsRecording] = useState(false);

  const cameraRef = useRef(null);

  const videoRef = useRef(null);

 

  const startRecord = async () => {

    if (cameraRef.current) {

      try {

        const { uri } = await cameraRef.current.recordAsync();

        console.log('Recording started:', uri);

        setIsRecording(true);

      } catch (error) {

        console.error('Error starting recording:', error);

      }

    }

  };

 

  const stopRecord = async () => {

    if (cameraRef.current) {

      try {

        const { uri } = await cameraRef.current.stopRecording();

        console.log('Recording stopped:', uri);

        setIsRecording(false);

      } catch (error) {

        console.error('Error stopping recording:', error);

      }

    }

  };

 

  const takePicture = async () => {

    if (cameraRef.current) {

      try {

        const { uri } = await cameraRef.current.takePictureAsync();

        console.log('Picture taken:', uri);

      } catch (error) {

        console.error('Error taking picture:', error);

      }

    }

  };

 

  const switchCamera = () => {

    setCameraType(

      cameraType === Camera.Constants.Type.back

        ? Camera.Constants.Type.front

        : Camera.Constants.Type.back

    );

  };

 

  const onCameraPermission = async () => {

    const { status } = await Camera.requestPermissionsAsync();

    setHasPermission(status === 'granted');

  };

 

  if (hasPermission === null) {

    return <View />;

  }

 

  if (hasPermission === false) {

    return <Text>No access to camera</Text>;

  }

 

  return (

    <View style={styles.container}>

      <Camera

        style={styles.camera}

        type={cameraType}

        ref={cameraRef}

        onCameraReady={() => console.log('Camera ready')}

      >

        <View style={styles.controls}>

          <TouchableOpacity

            style={styles.button}

            onPress={isRecording ? stopRecord : startRecord}

          >

            <Text style={styles.text}>{isRecording ? 'Stop' : 'Record'}</Text>

          </TouchableOpacity>

          <TouchableOpacity style={styles.button} onPress={takePicture}>

            <Text style={styles.text}>Take Picture</Text>

          </TouchableOpacity>

          <TouchableOpacity style={styles.button} onPress={switchCamera}>

            <Text style={styles.text}>Switch Camera</Text>

          </TouchableOpacity>

        </View>

      </Camera>

      {isRecording && (

        <Video

          ref={videoRef}

          style={styles.videoPreview}

          source={{ uri: 'http://d23dyxeqlo5psv.cloudfront.net/big_buck_bunny.mp4' }}

          useNativeControls

        />

      )}

    </View>

  );

}

 

const styles = StyleSheet.create({

  container: {

    flex: 1,

  },

  camera: {

    flex: 1,

  },

  controls: {

    flex: 1,

    flexDirection: 'row',

    justifyContent: 'center',

    alignItems: 'flex-end',

    marginBottom: 20,

  },

  button: {

    backgroundColor: 'white',

    borderRadius: 5,

    padding: 15,

    marginHorizontal: 10,

  },

  text: {

    fontSize: 16,

  },

  videoPreview: {

    flex: 1,

    position: 'absolute',

    top: 0,

    left: 0,

    right: 0,

    bottom: 0,

  },

});

 





comments powered by Disqus
NEW ENTRIES
S.No Name Entry Time/Date
5715 code 29-May-2023 10:13:03 AM
5714 Fresh links 29-May-2023 10:08:48 AM
5713 processing 29-May-2023 10:07:23 AM
5712 kos kona 29-May-2023 10:05:49 AM
5711 Abc 24-May-2023 03:28:32 PM
5710 S3xy Movie 24-May-2023 07:45:57 AM
5709 C 23-May-2023 08:29:51 AM
5708 qs 23-May-2023 08:24:49 AM
5707 nnnn 23-May-2023 08:15:38 AM
5706 MiD 23-May-2023 12:47:37 AM
5705 . 22-May-2023 11:08:37 PM
5704 ghhascshgcvs 22-May-2023 05:00:15 PM
5703 StudentDashb 22-May-2023 04:42:27 PM
5702 LoginScreen 22-May-2023 04:41:22 PM
5701 app.js 22-May-2023 04:40:43 PM
5700 Code 22-May-2023 03:55:14 PM
5699 Child Video3 19-May-2023 11:39:31 AM
5698 . 18-May-2023 09:48:52 PM
5697 . 18-May-2023 04:03:47 PM
5696 Child Video2 11-May-2023 08:00:11 AM
5695 Child Videos 05-May-2023 07:58:35 AM
5694 MET May 3 03-May-2023 11:15:13 AM
5693 Asfand Leaks 02-May-2023 09:18:28 AM
5692 bikmangiya 02-May-2023 09:17:04 AM
5691 kk 30-Apr-2023 12:11:31 AM
5690 Yasir 29-Apr-2023 01:32:17 AM
5689 lll 27-Apr-2023 08:39:14 PM
5688 Gg 27-Apr-2023 08:31:28 PM
5687 More 4 You 27-Apr-2023 12:55:44 PM
5686 Elif Yener 26-Apr-2023 03:51:34 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