Advertisement
Guest User

Untitled

a guest
Aug 20th, 2018
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.60 KB | None | 0 0
  1. import React, { Component } from 'react'
  2. import { ScrollView, View, Text, TouchableOpacity, Linking } from 'react-native'
  3. import Header from '../../components/Header'
  4. import IconTouchable from '../../components/IconTouchable'
  5. import ImagePicker from 'react-native-image-picker'
  6. import BackgroundImage from '../../components/BackgroundImage'
  7. import DefaultBackgroundImg from '../../components/DefaultBackgroundImg'
  8. import DialogComponent from '../../components/DialogComponent'
  9. import styles from './styles'
  10.  
  11. class ProfileSettings extends Component {
  12. constructor (props) {
  13. super(props)
  14.  
  15. this.state = {
  16. image: null,
  17. username: '',
  18. password: '',
  19. showUserNameDialog: false,
  20. showPassDialog: false
  21. }
  22.  
  23. this.handleSubmit = this.handleSubmit.bind(this)
  24. this.pickImage = this.pickImage.bind(this)
  25. this.renderUserNamePrompt = this.renderUserNamePrompt.bind(this)
  26. this.renderPassPrompt = this.renderPassPrompt.bind(this)
  27. }
  28.  
  29. handleSubmit () {
  30. // TODO: Implement validation and proceed logic
  31. console.log('Profile Settings: ', this.state)
  32. this.props.navigation.navigate('Splash')
  33. }
  34.  
  35. renderUserNamePrompt () {
  36. return (
  37. <DialogComponent
  38. visibility={this.state.showUserNameDialog}
  39. title='Профилно име'
  40. description='Въведете профилното си име'
  41. labelInput='Вашето профилно име'
  42. confirm='запази'
  43. onCancel={() => this.setState({ showUserNameDialog: false })}
  44. onPress={(text) => this.setState({ username: text, showUserNameDialog: false })}
  45. />
  46. )
  47. }
  48.  
  49. renderPassPrompt () {
  50. return (
  51. <DialogComponent
  52. visibility={this.state.showPassDialog}
  53. title='Парола'
  54. description='Въведете паролата си'
  55. labelInput='Вашата парола'
  56. confirm='запази'
  57. onCancel={() => this.setState({ showPassDialog: false })}
  58. onPress={(value) => this.setState({ password: value, showPassDialog: false })}
  59. />
  60. )
  61. }
  62.  
  63. pickImage () {
  64. const options = {
  65. title: 'Избери снимка',
  66. storageOptions: {
  67. skipBackup: true,
  68. path: 'images'
  69. }
  70. }
  71.  
  72. ImagePicker.showImagePicker(options, (response) => {
  73. if (!response.didCancel && !response.error) {
  74. const source = { uri: response.uri }
  75. this.setState({ image: source })
  76. }
  77. })
  78. }
  79.  
  80. render () {
  81. const { image } = this.state
  82. const PATH = 'socourt-admin/resources/imgs/'
  83. const FIDWEB = 'http://fidweb.net'
  84. const SOCOURT = 'http://thesocourt.com'
  85. const BFT = 'https://www.facebook.com/BulgarianTennisFederation/'
  86. return (
  87. <View style={styles.container}>
  88.  
  89. <Header
  90. text='Настройки'
  91. goBack={() => this.props.navigation.goBack()}
  92. goToProfile={() => this.props.navigation.navigate('UserProfile')}
  93. />
  94.  
  95. {/* MAIN CONTENT */}
  96. <ScrollView style={styles.scrollContainer}>
  97. <View style={styles.innerContainer}>
  98.  
  99. <View style={styles.mainContent}>
  100.  
  101. <View style={styles.profileContainer}>
  102.  
  103. {/* PICTURE SELECT */}
  104. <View style={styles.userPhoto}>
  105.  
  106. {image
  107. ? <BackgroundImage
  108. image={image}
  109. style={styles.imgUserPhoto}
  110. colorFilter='#00000040'
  111. />
  112. : <DefaultBackgroundImg
  113. style={styles.imgUserPhoto}
  114. colorFilter='#00000060'
  115. />
  116. }
  117.  
  118. <IconTouchable
  119. image={require(PATH + 'icon-camera-white.png')}
  120. style={styles.iconPickPhoto}
  121. onPress={this.pickImage}
  122. />
  123. </View>
  124.  
  125. {/* USER CONTENT */}
  126. <View style={styles.btnUserName}>
  127. <Text style={styles.btnUserNameTxt}>
  128. {this.state.username || 'User Name'}
  129. </Text>
  130. <IconTouchable
  131. image={require(PATH + 'icon-pencil-dark.png')}
  132. style={styles.iconEditUserName}
  133. onPress={() => this.setState({ showUserNameDialog: true })}
  134. />
  135.  
  136. {this.state.showUserNameDialog && this.renderUserNamePrompt()}
  137. </View>
  138.  
  139. <View />
  140.  
  141. <View >
  142. <Text style={styles.userEmail}>
  143. useremail@gmail.com
  144. </Text>
  145. </View>
  146. </View>
  147.  
  148. <View style={styles.btnContainer}>
  149. {/* BUTTONS */}
  150.  
  151. <View style={styles.btnView}>
  152. <TouchableOpacity
  153. style={styles.btnEdit}
  154. onPress={() => this.setState({ showPassDialog: true })}
  155. >
  156. <Text style={styles.btnViewText}>
  157. редактирай парола
  158. </Text>
  159. <IconTouchable
  160. image={require(PATH + 'icon-pencil-dark.png')}
  161. style={styles.iconEdit}
  162. onPress={() => this.setState({ showPassDialog: true })}
  163. />
  164. {this.state.showPassDialog && this.renderPassPrompt()}
  165. </TouchableOpacity>
  166. </View>
  167.  
  168. <View style={styles.btnView}>
  169. <TouchableOpacity
  170. style={styles.btnViewTouch}
  171. onPress={() => this.props.navigation.navigate('FrequentQuestions')}
  172. >
  173. <Text style={styles.btnViewText}>
  174. често задавани въпроси
  175. </Text>
  176. </TouchableOpacity>
  177. </View>
  178.  
  179. <View style={styles.btnView}>
  180. <TouchableOpacity
  181. style={styles.btnViewTouch}>
  182. <Text style={styles.btnViewText}>
  183. свързване с поддръжка
  184. </Text>
  185. </TouchableOpacity>
  186. </View>
  187.  
  188. <View style={styles.fbButton}>
  189. <TouchableOpacity
  190. onPress={() => Linking.openURL(BFT)}
  191. >
  192. <Text style={styles.fbButtonTxt}>
  193. последвай БФТ във facebook
  194. </Text>
  195. </TouchableOpacity>
  196. </View>
  197.  
  198. </View>
  199. </View>
  200.  
  201. {/* FOOTER */}
  202. <View style={styles.footerContainer}>
  203. <TouchableOpacity style={styles.exitBtn}>
  204. <Text style={styles.exitBtnTxt}>
  205. изход
  206. </Text>
  207. </TouchableOpacity>
  208.  
  209. <View style={styles.footerView}>
  210. <Text style={styles.footerText}>
  211. БФТ Livescore старателно създадено от екипа на <Text style={styles.companyText} onPress={() => Linking.openURL(FIDWEB)}>FidWeb</Text> и <Text style={styles.companyText} onPress={() => Linking.openURL(SOCOURT)}> SoCourt</Text>
  212. </Text>
  213. </View>
  214. </View>
  215.  
  216. </View>
  217. </ScrollView>
  218.  
  219. </View>
  220. )
  221. }
  222. }
  223.  
  224. export default ProfileSettings
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement