Advertisement
Guest User

Menu drawer

a guest
May 9th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react';
  2. import { StyleSheet, Text, View, StatusBar, FlatList } from 'react-native';
  3. import Icon from 'react-native-ionicons';
  4. import {getSportMoment} from '../helper/calculation.js';
  5.  
  6. export default class Dashboard extends React.Component {
  7.     static navigationOptions = {
  8.         header: null,
  9.         drawerLabel: 'Dashboard',
  10.         drawerIcon: () => (
  11.             <Icon name="home" />
  12.         ),
  13.     };
  14.  
  15.     constructor() {
  16.         super();
  17.         this.state = {
  18.         }
  19.     }
  20.    
  21.     render() {
  22.         // calculation in Helper
  23.         var sportMoments = getSportMoment();
  24.        
  25.        
  26.  
  27.         return (
  28.             <View style={styles.container}>
  29.                 <StatusBar
  30.                     backgroundColor="#db0000"
  31.                     barStyle="light-content"
  32.                     hidden={false}
  33.                 />
  34.                 <View style={styles.toolBar}>
  35.                     <Icon name="menu" onPress={() => this.props.navigation.toggleDrawer()} style={styles.menuIcon} /><Text style={styles.toolbarText}>Dashboard</Text>
  36.                 </View>
  37.                 <FlatList style={styles.list}
  38.                     data={sportMoments}
  39.                     keyExtractor={item => item.id}
  40.                     renderItem={({ item }) => <View style={styles.sportItem}><View style={styles.sportItemIconWrapper}><Icon name="alarm" style={{color: '#000', fontSize: 40}} /></View><View><Text style={styles.momentTitle}>{item.moment.sport}</Text><Text style={styles.momentTime}>{item.moment.time} {item.id}</Text></View></View>}
  41.                 />
  42.             </View>
  43.         );
  44.     }
  45. }
  46.  
  47. const styles = StyleSheet.create({
  48.     container: {
  49.         flex: 1,
  50.         backgroundColor: '#fff',
  51.  
  52.     },
  53.     toolBar: {
  54.         height: 60,
  55.         backgroundColor: 'red',
  56.         flexDirection: 'row',
  57.     },
  58.     menuIcon: {
  59.         position: 'absolute',
  60.         left: 10,
  61.         top: 10,
  62.         color: 'white',
  63.         fontSize: 35,
  64.     },
  65.     toolbarText: {
  66.         position: 'absolute',
  67.         left: 55,
  68.         top: 5,
  69.         color: 'white',
  70.         fontSize: 30,
  71.     },
  72.     sportItem: {
  73.         marginTop: 5,
  74.         marginLeft: 3,
  75.         marginRight: 3,
  76.         paddingLeft: 5,
  77.         paddingRight: 5,
  78.         paddingBottom: 2,
  79.         borderWidth: 1 / 2,
  80.         borderLeftColor: 'red',
  81.         borderLeftWidth: 5,
  82.         flexDirection: 'row',
  83.     },
  84.     sportItemIconWrapper: {
  85.         marginTop: 6,
  86.         paddingRight: 10,
  87.     },
  88.     momentTitle: {
  89.         color: 'black',
  90.         fontSize: 25,
  91.     },
  92.     momentTime: {
  93.         fontSize: 15,
  94.     },
  95.  
  96. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement