PersonalInfo.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. /**
  2. * Sample React Native App
  3. * https://github.com/facebook/react-native
  4. *
  5. * @format
  6. * @flow
  7. */
  8. import React, { Component } from "react";
  9. import {
  10. Platform,
  11. StyleSheet,
  12. Text,
  13. View,
  14. Image,
  15. TouchableOpacity,
  16. ImageBackground,
  17. Button,
  18. StatusBar,
  19. Modal,
  20. TouchableHighlight,
  21. DeviceEventEmitter
  22. } from "react-native";
  23. import AndroidUtil from "../../util/AndroidUtil";
  24. import BasePage from "../BasePage";
  25. import CourseTitle from "./CourseTitle";
  26. import Header from "./Header";
  27. import PersonalInfoDialog from "./PersonalInfoDialog";
  28. type Props = {};
  29. export default class PersonalInfo extends BasePage {
  30. state = {
  31. nickName: "初始昵称",
  32. schoolName: "未设置"
  33. };
  34. updateState(data) {
  35. this.setState(data);
  36. }
  37. render() {
  38. return (
  39. <View style={{ flex: 1 }}>
  40. <PersonalInfoDialog
  41. ref={view => (this.dialog = view)}
  42. updateParentState={this.updateState.bind(this)}
  43. />
  44. <StatusBar
  45. backgroundColor={"transparent"}
  46. barStyle={"dark-content"}
  47. backgroundColor={"white"}
  48. translucent={false}
  49. />
  50. <View
  51. style={{
  52. flex: 1,
  53. flexDirection: "column"
  54. }}
  55. >
  56. <ImageBackground
  57. source={require("../images/userInfo/top.png")}
  58. style={{
  59. flex: 5,
  60. width: "100%",
  61. backgroundColor: "#F0F1F5",
  62. height: "73%"
  63. }}
  64. imageStyle={{ resizeMode: "contain" }}
  65. >
  66. <View
  67. style={{
  68. flex: 1,
  69. alignItems: "center",
  70. justifyContent: "center",
  71. flexDirection: "column"
  72. }}
  73. >
  74. <CourseTitle
  75. style={{ flex: 1 }}
  76. width={this.getWindowWidth()}
  77. title="个人信息"
  78. backPress={() => this.goBack()}
  79. lefttype={2}
  80. textcolor={"white"}
  81. backPress={() => this.goBack()}
  82. />
  83. <View
  84. style={{
  85. flex: 1.5,
  86. backgroundColor: "white",
  87. width: "90%",
  88. alignItems: "center",
  89. justifyContent: "center",
  90. borderRadius: 20,
  91. overflow: "hidden"
  92. }}
  93. >
  94. <Header
  95. uri="https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1295208965,3056573814&amp;fm=26&amp;gp=0.jpg"
  96. username="卡通笨笨熊"
  97. flowerNumber="123234"
  98. onPress={() => this.toNextPage("MainActivity")}
  99. />
  100. </View>
  101. </View>
  102. </ImageBackground>
  103. <View style={{ flex: 0.1, backgroundColor: "#F0F1F5" }} />
  104. <View
  105. style={{
  106. width: "100%",
  107. flex: 4.1,
  108. alignItems: "center",
  109. justifyContent: "center",
  110. backgroundColor: "#F0F1F5"
  111. }}
  112. >
  113. <View
  114. style={{
  115. backgroundColor: "#F3F3F3",
  116. width: "90%",
  117. alignItems: "center",
  118. justifyContent: "center",
  119. height: "90%",
  120. overflow: "hidden",
  121. borderRadius: 20
  122. }}
  123. >
  124. {this.userInfo123()}
  125. </View>
  126. </View>
  127. <View style={{ flex: 0.1, backgroundColor: "#F0F1F5" }} />
  128. <View
  129. style={{
  130. width: "100%",
  131. alignItems: "center",
  132. justifyContent: "center",
  133. flex: 4.1,
  134. backgroundColor: "#F0F1F5"
  135. }}
  136. >
  137. <View
  138. style={{
  139. backgroundColor: "#F3F3F3",
  140. width: "90%",
  141. height: "90%",
  142. overflow: "hidden",
  143. borderRadius: 20
  144. }}
  145. >
  146. {this.userInfo456()}
  147. </View>
  148. </View>
  149. <View
  150. style={{
  151. width: "100%",
  152. flex: 4,
  153. backgroundColor: "#F0F1F5",
  154. flexDirection: "column"
  155. }}
  156. >
  157. <View style={{ flex: 0.5 }} />
  158. <View style={{ flex: 1, flexDirection: "row" }}>
  159. <View style={{ flex: 1 }} />
  160. <View
  161. style={{
  162. flex: 7,
  163. width: "100%",
  164. height: "100%"
  165. }}
  166. >
  167. <TouchableOpacity
  168. activeOpacity={1}
  169. style={{
  170. flex: 1,
  171. width: "100%",
  172. alignItems: "center",
  173. justifyContent: "center",
  174. height: "100%"
  175. }}
  176. onPress={() => this.logout()}
  177. >
  178. <ImageBackground
  179. source={require("../images/userInfo/logoutbg1.png")}
  180. style={{
  181. flex: 1,
  182. width: "100%",
  183. resizeMode: "repeat",
  184. alignItems: "center",
  185. justifyContent: "center",
  186. height: "100%"
  187. }}
  188. imageStyle={{ resizeMode: "contain" }}
  189. >
  190. <Text
  191. style={{
  192. fontSize: 30,
  193. color: "white",
  194. width: "100%",
  195. textAlign: "center"
  196. }}
  197. >
  198. 退出登录
  199. </Text>
  200. </ImageBackground>
  201. </TouchableOpacity>
  202. <View style={{ flex: 1 }} />
  203. </View>
  204. <View style={{ flex: 1 }} />
  205. </View>
  206. </View>
  207. </View>
  208. </View>
  209. );
  210. }
  211. userInfo123() {
  212. return (
  213. <View
  214. style={{
  215. width: "100%",
  216. alignItems: "center",
  217. justifyContent: "center",
  218. height: "100%"
  219. }}
  220. >
  221. <View style={styles.item}>
  222. <View
  223. style={{
  224. flex: 2,
  225. alignItems: "center",
  226. justifyContent: "center"
  227. }}
  228. >
  229. {this.choseheadericon(0)}
  230. </View>
  231. <Text style={styles.item_text}>头像</Text>
  232. <View
  233. style={{
  234. flex: 2,
  235. alignItems: "center",
  236. justifyContent: "center"
  237. }}
  238. >
  239. {this.getArraowImg(0)}
  240. </View>
  241. </View>
  242. <View style={{ flex: 0.05 }} />
  243. <View style={styles.item}>
  244. <View
  245. style={{
  246. flex: 2,
  247. alignItems: "center",
  248. justifyContent: "center"
  249. }}
  250. >
  251. {this.choseheadericon(1)}
  252. </View>
  253. <Text style={styles.item_text}>{this.state.nickName}</Text>
  254. <View
  255. style={{
  256. flex: 2,
  257. alignItems: "center",
  258. justifyContent: "center"
  259. }}
  260. >
  261. {this.getArraowImg(1)}
  262. </View>
  263. </View>
  264. <View style={{ flex: 0.05 }} />
  265. <View style={styles.item}>
  266. <View
  267. style={{
  268. flex: 2,
  269. alignItems: "center",
  270. justifyContent: "center"
  271. }}
  272. >
  273. {this.choseheadericon(2)}
  274. </View>
  275. <Text style={styles.item_text}>生日</Text>
  276. <View
  277. style={{
  278. flex: 2,
  279. alignItems: "center",
  280. justifyContent: "center"
  281. }}
  282. >
  283. {this.getArraowImg(2)}
  284. </View>
  285. </View>
  286. </View>
  287. );
  288. }
  289. userInfo456() {
  290. return (
  291. <View
  292. style={{
  293. width: "100%",
  294. alignItems: "center",
  295. justifyContent: "center",
  296. height: "100%"
  297. }}
  298. >
  299. <View style={styles.item}>
  300. <View
  301. style={{
  302. flex: 2,
  303. alignItems: "center",
  304. justifyContent: "center"
  305. }}
  306. >
  307. {this.choseheadericon(3)}
  308. </View>
  309. <Text style={styles.item_text}>所在地区</Text>
  310. <View
  311. style={{
  312. flex: 2,
  313. alignItems: "center",
  314. justifyContent: "center"
  315. }}
  316. >
  317. {this.getArraowImg(3)}
  318. </View>
  319. </View>
  320. <View style={{ flex: 0.05 }} />
  321. <View style={styles.item}>
  322. <View
  323. style={{
  324. flex: 2,
  325. alignItems: "center",
  326. justifyContent: "center"
  327. }}
  328. >
  329. {this.choseheadericon(4)}
  330. </View>
  331. <Text style={styles.item_text}>{this.state.schoolName}</Text>
  332. <View
  333. style={{
  334. flex: 2,
  335. alignItems: "center",
  336. justifyContent: "center"
  337. }}
  338. >
  339. {this.getArraowImg(4)}
  340. </View>
  341. </View>
  342. <View style={{ flex: 0.05 }} />
  343. <View style={styles.item}>
  344. <View
  345. style={{
  346. flex: 2,
  347. alignItems: "center",
  348. justifyContent: "center"
  349. }}
  350. >
  351. {this.choseheadericon(5)}
  352. </View>
  353. <Text style={styles.item_text}>我的年级</Text>
  354. <View
  355. style={{
  356. flex: 2,
  357. alignItems: "center",
  358. justifyContent: "center"
  359. }}
  360. >
  361. {this.getArraowImg(5)}
  362. </View>
  363. </View>
  364. </View>
  365. );
  366. }
  367. getArraowImg(type) {
  368. return (
  369. <TouchableOpacity
  370. style={{
  371. width: "100%",
  372. height: "100%",
  373. alignItems: "center",
  374. justifyContent: "center"
  375. }}
  376. onPress={() => this.arrowpress(type)}
  377. >
  378. <Image
  379. source={require("../images/userInfo/arrow.png")}
  380. style={{
  381. width: "20%",
  382. height: "30%"
  383. }}
  384. />
  385. </TouchableOpacity>
  386. );
  387. }
  388. choseheadericon(type) {
  389. let headerpath;
  390. switch (type) {
  391. case 0:
  392. headerpath = require("../images/userInfo/headportrait.png");
  393. break;
  394. case 1:
  395. headerpath = require("../images/userInfo/nickname.png");
  396. break;
  397. case 2:
  398. headerpath = require("../images/userInfo/birthday.png");
  399. break;
  400. case 3:
  401. headerpath = require("../images/userInfo/location.png");
  402. break;
  403. case 4:
  404. headerpath = require("../images/userInfo/school.png");
  405. break;
  406. case 5:
  407. headerpath = require("../images/userInfo/grade.png");
  408. break;
  409. }
  410. // alert(headerpath);
  411. return (
  412. <Image
  413. source={headerpath}
  414. style={{
  415. width: "60%",
  416. height: "60%",
  417. resizeMode: "contain"
  418. }}
  419. />
  420. );
  421. }
  422. arrowpress(type) {
  423. switch (type) {
  424. case 0:
  425. alert("点击头像");
  426. break;
  427. case 1:
  428. this.dialog.setInfo("修改昵称", "昵称");
  429. this.dialog.setModalVisible(true, 1);
  430. break;
  431. case 2:
  432. alert("生日");
  433. break;
  434. case 3:
  435. alert("所在地区");
  436. break;
  437. case 4:
  438. this.dialog.setInfo("我的学校", "学校名称");
  439. this.dialog.setModalVisible(true, 2);
  440. break;
  441. case 5:
  442. alert("我的年级");
  443. break;
  444. }
  445. }
  446. logout() {
  447. alert("点击退出了");
  448. }
  449. }
  450. const styles = StyleSheet.create({
  451. item: {
  452. flex: 1,
  453. width: "100%",
  454. flexDirection: "row",
  455. backgroundColor: "white"
  456. },
  457. item_text: {
  458. flex: 10,
  459. marginLeft: 10,
  460. textAlignVertical: "center",
  461. color: "black",
  462. fontSize: 20
  463. }
  464. });