PersonalInfo.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  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 ChosePhoto from "./ChosePhoto";
  27. import Header from "./Header";
  28. import PersonalInfoDialog from "./PersonalInfoDialog";
  29. type Props = {};
  30. export default class PersonalInfo extends BasePage {
  31. state = {
  32. nickName: "初始昵称",
  33. schoolName: "未设置"
  34. };
  35. updateState(data) {
  36. this.setState(data);
  37. }
  38. render() {
  39. return (
  40. <View style={{ flex: 1 }}>
  41. <PersonalInfoDialog
  42. ref={view => (this.dialog = view)}
  43. updateParentState={this.updateState.bind(this)}
  44. />
  45. <ChosePhoto ref={view => (this.chosephoto = view)} />
  46. <StatusBar
  47. backgroundColor={"transparent"}
  48. barStyle={"dark-content"}
  49. backgroundColor={"white"}
  50. translucent={false}
  51. />
  52. <View
  53. style={{
  54. flex: 1,
  55. flexDirection: "column"
  56. }}
  57. >
  58. <ImageBackground
  59. source={require("../images/userInfo/top.png")}
  60. style={{
  61. flex: 5,
  62. width: "100%",
  63. backgroundColor: "#F0F1F5",
  64. height: "73%"
  65. }}
  66. imageStyle={{ resizeMode: "contain" }}
  67. >
  68. <View
  69. style={{
  70. flex: 1,
  71. alignItems: "center",
  72. justifyContent: "center",
  73. flexDirection: "column"
  74. }}
  75. >
  76. <CourseTitle
  77. style={{ flex: 1 }}
  78. width={this.getWindowWidth()}
  79. title="个人信息"
  80. backPress={() => this.goBack()}
  81. lefttype={2}
  82. righttype={0}
  83. textcolor={"white"}
  84. backPress={() => this.goBack()}
  85. />
  86. <TouchableOpacity
  87. style={{
  88. flex: 1,
  89. backgroundColor: "white",
  90. width: "90%",
  91. alignItems: "center",
  92. justifyContent: "center",
  93. borderRadius: 20,
  94. overflow: "hidden"
  95. }}
  96. activeOpacity={1}
  97. onPress={() => this.arrowpress(0)}
  98. >
  99. <View
  100. style={{
  101. flex: 1,
  102. borderRadius: 20,
  103. overflow: "hidden",
  104. alignItems: "center",
  105. justifyContent: "center",
  106. flexDirection: "row"
  107. }}
  108. >
  109. <View style={{ flex: 0.5 }} />
  110. <View
  111. style={{
  112. flex: 3,
  113. height: "100%",
  114. alignItems: "center",
  115. justifyContent: "center"
  116. }}
  117. >
  118. <Image
  119. style={{
  120. borderRadius: 50,
  121. width: "100%",
  122. height: "78%",
  123. borderWidth: 3,
  124. borderColor: "red"
  125. }}
  126. source={{
  127. uri:
  128. "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg"
  129. }}
  130. />
  131. </View>
  132. <View
  133. style={{
  134. flex: 9,
  135. backgroundColor: "white",
  136. height: "100%",
  137. justifyContent: "center"
  138. }}
  139. >
  140. <Text style={{ left: 10, color: "black", fontSize: 20 }}>
  141. 修改头像
  142. </Text>
  143. </View>
  144. <View
  145. style={{
  146. flex: 1.5,
  147. alignItems: "center",
  148. height: "56%",
  149. justifyContent: "center"
  150. }}
  151. >
  152. {this.getArraowImg(0)}
  153. </View>
  154. </View>
  155. </TouchableOpacity>
  156. </View>
  157. </ImageBackground>
  158. <View
  159. style={{
  160. width: "100%",
  161. flex: 8,
  162. alignItems: "center",
  163. justifyContent: "center",
  164. backgroundColor: "#F0F1F5"
  165. }}
  166. >
  167. <View
  168. style={{
  169. backgroundColor: "rgba(242, 242, 242, 1)",
  170. width: "90%",
  171. alignItems: "center",
  172. justifyContent: "center",
  173. height: "90%",
  174. overflow: "hidden",
  175. borderRadius: 20
  176. }}
  177. >
  178. {this.userInfo123()}
  179. </View>
  180. </View>
  181. {/* <View
  182. style={{
  183. width: "100%",
  184. alignItems: "center",
  185. justifyContent: "center",
  186. flex: 4.1,
  187. backgroundColor: "#F0F1F5"
  188. }}
  189. >
  190. <View
  191. style={{
  192. backgroundColor: "#F3F3F3",
  193. width: "90%",
  194. height: "90%",
  195. overflow: "hidden",
  196. borderRadius: 20
  197. }}
  198. >
  199. {this.userInfo456()}
  200. </View>
  201. </View> */}
  202. <View
  203. style={{ flex: 0.5, backgroundColor: "rgba(242, 242, 242, 1)" }}
  204. />
  205. <View
  206. style={{
  207. width: "100%",
  208. flex: 4,
  209. backgroundColor: "#F0F1F5",
  210. flexDirection: "column"
  211. }}
  212. >
  213. <View style={{ flex: 0.5 }} />
  214. <View style={{ flex: 1, flexDirection: "row" }}>
  215. <View style={{ flex: 1 }} />
  216. <View
  217. style={{
  218. flex: 7,
  219. width: "100%",
  220. height: "100%"
  221. }}
  222. >
  223. <TouchableOpacity
  224. activeOpacity={1}
  225. style={{
  226. flex: 1,
  227. width: "100%",
  228. alignItems: "center",
  229. justifyContent: "center",
  230. height: "100%"
  231. }}
  232. onPress={() => this.logout()}
  233. >
  234. <ImageBackground
  235. source={require("../images/userInfo/logoutbg1.png")}
  236. style={{
  237. flex: 1,
  238. width: "100%",
  239. resizeMode: "repeat",
  240. alignItems: "center",
  241. justifyContent: "center",
  242. height: "100%"
  243. }}
  244. imageStyle={{ resizeMode: "contain" }}
  245. >
  246. <Text
  247. style={{
  248. fontSize: 30,
  249. color: "white",
  250. width: "100%",
  251. textAlign: "center"
  252. }}
  253. >
  254. 退出登录
  255. </Text>
  256. </ImageBackground>
  257. </TouchableOpacity>
  258. <View style={{ flex: 1 }} />
  259. </View>
  260. <View style={{ flex: 1 }} />
  261. </View>
  262. </View>
  263. </View>
  264. </View>
  265. );
  266. }
  267. userInfo123() {
  268. return (
  269. <View
  270. style={{
  271. width: "100%",
  272. alignItems: "center",
  273. justifyContent: "center",
  274. height: "100%"
  275. }}
  276. >
  277. <TouchableOpacity
  278. style={styles.item}
  279. activeOpacity={1}
  280. onPress={() => this.arrowpress(1)}
  281. >
  282. <View style={styles.item}>
  283. <View
  284. style={{
  285. flex: 2,
  286. alignItems: "center",
  287. justifyContent: "center"
  288. }}
  289. >
  290. {this.choseheadericon(1)}
  291. </View>
  292. <Text style={styles.item_text}>昵称</Text>
  293. <View
  294. style={{
  295. flex: 5,
  296. alignItems: "flex-end"
  297. }}
  298. >
  299. <Text
  300. style={{
  301. flex: 1,
  302. fontSize: 16,
  303. textAlignVertical: "center"
  304. }}
  305. >
  306. {this.state.nickName}
  307. </Text>
  308. </View>
  309. <View
  310. style={{
  311. flex: 1.1,
  312. alignItems: "center",
  313. justifyContent: "center"
  314. }}
  315. >
  316. {this.getArraowImg(1)}
  317. </View>
  318. </View>
  319. </TouchableOpacity>
  320. <View style={{ flex: 0.05 }} />
  321. <TouchableOpacity
  322. style={styles.item}
  323. activeOpacity={1}
  324. onPress={() => this.arrowpress(2)}
  325. >
  326. <View style={styles.item}>
  327. <View
  328. style={{
  329. flex: 2,
  330. alignItems: "center",
  331. justifyContent: "center"
  332. }}
  333. >
  334. {this.choseheadericon(2)}
  335. </View>
  336. <Text style={styles.item_text}>生日</Text>
  337. <View
  338. style={{
  339. flex: 5,
  340. alignItems: "flex-end"
  341. }}
  342. >
  343. <Text
  344. style={{
  345. flex: 1,
  346. fontSize: 16,
  347. textAlignVertical: "center"
  348. }}
  349. >
  350. 生日。。。。
  351. </Text>
  352. </View>
  353. <View
  354. style={{
  355. flex: 1.1,
  356. alignItems: "center",
  357. justifyContent: "center"
  358. }}
  359. >
  360. {this.getArraowImg(2)}
  361. </View>
  362. </View>
  363. </TouchableOpacity>
  364. <View style={{ flex: 0.05 }} />
  365. <TouchableOpacity
  366. style={styles.item}
  367. activeOpacity={1}
  368. onPress={() => this.arrowpress(3)}
  369. >
  370. <View style={styles.item}>
  371. <View
  372. style={{
  373. flex: 2,
  374. alignItems: "center",
  375. justifyContent: "center"
  376. }}
  377. >
  378. {this.choseheadericon(3)}
  379. </View>
  380. <Text style={styles.item_text}>所在地区</Text>
  381. <View
  382. style={{
  383. flex: 5,
  384. alignItems: "flex-end"
  385. }}
  386. >
  387. <Text
  388. style={{
  389. flex: 1,
  390. fontSize: 16,
  391. textAlignVertical: "center"
  392. }}
  393. >
  394. 所在地区。。。。
  395. </Text>
  396. </View>
  397. <View
  398. style={{
  399. flex: 1.1,
  400. alignItems: "center",
  401. justifyContent: "center"
  402. }}
  403. >
  404. {this.getArraowImg(3)}
  405. </View>
  406. </View>
  407. </TouchableOpacity>
  408. <View style={{ flex: 0.05 }} />
  409. <TouchableOpacity
  410. style={styles.item}
  411. activeOpacity={1}
  412. onPress={() => this.arrowpress(4)}
  413. >
  414. <View style={styles.item}>
  415. <View
  416. style={{
  417. flex: 2,
  418. alignItems: "center",
  419. justifyContent: "center"
  420. }}
  421. >
  422. {this.choseheadericon(4)}
  423. </View>
  424. <Text style={styles.item_text}>我的学校</Text>
  425. <View
  426. style={{
  427. flex: 5,
  428. alignItems: "flex-end"
  429. }}
  430. >
  431. <Text
  432. style={{
  433. flex: 1,
  434. fontSize: 16,
  435. textAlignVertical: "center"
  436. }}
  437. >
  438. {this.state.schoolName}
  439. </Text>
  440. </View>
  441. <View
  442. style={{
  443. flex: 1.1,
  444. alignItems: "center",
  445. justifyContent: "center"
  446. }}
  447. >
  448. {this.getArraowImg(4)}
  449. </View>
  450. </View>
  451. </TouchableOpacity>
  452. <View style={{ flex: 0.05 }} />
  453. <TouchableOpacity
  454. style={styles.item}
  455. activeOpacity={1}
  456. onPress={() => this.arrowpress(5)}
  457. >
  458. <View style={styles.item}>
  459. <View
  460. style={{
  461. flex: 2,
  462. alignItems: "center",
  463. justifyContent: "center"
  464. }}
  465. >
  466. {this.choseheadericon(5)}
  467. </View>
  468. <Text style={styles.item_text}>我的年级</Text>
  469. <View
  470. style={{
  471. flex: 5,
  472. alignItems: "flex-end"
  473. }}
  474. >
  475. <Text
  476. style={{
  477. flex: 1.1,
  478. fontSize: 16,
  479. textAlignVertical: "center"
  480. }}
  481. >
  482. 年级。。。
  483. </Text>
  484. </View>
  485. <View
  486. style={{
  487. flex: 1.1,
  488. alignItems: "center",
  489. justifyContent: "center"
  490. }}
  491. >
  492. {this.getArraowImg(5)}
  493. </View>
  494. </View>
  495. </TouchableOpacity>
  496. </View>
  497. );
  498. }
  499. getArraowImg(type) {
  500. return (
  501. <TouchableOpacity
  502. style={{
  503. width: "100%",
  504. height: "100%",
  505. alignItems: "center",
  506. justifyContent: "center"
  507. }}
  508. onPress={() => this.arrowpress(type)}
  509. >
  510. <Image
  511. source={require("../images/userInfo/arrow.png")}
  512. style={{
  513. width: "20%",
  514. height: "30%"
  515. }}
  516. />
  517. </TouchableOpacity>
  518. );
  519. }
  520. choseheadericon(type) {
  521. let headerpath;
  522. switch (type) {
  523. case 0:
  524. headerpath = require("../images/userInfo/headportrait.png");
  525. break;
  526. case 1:
  527. headerpath = require("../images/userInfo/nickname.png");
  528. break;
  529. case 2:
  530. headerpath = require("../images/userInfo/birthday.png");
  531. break;
  532. case 3:
  533. headerpath = require("../images/userInfo/location.png");
  534. break;
  535. case 4:
  536. headerpath = require("../images/userInfo/school.png");
  537. break;
  538. case 5:
  539. headerpath = require("../images/userInfo/grade.png");
  540. break;
  541. }
  542. // alert(headerpath);
  543. return (
  544. <Image
  545. source={headerpath}
  546. style={{
  547. width: "60%",
  548. height: "60%",
  549. resizeMode: "contain"
  550. }}
  551. />
  552. );
  553. }
  554. arrowpress(type) {
  555. switch (type) {
  556. case 0:
  557. this.chosephoto.setModalVisible(true);
  558. break;
  559. case 1:
  560. this.dialog.setInfo("修改昵称", "昵称");
  561. this.dialog.setModalVisible(true, 1);
  562. break;
  563. case 2:
  564. alert("生日");
  565. break;
  566. case 3:
  567. alert("所在地区");
  568. break;
  569. case 4:
  570. this.dialog.setInfo("我的学校", "学校名称");
  571. this.dialog.setModalVisible(true, 2);
  572. break;
  573. case 5:
  574. alert("我的年级");
  575. break;
  576. }
  577. }
  578. logout() {
  579. alert("点击退出了");
  580. }
  581. }
  582. export class item extends Component<Props> {
  583. render() {
  584. return (
  585. <View>
  586. <View style={{}} />
  587. </View>
  588. );
  589. }
  590. }
  591. const styles = StyleSheet.create({
  592. item: {
  593. flex: 1,
  594. width: "100%",
  595. flexDirection: "row",
  596. backgroundColor: "white"
  597. },
  598. item_text: {
  599. flex: 2,
  600. textAlignVertical: "center",
  601. color: "black",
  602. fontSize: 20
  603. }
  604. });