PersonalInfo.js 12 KB

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