Advertisement
eri_qlue

Tukangs - Home (Menu)

Dec 17th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Home extends Component {
  2.   constructor(props) {
  3.     super(props);
  4.  
  5.     this.state = {
  6.       position: 1,
  7.       interval: null,
  8.       dataSource: [
  9.         `http://lorempixel.com/output/nature-q-c-640-480-1.jpg`,
  10.         `http://lorempixel.com/output/nature-q-c-640-480-2.jpg`,
  11.         `http://lorempixel.com/output/nature-q-c-640-480-3.jpg`,
  12.         `http://lorempixel.com/output/nature-q-c-640-480-5.jpg`,
  13.         `http://lorempixel.com/output/nature-q-c-640-480-6.jpg`,
  14.         `http://lorempixel.com/output/nature-q-c-640-480-7.jpg`,
  15.       ],
  16.     };
  17.   }
  18.  
  19.   componentWillMount() {
  20.     this.setState({interval: setInterval(() => {
  21.       this.setState({position: this.state.position === 6 ? 0 : this.state.position + 1});
  22.     }, 2000)});
  23.   }
  24.  
  25.   componentWillUnmount() {
  26.     clearInterval(this.state.interval);
  27.   }
  28.  
  29.   render() {
  30.     return (
  31.       <View style={styles.container}>
  32.         <Slideshow
  33.           images={this.state.dataSource}
  34.           position={this.state.position}
  35.           onPositionChanged={position => this.setState({position})}
  36.         />
  37.         <View style={styles.content}>
  38.           <TouchableOpacity onPress={onButtonPress}>
  39.             <Card containerStyle={styles.card} title="Air Conditioner">
  40.               <Image
  41.                 source={{ uri: 'http://spellfujiya.com/wp-content/uploads/2016/10/Ac.png' }}
  42.                 resizeMode="contain"
  43.                 style={styles.image}
  44.               />
  45.             </Card>
  46.           </TouchableOpacity>
  47.           <TouchableOpacity onPress={onButtonPress}>
  48.             <Card containerStyle={styles.card} title="Roofing">
  49.               <Image
  50.                 source={{ uri: 'https://cdn3.iconfinder.com/data/icons/handyman-1/305/service-serviceman-handyman-004-512.png' }}
  51.                 resizeMode="contain"
  52.                 style={styles.image}
  53.               />
  54.             </Card>
  55.           </TouchableOpacity>
  56.           <TouchableOpacity onPress={onButtonPress}>
  57.             <Card containerStyle={styles.card} title="Plumbing">
  58.               <Image
  59.                 source={{ uri: 'http://charlotte.trenchlesstechnologies.net/wp-content/uploads/2014/12/wrench-icon-300x300.png' }}
  60.                 resizeMode="contain"
  61.                 style={styles.image}
  62.               />
  63.             </Card>
  64.           </TouchableOpacity>
  65.           <TouchableOpacity onPress={onButtonPress}>
  66.             <Card containerStyle={styles.card} title="Electricity">
  67.               <Image
  68.                 source={{ uri: 'https://cdn3.iconfinder.com/data/icons/wsd-power/512/power-09-512.png' }}
  69.                 resizeMode="contain"
  70.                 style={styles.image}
  71.               />
  72.             </Card>
  73.           </TouchableOpacity>
  74.         </View>
  75.       </View>
  76.     );
  77.   }
  78. }
  79.  
  80. export default Home;
  81.  
  82. deskripsi :
  83. kode ini untuk menampilakn menu - menu
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement