Advertisement
Guest User

Untitled

a guest
Apr 5th, 2017
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react';
  2. import { View, Text, Image, TouchableOpacity } from 'react-native';
  3. import { R } from '../../resources/';
  4.  
  5. class MainListItem extends React.Component {
  6.  
  7.     render() {
  8.         const { icon, title, enabled, onPress } = this.props.content;
  9.         const {
  10.             containerStyle,
  11.             labelTextStyle,
  12.             iconStyle,
  13.             dividerStyle
  14.         } = styles;
  15.         return (
  16.             <TouchableOpacity onPress={onPress}>
  17.                 <View style={containerStyle}>
  18.                     <Image source={icon} style={iconStyle} />
  19.                     <Text style={labelTextStyle}>{title}</Text>
  20.                     {this._renderAvailability(enabled)}
  21.                 </View>
  22.                 <View style={dividerStyle} />
  23.             </TouchableOpacity>
  24.         );
  25.     }
  26.  
  27.     // It renders the arrow or "Em breve" text
  28.     _renderAvailability(enabled) {
  29.         const {
  30.             arrowContainerStyle,
  31.             soonContainerStyle,
  32.             soonTextStyle
  33.         } = styles;
  34.         if (enabled) {
  35.             return (
  36.                 <View style={arrowContainerStyle}>
  37.                     <Image source={R.images.arrow} style={{ height: 20, width: 20 }} />
  38.                 </View>
  39.             );
  40.         }
  41.  
  42.         return (
  43.             <View style={soonContainerStyle}>
  44.                 <Text style={soonTextStyle}>EM BREVE</Text>
  45.             </View>
  46.         );
  47.     }
  48. }
  49.  
  50. const styles = {
  51.     containerStyle: {
  52.         alignSelf: 'stretch',
  53.         backgroundColor: '#fff',
  54.         flexDirection: 'row',
  55.         justifyContent: 'flex-start',
  56.         alignItems: 'center',
  57.         marginLeft: 50,
  58.         height: 60
  59.     },
  60.     labelTextStyle: {
  61.         fontSize: 16,
  62.         marginLeft: 20,
  63.         color: '#1762a6'
  64.     },
  65.     iconStyle: {
  66.         height: 32,
  67.         width: 32
  68.     },
  69.     arrowContainerStyle: {
  70.         flex: 1,
  71.         justifyContent: 'center',
  72.         alignItems: 'flex-end',
  73.         marginRight: 15
  74.     },
  75.     dividerStyle: {
  76.         alignSelf: 'stretch',
  77.         height: 1,
  78.         backgroundColor: '#efefef',
  79.         marginLeft: 50,
  80.     },
  81.     soonContainerStyle: {
  82.         flex: 1,
  83.         justifyContent: 'center',
  84.         alignItems: 'flex-end',
  85.         marginRight: 15
  86.     },
  87.     soonTextStyle: {
  88.         backgroundColor: '#fb435f',
  89.         fontSize: 12,
  90.         paddingLeft: 5,
  91.         paddingRight: 5,
  92.         color: '#fff'
  93.     }
  94. };
  95.  
  96. export default MainListItem;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement