Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.11 KB | None | 0 0
  1. import React, {Component} from 'react';
  2. import {StyleSheet, Text, View, ScrollView, TouchableOpacity, Alert} from "react-native";
  3. import {Tabs, Tab, Button,} from 'native-base';
  4.  
  5. import {connect} from "react-redux";
  6. import * as actions from "../../store/actions";
  7.  
  8. import DefaultTracks from "./DefaultTracks";
  9. import PersonalTracks from "./PersonalTracks";
  10. import HeaderMenu from "../HeaderMenu";
  11. import EditTracks from "./EditTracks";
  12.  
  13. const Icons = createIconSetFromFontello(fontelloConfig);
  14.  
  15.  
  16. import {createIconSetFromFontello} from 'react-native-vector-icons';
  17. import fontelloConfig from '../../../config.json';
  18.  
  19.  
  20. import PouchDB from 'pouchdb-react-native';
  21. import FeedBack from "../Feedback";
  22.  
  23. const localDB = PouchDB('iloveaveiro');
  24.  
  25. class TracksList extends Component {
  26. state = {
  27. tracks: []
  28. };
  29.  
  30. render() {
  31. let {userData} = this.props;
  32. return (
  33. <View style={{flex: 1}}>
  34. <View>
  35. <HeaderMenu name='Trajetos' navigation={this.props.navigation}/>
  36. </View>
  37. <View style={styles.container}>
  38. <View
  39. style={{
  40. flex: 1,
  41. flexDirection: 'row',
  42. marginBottom: 40,
  43. marginTop: 20,
  44. textAlign: 'center'
  45. }}
  46. >
  47.  
  48. <Tabs tabBarUnderlineStyle={{backgroundColor: 'orange'}} tabContainerStyle={{elevation: 0}}>
  49. <Tab
  50. tabStyle={{backgroundColor: "white"}}
  51. activeTabStyle={{backgroundColor: "white"}}
  52. activeTextStyle={{color: 'orange'}}
  53. textStyle={{color: 'grey'}}
  54. heading="Predefinidos"
  55. >
  56. <View style={{width: '100%', height: '100%', marginTop: 5}}>
  57. <View style={{position: 'absolute', top: 0, right: 10, zIndex: 99}}>
  58. <Button transparent rounded onPress={() => {
  59. Alert.alert("KJASLDASOIDAS")
  60. }}>
  61. <Icons name="filtros" size={70} style={{color: "orange"}} />
  62. </Button>
  63. </View>
  64. <ScrollView>
  65. {this.props.tracks.length !== 0 ? (
  66. this._setContent(this.props.tracks)
  67. ) : (
  68. <Text>There are no tracks available</Text>
  69. )}
  70. </ScrollView>
  71.  
  72. </View>
  73.  
  74. </Tab>
  75. <Tab
  76. tabStyle={{backgroundColor: 'white'}}
  77. activeTabStyle={{backgroundColor: "white"}}
  78. activeTextStyle={{color: 'orange'}}
  79. textStyle={{color: 'grey'}}
  80. heading="Meus trajetos"
  81. >
  82. <View style={{width: '100%', marginTop: 20}}>
  83. <ScrollView>
  84. {userData ? <View style={{position: 'absolute', top: 0, right: 10, zIndex: 99}}>
  85. <Button transparent rounded onPress={() => {
  86. Alert.alert("KJASLDASOIDAS")
  87. }}>
  88. <Icons name="filtros" size={70} style={{color: "orange"}} />
  89. </Button>
  90. </View> && (
  91. this.props.favTracks.length !== 0 ? (
  92. this._setPersonalTracks(this.props.favTracks)
  93. ) : (
  94. <Text>Ainda não criaste nenhum trajeto</Text>
  95. )
  96. ) : (
  97. <FeedBack type={1}/>
  98. )}
  99. </ScrollView>
  100. </View>
  101. </Tab>
  102. </Tabs>
  103. </View>
  104. </View>
  105. </View>
  106. )
  107. }
  108.  
  109. componentDidMount() {
  110. let {userData} = this.props;
  111. this.props.getTracks();
  112. {
  113. userData && this.props.getFavTracks(userData.id);
  114. }
  115. }
  116.  
  117. _setContent = tracks => {
  118. let content = [];
  119.  
  120. tracks.map((track, key) => {
  121. content.push(
  122. <DefaultTracks data={track}/>
  123. );
  124. });
  125.  
  126. return content;
  127. };
  128.  
  129. _setPersonalTracks = tracks => {
  130. let content = [];
  131.  
  132. tracks.map(track => {
  133. content.push(
  134. <PersonalTracks data={track}/>
  135. )
  136. });
  137.  
  138. return content;
  139. };
  140. }
  141.  
  142. const styles = StyleSheet.create({
  143. container: {
  144. flex: 1,
  145. justifyContent: 'center',
  146. alignItems: 'center',
  147. backgroundColor: 'white',
  148. },
  149. title: {
  150. fontSize: 25,
  151. fontWeight: 'bold',
  152. textAlign: 'center',
  153. color: '#fff',
  154. marginTop: 40
  155. }
  156. });
  157.  
  158. function mapStateToProps(state) {
  159. return {
  160. tracks: state.tracks.tracks,
  161. favTracks: state.favTracks.favTracks,
  162. userData: state.user.user
  163. };
  164. }
  165.  
  166. export default connect(
  167. mapStateToProps,
  168. actions
  169. )(TracksList);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement