Swih

Untitled

Mar 11th, 2021
602
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { useState } from 'react';
  2. import { StyleSheet, View, Text, Image, Switch} from 'react-native';
  3.  
  4. const items = [
  5.   {
  6.     id: 1,
  7.     name: 'Sneackers Smoosh',
  8.     price: 429,
  9.     imageURL: 'https://cdn.discordapp.com/attachments/749770267844280320/819587044409999400/Sneackers_3_1000x1000.png',
  10.   },
  11.   {
  12.     id:2,
  13.     name: 'Air force B8',
  14.     price: 395,
  15.     imageURL: 'https://cdn.discordapp.com/attachments/749770267844280320/819586862347845632/Sneackers_2_1000x1000.png',
  16.   },
  17.   {
  18.     id:3,
  19.     name: 'Spoon',
  20.     price: 1249,
  21.     imageURL: 'https://cdn.discordapp.com/attachments/749770267844280320/819586870429876284/Sneackers_4_000x1000.png',
  22.   },
  23.   {
  24.     id:4,
  25.     name: 'Yeezy Inesta 700',
  26.     price: 699,
  27.     imageURL: 'https://cdn.discordapp.com/attachments/749770267844280320/819586883461578833/Sneackers_1000x1000.png',
  28.   }
  29. ]
  30.  
  31. const styles = StyleSheet.create({
  32.   header: {
  33.     width: '100%',
  34.     height: '15%',
  35.     backgroundColor: '#eee',
  36.     alignItems: 'center',
  37.     justifyContent: 'center',
  38.   },
  39.  
  40.   container: {
  41.     flex: 1,
  42.     alignItems: 'center',
  43.   },
  44.  
  45.   box: {
  46.     width: '45%',
  47.     height: 300,
  48.     marginVertical: 5,
  49.     //borderRadius: 20,
  50.   },
  51.  
  52.   inner: {
  53.     flex: 1,
  54.     backgroundColor: '#eee',
  55.     //alignItems:'center',
  56.     //justifyContent:'center'
  57.     borderRadius: 10,
  58.   },
  59.  
  60.   containerbox: {
  61.     justifyContent: 'space-evenly',
  62.     flexDirection: 'row',
  63.     flexWrap: 'wrap',
  64.     marginTop: 10,
  65.   },
  66. });
  67.  
  68. const App = () => {
  69.     const [isEnabled, setIsEnabled] = useState(false);
  70.     const toggleSwitch = () => setIsEnabled(previousState => !previousState);
  71.  
  72.     return (
  73.       <View style={styles.container}>
  74.         <View style={styles.header}>
  75.           <Text>Snack Sneackers</Text>
  76.         </View>
  77.  
  78.         <View style={styles.containerbox}>
  79.           {items.map((item) => {
  80.             <View style={styles.box}>
  81.               <View style={styles.inner}>
  82.                 <Image
  83.                   style={{ height: 200, width: '100%', resizeMode: 'cover',borderTopLeftRadius: 10, borderTopRightRadius: 10}}
  84.                   source={{ uri: items.imageURL }}
  85.                 />
  86.                 <Text style={{ textAlign: 'left', padding: 5, }} >{items.name}- {items.price}</Text>
  87.                   <Switch
  88.                     style={{ marginTop: 20, marginRight: 5}}
  89.                     trackColor={{ false: "#767577", true: "#81b0ff" }}
  90.                     thumbColor={isEnabled ? "#fff" : "#fff"}
  91.                     ios_backgroundColor="#3e3e3e"
  92.                     onValueChange={toggleSwitch}
  93.                     value={isEnabled}
  94.                   />
  95.                 </View>
  96.               </View>
  97.           })}
  98.         </View>
  99.       </View>
  100.     );
  101.   }
  102.  
  103.   export default App;
Advertisement
Add Comment
Please, Sign In to add comment