Copy and Paste  -   An Application to Copy/Paste Text  

 
S.No 5355 Name fire wood Date/Time 03-Nov-2022 10:10:49 AM

Copy text from below
import React, { useState } from 'react';
import {
  Text,
  View,
  Image,
  StyleSheet,
  TouchableOpacity,
} from 'react-native';

const CHOICES = [
  {
    name: 'WOOD',
    uri: 'https://i.ibb.co/TRjfP6w/istockphoto-106548715-612x612.jpg'
  },
  {
    name: 'WATER',
    uri: 'https://i.ibb.co/6HSds21/pexels-matthias-cooper-1147124.jpg'
  },
  {
    name: 'FIRE',
    uri: 'https://i.ibb.co/LdD1McC/download.jpg'
  },
];

const randomComputerChoice = () => CHOICES[Math.floor(Math.random() * CHOICES.length)];

const getRoundOutcome = (userChoice) => {
  const computerChoice = randomComputerChoice().name;
  let result;

  if (userChoice === 'WOOD') {
    result = computerChoice === 'WATER' ? 'Victory!' : 'Defeat!';
  };
  if (userChoice === 'WATER') {
    result = computerChoice === 'FIRE' ? 'Victory!' : 'Defeat!';
  };
  if (userChoice === 'FIRE') {
    result = computerChoice === 'FIRE' ? 'Victory!' : 'Defeat!';
  };

  if (userChoice === computerChoice) result = 'Tie game!';
  return [result, computerChoice];
};

const Button = (props) => (
  <TouchableOpacity
    style={styles.buttonStyle}
    onPress={() => props.onPress(props.name)}
  >
    <Text style={styles.buttonText}>
      {props.name.charAt(0).toUpperCase() + props.name.slice(1)}
    </Text>
  </TouchableOpacity>
);

const ChoiceCard = ({ player, choice: { uri, name }}) => {
  const title = name && name.charAt(0).toUpperCase() + name.slice(1);

  return (
    <View style={styles.choiceContainer}>
      <Text style={styles.choiceDescription}>
        {player}
      </Text>
      <Image
        source={{ uri }}
        resizeMode="contain"
        style={styles.choiceImage}
      />
      <Text style={styles.choiceCardTitle}>
        {title}
      </Text>
    </View>
  );
};

export default function App() {
  const [gamePrompt, setGamePrompt] = useState('Chose your weapon!');
  const [userChoice, setUserChoice] = useState({});
  const [computerChoice, setComputerChoice] = useState({});

  const onPress = (playerChoice) => {
    const [result, compChoice] = getRoundOutcome(playerChoice);
   
    const newUserChoice = CHOICES.find(choice => choice.name === playerChoice);
    const newComputerChoice = CHOICES.find(choice => choice.name === compChoice);

    setGamePrompt(result);
    setUserChoice(newUserChoice);
    setComputerChoice(newComputerChoice);
  };

  const getResultColor = () => {
    if (gamePrompt === 'Victory!') return 'green';
    if (gamePrompt === 'Defeat!') return 'red';
    return null;
  };

  return (
    <View style={styles.container}>
      <Text style={{ fontSize: 35, color: getResultColor() }}>
        {gamePrompt}
      </Text>
      <View style={styles.choicesContainer}>
        <ChoiceCard
          player="Player"
          choice={userChoice}
        />
        <Text style={{ color: 'green' }}>vs</Text>
        <ChoiceCard
          player="Computer"
          choice={computerChoice}
        />
      </View>
      {CHOICES.map(choice => {
        return (
          <Button
            key={choice.name}
            name={choice.name}
            onPress={onPress}
          />
        )
      })}
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
    backgroundColor: '#e9ebee'
  },
  buttonContainer: {
    alignItems: 'center',
    justifyContent: 'center',
  },
  buttonStyle: {
    width: 200,
    margin: 10,
    height: 50,
    borderRadius: 10,
    alignItems: 'center',
    justifyContent: 'center',
    backgroundColor: 'blue',
  },
  buttonText: {
    fontSize: 25,
    color: 'white',
    fontWeight: 'bold',
  },
  choicesContainer: {
    margin: 10,
    borderWidth: 2,
    paddingTop: 100,
    shadowRadius: 5,
    paddingBottom: 100,
    borderColor: 'grey',
    shadowOpacity: 0.90,
    flexDirection: 'row',
    alignItems: 'center',
    backgroundColor: 'white',
    justifyContent: 'space-around',
    shadowColor: 'rgba(0,0,0,0.2)',
    shadowOffset: { height: 5, width: 5 },
  },
  choiceContainer: {
    flex: 1,
    alignItems: 'center',
  },
  choiceDescription: {
&am




comments powered by Disqus
NEW ENTRIES
S.No Name Entry Time/Date
5718 code 29-May-2023 05:50:57 PM
5717 link 29-May-2023 04:39:14 PM
5716 K1d S3xy 29-May-2023 12:49:04 PM
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

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