Advertisement
Guest User

Untitled

a guest
Jul 21st, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.20 KB | None | 0 0
  1. `
  2. 'use strict';
  3. import React, { Component } from 'react';
  4. import {
  5. AppRegistry,
  6. StyleSheet,
  7. Text,
  8. TextInput,
  9. TouchableHighlight,
  10. View,
  11. AsyncStorage,
  12. AlertIOS,
  13. Navigator
  14. }from 'react-native';
  15. var Login = require('./Login');
  16. var AfterLoginView = require('./AfterLoginView');
  17. var Searchlead = require('./Searchlead');
  18. var RenderDetails = require('./RenderDetails');
  19. class EHNYApp extends Component {
  20. componentWillUnmount() {
  21. Actions.currentRouter = null
  22. }
  23. renderScene(route,navigator){
  24. if(route.name == 'login'){
  25. return <Login navigator = {navigator} />
  26. }
  27. if(route.name == 'afterlogin'){
  28. return <AfterLoginView navigator = {navigator} />
  29. }
  30. if(route.name == 'search'){
  31. return <Searchlead navigator = {navigator} />
  32. }
  33. if(route.name == 'renderdetails'){
  34. return <RenderDetails navigator = {navigator} />
  35. }
  36. }
  37. render() {
  38. return (
  39. <Navigator
  40. initialRoute = {{ name: 'login' }}
  41. renderScene = {this.renderScene.bind(this)}
  42. />
  43. );
  44. }
  45. }
  46. AppRegistry.registerComponent('EHNYApp', () => EHNYApp);
  47.  
  48. `
  49. 'use strict';
  50. import React, { Component } from 'react';
  51. import {
  52. AppRegistry,
  53. StyleSheet,
  54. Text,
  55. TextInput,
  56. TouchableHighlight,
  57. View,
  58. AsyncStorage,
  59. AlertIOS,
  60. NavigatorIOS,
  61. Image,
  62. ActivityIndicatorIOS
  63.  
  64. } from 'react-native';
  65. var AfterLoginView = require('./AfterLoginView');
  66. var STORAGE_KEY = 'id_token';
  67. class Login extends Component{
  68. constructor(props){
  69. super(props)
  70. this.state = {
  71. username : '',
  72. password : '',
  73. errorMesage : '',
  74. isLoading : false,
  75. }
  76. }
  77. submitForm(event){
  78. this.setState({ isLoading: true });
  79. this.swipeToAfterLoginView('afterlogin');
  80. }
  81. swipeToAfterLoginView(routeName){
  82. this.props.navigator.push({
  83. name : routeName,
  84. });
  85. }
  86. render() {
  87. var spinner = this.state.isLoading ? ( < ActivityIndicatorIOS hidden = 'true' size = 'large' / > ) :
  88. < View / >
  89. return (
  90. < View style = {styles.container} >
  91. < View style = {styles.logo} >
  92. < Image style = {styles.logoImage}
  93. source = {require('./logo.png')}
  94. resizeMode = 'contain'
  95. />
  96. < /View>
  97. {spinner}
  98. < View style = {styles.containerFirst} >
  99. < Text style = {styles.errorMesage} > { this.state.errorMesage } < /Text>
  100.  
  101. < TextInput style = {styles.textInput}
  102. placeholder = 'Email'
  103. placeholderTextColor = 'white'
  104. autofocus = {true}
  105. autoCapitalize = 'none'
  106. onChange = {this.usernameInput.bind(this)} /> < /View>
  107. < View style = {styles.containerSecond} >
  108. < TextInput ref = 'password' placeholderTextColor = 'white'
  109. value = { this.state.password}
  110. onChangeText = {password = > this.setState({password})}
  111. onSubmitEditing = {this._submitForm}
  112. style = {styles.textInput}
  113. placeholder = 'Password'
  114. autoCapitalize = 'none'
  115.  
  116. password = {true}
  117. />
  118. < /View>
  119.  
  120. < TouchableHighlight
  121. style = {styles.button} onPress = {this.submitForm.bind(this)} >
  122. < Text style = {styles.buttonText} > LOGIN < /Text>
  123. < /TouchableHighlight>
  124.  
  125. < Text style = {styles.forgotPassword} > Forgot Password ? < /Text>
  126.  
  127. < /View>
  128. );
  129. }
  130.  
  131. }
  132. module.exports = Login;`
  133.  
  134. `
  135. 'use strict';
  136. import React, { Component } from 'react';
  137. import {
  138. AppRegistry,
  139. StyleSheet,
  140. Text,
  141. TextInput,
  142. TouchableHighlight,
  143. View,
  144. AsyncStorage,
  145. AlertIOS,
  146. Navigator,
  147. TabBarIOS,
  148. ActivityIndicatorIOS
  149. } from 'react-native';
  150. var Dashboard = require('./Dashboard');
  151. var Other = require('./Other');
  152. var Searchlead = require('./Searchlead');
  153. class AfterLoginView extends Component{
  154. constructor(props) {
  155. super(props);
  156. this.state = {
  157. selectedTab:'searchlead',
  158. isLoading : false,
  159. };
  160. }
  161. render(){
  162. var spinner = this.state.isLoading ?
  163. ( < ActivityIndicatorIOS
  164. hidden = 'true'
  165. size = 'large' / > ) :
  166. ( < View / > );
  167. return (
  168. < TabBarIOS selectedTab = {this.state.selectedTab} >
  169. < TabBarIOS.Item
  170. selected = {this.state.selectedTab === 'searchlead'}
  171. title = 'SearchLead'
  172. systemIcon = 'search'
  173. onPress = { () = > {
  174. this.setState({
  175. selectedTab : 'searchlead'
  176. })
  177. }} >
  178. < Searchlead / >
  179. < /TabBarIOS.Item>
  180.  
  181.  
  182. < TabBarIOS.Item
  183. selected = {this.state.selectedTab === 'dashboard'}
  184. //systemIcon="featured"
  185. title = 'Dashboard'
  186. onPress = {() = > {
  187. this.setState({
  188. selectedTab :'dashboard'
  189. });
  190. }} >
  191. < Dashboard / >
  192. < /TabBarIOS.Item>
  193. < TabBarIOS.Item
  194. selected = {this.state.selectedTab === 'other'}
  195. title = 'Other'
  196. onPress = {() = > {
  197. this.setState({
  198. selectedTab : 'other'
  199. });
  200. }} >
  201. < Other / >
  202. < /TabBarIOS.Item>
  203. < /TabBarIOS>
  204.  
  205. );
  206. }
  207. async submitForm(event){
  208.  
  209. var demoToken = await AsyncStorage.getItem('id_token');
  210. console.log(demoToken);
  211. // this.login();
  212. }
  213.  
  214.  
  215. };
  216. module.exports = AfterLoginView;`
  217.  
  218. `
  219. 'use strict';
  220. import React, { Component } from 'react';
  221. import {
  222. AppRegistry,
  223. StyleSheet,
  224. Text,
  225. TextInput,
  226. ListView,
  227. View,
  228. TouchableHighlight,
  229. Navigator
  230. } from 'react-native';
  231. var RenderDetails = require('./RenderDetails');
  232. var Login = require('./Login');
  233. var ds = new ListView.DataSource({rowHasChanged: (r1, r2) = > r1 !== r2});
  234. class Searchlead extends Component {
  235. constructor(props) {
  236. super(props);
  237. this.state = {
  238. searchedAdresses: []
  239. };
  240. };
  241. componentWillMount = function(){
  242. this._pressData = {};
  243. }
  244. _pressData = function (){
  245. console.log("yes");
  246. }
  247. searchedAdresses = (searchedText) = > {
  248. if (searchedText === '') {
  249. return [];
  250. }
  251. var url = 'https://maps.googleapis.com/maps/api/place/autocomplete/json?input=' + searchedText + '&types=geocode&key=apikeuys-s&sensor=true';
  252. var i = 0;
  253. var addressData = new Array();
  254. fetch(url, { method:"GET"})
  255. .then((response) = > response.json())
  256. .then((responseData) = > {
  257. for (i = 0; i < responseData.predictions.length; i++){
  258. addressData[i] = {description : responseData.predictions[i].description, place_id : responseData.predictions[i].place_id };
  259. }
  260. this.setState({searchedAdresses: addressData});
  261. })
  262. .done();
  263. };
  264. renderAdress = (rowData, sectionID, rowID) = > {
  265.  
  266. return (
  267. < TouchableHighlight onPress = { this._onPressAddressList.bind(this)} underlayColor = 'white' >
  268. < Text style = { styles.listTextInput } > {rowData.description} < /Text>
  269.  
  270. < /TouchableHighlight>
  271. );
  272. };
  273. _onPressAddressList = () = > {
  274. this.props.navigator.push({
  275. name:'renderdetails'
  276.  
  277. });
  278. }
  279. _renderSeperator(sectionID: number, rowID: number, adjacentRowHighlighted: bool) {
  280. return (
  281. < View key = {`${sectionID} - ${rowID}`} style = {{ height: adjacentRowHighlighted ? 4 : 1, backgroundColor: adjacentRowHighlighted ? '#3B5998' : '#CCCCCC', }}
  282. />
  283. );
  284. }
  285. render() {
  286. return (
  287. < View style = {styles.container} >
  288. < View style = {styles.imageContainer} > < /View>
  289. < View style = {styles.textContainer} >
  290. < TextInput
  291. style = {styles.textinput}
  292. onChangeText = {this.searchedAdresses}
  293. placeholder = "Type your adress here" / >
  294. < /View>
  295. < View >
  296. < ListView
  297. dataSource = {ds.cloneWithRows(this.state.searchedAdresses)}
  298. renderRow = {this.renderAdress}
  299. renderSeparator = {this._renderSeperator}
  300. enableEmptySections = {true}
  301. />
  302. < /View>
  303. < /View>
  304. );
  305. };
  306. }
  307. module.exports = Searchlead;`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement