Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.07 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import {
  3. StyleSheet,
  4. View,
  5. FlatList,
  6. Text,
  7. Platform,
  8. Alert,
  9. } from 'react-native';
  10. import { Container,Header,Left,Right,Icon, Title, Body } from 'native-base';
  11. import GlobalStyle from '../component/style/GlobalStyle';
  12. import ScheduleListRow from '../component/ScheduleListRow';
  13. import Button from '../component/common/Button';
  14.  
  15. class ScheduleScreen extends Component{
  16. constructor(props) {
  17. super(props);
  18. this.state = {
  19. scheduleData : [
  20. {
  21. dateTrans : 'April 22, 2019',
  22. scheduleContent : [
  23. {
  24. name : 'Andika',
  25. description : 'Meeting 16:30',
  26. },
  27. {
  28. name : 'BI Team',
  29. description : 'Meeting 19:30',
  30. },
  31. ]
  32. },
  33. ]
  34.  
  35. // scheduleData : [
  36. // {
  37. // name : 'Andika',
  38. // description : 'Meeting 16:30',
  39. // },
  40. // {
  41. // name : 'BI Team',
  42. // description : 'Meeting 19:30',
  43. // },
  44. // ]
  45. };
  46. }
  47.  
  48. _keyApprovalExtractor = (item, index) => item.scheduleContent.name;
  49. _renderItem = ({item, scheduleContent}) => (
  50. <ScheduleListRow
  51. xDateTrans={item.dateTrans}
  52. xName={item.scheduleContent.name}
  53. xDescription={item.scheduleContent.description}
  54. onPressItem={this._onPressItem}
  55. />
  56. );
  57.  
  58. _onPressItem = (name) => {
  59. Alert.alert(name);
  60. };
  61.  
  62. render(){
  63. return(
  64. <Container>
  65. <Header style={{ backgroundColor: 'white' }}>
  66. <Left style={{ flexDirection: 'row'}}>
  67. <Icon onPress={() => this.props.navigation.openDrawer()} name="md-menu" style={{ color: 'black', marginRight: 15 }} />
  68. </Left>
  69. <Body>
  70. <Title style={{color:'black'}}>Schedule</Title>
  71. </Body>
  72. <Right>
  73. <Icon name="ios-arrow-down" style={{ color: 'black'}} />
  74. </Right>
  75. </Header>
  76. <View style={styles.container}>
  77. <FlatList
  78. style={GlobalStyle.listContainer}
  79. data={this.state.scheduleData}
  80. renderItem={this._renderItem}
  81. keyExtractor={this._keyApprovalExtractor}
  82. />
  83. <View style={styles.bottomContainer}>
  84. <Button>NEW SCHEDULE</Button>
  85. </View>
  86. </View>
  87. </Container>
  88. );
  89. }
  90. }
  91.  
  92. const styles = StyleSheet.create({
  93. container : {
  94. flex: 1,
  95. flexDirection : 'column',
  96. backgroundColor:'#FFFFFF',
  97. },
  98. dateText : {
  99. marginTop : Platform.OS === 'ios' ? 8 : 0,
  100. padding : 5,
  101. fontSize:14,
  102. color:'#000000'
  103. },
  104. bottomContainer : {
  105. justifyContent : "flex-end",
  106. alignItems : "center",
  107. marginBottom : 10
  108. }
  109. });
  110.  
  111.  
  112. export default ScheduleScreen;
  113.  
  114.  
  115. ===================================================
  116.  
  117. import React, { Component } from 'react';
  118. import { View, Text, StyleSheet, Image, TouchableOpacity } from 'react-native';
  119. import Card from './common/Card';
  120. import CardSection from './common/CardSection';
  121.  
  122.  
  123. class ScheduleListRow extends Component{
  124. _onPress = () => {
  125. this.props.onPressItem(this.props.xName);
  126. };
  127.  
  128. _dateTrans = () => {
  129. if(this.props.xDateTrans !== null){
  130. return(
  131. <Text style={styles.titleText}>{this.props.xDateTrans}</Text>
  132. );
  133. }
  134. };
  135.  
  136. render(){
  137. return(
  138. <TouchableOpacity onPress={this._onPress}
  139. style={styles.container}>
  140. <Text style={styles.titleText}>{this.props.xDateTrans}</Text>
  141. <Card>
  142. <CardSection>
  143. <View style={styles.subContainer}>
  144. <Image style={styles.photo}
  145. source={require('../images/ic_main_user.png')}/>
  146. <View style={styles.subContainer2}>
  147. <Text style={styles.titleText}>{this.props.xName}</Text>
  148. <Text style={styles.text}>{this.props.xDescription}</Text>
  149. </View>
  150. </View>
  151. </CardSection>
  152. </Card>
  153. </TouchableOpacity>
  154. );
  155. }
  156. }
  157.  
  158. const styles = StyleSheet.create({
  159. container: {
  160. flexDirection: 'column',
  161. flex : 1
  162. },
  163. subContainer : {
  164. flex : 1,
  165. flexDirection : 'row',
  166. },
  167. subContainer2 : {
  168. flex : 1,
  169. flexDirection : 'column',
  170. justifyContent : 'flex-start',
  171. alignItems: 'flex-start',
  172. marginBottom: 5,
  173. },
  174. titleText: {
  175. marginLeft: 20,
  176. marginTop: 2,
  177. fontSize:18,
  178. fontWeight : 'bold',
  179. color:'#000000',
  180. },
  181. text: {
  182. marginLeft: 20,
  183. marginTop: 2,
  184. fontSize:15,
  185. marginBottom : 5,
  186. color:'#000000',
  187. },
  188. photo: {
  189. marginLeft : 5,
  190. marginTop : 8,
  191. width:40,
  192. height: 40,
  193. },
  194. });
  195.  
  196. export default ScheduleListRow;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement