123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482 |
- /**
- * Sample React Native App
- * https://github.com/facebook/react-native
- *
- * @format
- * @flow
- */
- import React, { Component } from "react";
- import {
- Platform,
- StyleSheet,
- Text,
- View,
- Image,
- TouchableOpacity,
- ImageBackground,
- Button,
- StatusBar,
- Modal,
- TouchableHighlight,
- DeviceEventEmitter
- } from "react-native";
- import AndroidUtil from "../../util/AndroidUtil";
- import BasePage from "../BasePage";
- import CourseTitle from "./CourseTitle";
- import Header from "./Header";
- import PersonalInfoDialog from "./PersonalInfoDialog";
- type Props = {};
- export default class PersonalInfo extends BasePage {
- state = {
- nickName: "初始昵称",
- schoolName: "未设置"
- };
- updateState(data) {
- this.setState(data);
- }
- render() {
- return (
- <View style={{ flex: 1 }}>
- <PersonalInfoDialog
- ref={view => (this.dialog = view)}
- updateParentState={this.updateState.bind(this)}
- />
- <StatusBar
- backgroundColor={"transparent"}
- barStyle={"dark-content"}
- backgroundColor={"white"}
- translucent={false}
- />
- <View
- style={{
- flex: 1,
- flexDirection: "column"
- }}
- >
- <ImageBackground
- source={require("../images/userInfo/top.png")}
- style={{
- flex: 5,
- width: "100%",
- backgroundColor: "#F0F1F5",
- height: "73%"
- }}
- imageStyle={{ resizeMode: "contain" }}
- >
- <View
- style={{
- flex: 1,
- alignItems: "center",
- justifyContent: "center",
- flexDirection: "column"
- }}
- >
- <CourseTitle
- style={{ flex: 1 }}
- width={this.getWindowWidth()}
- title="个人信息"
- backPress={() => this.goBack()}
- lefttype={2}
- textcolor={"white"}
- backPress={() => this.goBack()}
- />
- <View
- style={{
- flex: 1.5,
- backgroundColor: "white",
- width: "90%",
- alignItems: "center",
- justifyContent: "center",
- borderRadius: 20,
- overflow: "hidden"
- }}
- >
- <Header
- uri="https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1295208965,3056573814&fm=26&gp=0.jpg"
- username="卡通笨笨熊"
- flowerNumber="123234"
- onPress={() => this.toNextPage("MainActivity")}
- />
- </View>
- </View>
- </ImageBackground>
- <View style={{ flex: 0.1, backgroundColor: "#F0F1F5" }} />
- <View
- style={{
- width: "100%",
- flex: 4.1,
- alignItems: "center",
- justifyContent: "center",
- backgroundColor: "#F0F1F5"
- }}
- >
- <View
- style={{
- backgroundColor: "#F3F3F3",
- width: "90%",
- alignItems: "center",
- justifyContent: "center",
- height: "90%",
- overflow: "hidden",
- borderRadius: 20
- }}
- >
- {this.userInfo123()}
- </View>
- </View>
- <View style={{ flex: 0.1, backgroundColor: "#F0F1F5" }} />
- <View
- style={{
- width: "100%",
- alignItems: "center",
- justifyContent: "center",
- flex: 4.1,
- backgroundColor: "#F0F1F5"
- }}
- >
- <View
- style={{
- backgroundColor: "#F3F3F3",
- width: "90%",
- height: "90%",
- overflow: "hidden",
- borderRadius: 20
- }}
- >
- {this.userInfo456()}
- </View>
- </View>
- <View
- style={{
- width: "100%",
- flex: 4,
- backgroundColor: "#F0F1F5",
- flexDirection: "column"
- }}
- >
- <View style={{ flex: 0.5 }} />
- <View style={{ flex: 1, flexDirection: "row" }}>
- <View style={{ flex: 1 }} />
- <View
- style={{
- flex: 7,
- width: "100%",
- height: "100%"
- }}
- >
- <TouchableOpacity
- activeOpacity={1}
- style={{
- flex: 1,
- width: "100%",
- alignItems: "center",
- justifyContent: "center",
- height: "100%"
- }}
- onPress={() => this.logout()}
- >
- <ImageBackground
- source={require("../images/userInfo/logoutbg1.png")}
- style={{
- flex: 1,
- width: "100%",
- resizeMode: "repeat",
- alignItems: "center",
- justifyContent: "center",
- height: "100%"
- }}
- imageStyle={{ resizeMode: "contain" }}
- >
- <Text
- style={{
- fontSize: 30,
- color: "white",
- width: "100%",
- textAlign: "center"
- }}
- >
- 退出登录
- </Text>
- </ImageBackground>
- </TouchableOpacity>
- <View style={{ flex: 1 }} />
- </View>
- <View style={{ flex: 1 }} />
- </View>
- </View>
- </View>
- </View>
- );
- }
- userInfo123() {
- return (
- <View
- style={{
- width: "100%",
- alignItems: "center",
- justifyContent: "center",
- height: "100%"
- }}
- >
- <View style={styles.item}>
- <View
- style={{
- flex: 2,
- alignItems: "center",
- justifyContent: "center"
- }}
- >
- {this.choseheadericon(0)}
- </View>
- <Text style={styles.item_text}>头像</Text>
- <View
- style={{
- flex: 2,
- alignItems: "center",
- justifyContent: "center"
- }}
- >
- {this.getArraowImg(0)}
- </View>
- </View>
- <View style={{ flex: 0.05 }} />
- <View style={styles.item}>
- <View
- style={{
- flex: 2,
- alignItems: "center",
- justifyContent: "center"
- }}
- >
- {this.choseheadericon(1)}
- </View>
- <Text style={styles.item_text}>{this.state.nickName}</Text>
- <View
- style={{
- flex: 2,
- alignItems: "center",
- justifyContent: "center"
- }}
- >
- {this.getArraowImg(1)}
- </View>
- </View>
- <View style={{ flex: 0.05 }} />
- <View style={styles.item}>
- <View
- style={{
- flex: 2,
- alignItems: "center",
- justifyContent: "center"
- }}
- >
- {this.choseheadericon(2)}
- </View>
- <Text style={styles.item_text}>生日</Text>
- <View
- style={{
- flex: 2,
- alignItems: "center",
- justifyContent: "center"
- }}
- >
- {this.getArraowImg(2)}
- </View>
- </View>
- </View>
- );
- }
- userInfo456() {
- return (
- <View
- style={{
- width: "100%",
- alignItems: "center",
- justifyContent: "center",
- height: "100%"
- }}
- >
- <View style={styles.item}>
- <View
- style={{
- flex: 2,
- alignItems: "center",
- justifyContent: "center"
- }}
- >
- {this.choseheadericon(3)}
- </View>
- <Text style={styles.item_text}>所在地区</Text>
- <View
- style={{
- flex: 2,
- alignItems: "center",
- justifyContent: "center"
- }}
- >
- {this.getArraowImg(3)}
- </View>
- </View>
- <View style={{ flex: 0.05 }} />
- <View style={styles.item}>
- <View
- style={{
- flex: 2,
- alignItems: "center",
- justifyContent: "center"
- }}
- >
- {this.choseheadericon(4)}
- </View>
- <Text style={styles.item_text}>{this.state.schoolName}</Text>
- <View
- style={{
- flex: 2,
- alignItems: "center",
- justifyContent: "center"
- }}
- >
- {this.getArraowImg(4)}
- </View>
- </View>
- <View style={{ flex: 0.05 }} />
- <View style={styles.item}>
- <View
- style={{
- flex: 2,
- alignItems: "center",
- justifyContent: "center"
- }}
- >
- {this.choseheadericon(5)}
- </View>
- <Text style={styles.item_text}>我的年级</Text>
- <View
- style={{
- flex: 2,
- alignItems: "center",
- justifyContent: "center"
- }}
- >
- {this.getArraowImg(5)}
- </View>
- </View>
- </View>
- );
- }
- getArraowImg(type) {
- return (
- <TouchableOpacity
- style={{
- width: "100%",
- height: "100%",
- alignItems: "center",
- justifyContent: "center"
- }}
- onPress={() => this.arrowpress(type)}
- >
- <Image
- source={require("../images/userInfo/arrow.png")}
- style={{
- width: "20%",
- height: "30%"
- }}
- />
- </TouchableOpacity>
- );
- }
- choseheadericon(type) {
- let headerpath;
- switch (type) {
- case 0:
- headerpath = require("../images/userInfo/headportrait.png");
- break;
- case 1:
- headerpath = require("../images/userInfo/nickname.png");
- break;
- case 2:
- headerpath = require("../images/userInfo/birthday.png");
- break;
- case 3:
- headerpath = require("../images/userInfo/location.png");
- break;
- case 4:
- headerpath = require("../images/userInfo/school.png");
- break;
- case 5:
- headerpath = require("../images/userInfo/grade.png");
- break;
- }
- // alert(headerpath);
- return (
- <Image
- source={headerpath}
- style={{
- width: "60%",
- height: "60%",
- resizeMode: "contain"
- }}
- />
- );
- }
- arrowpress(type) {
- switch (type) {
- case 0:
- alert("点击头像");
- break;
- case 1:
- this.dialog.setInfo("修改昵称", "昵称");
- this.dialog.setModalVisible(true, 1);
- break;
- case 2:
- alert("生日");
- break;
- case 3:
- alert("所在地区");
- break;
- case 4:
- this.dialog.setInfo("我的学校", "学校名称");
- this.dialog.setModalVisible(true, 2);
- break;
- case 5:
- alert("我的年级");
- break;
- }
- }
- logout() {
- alert("点击退出了");
- }
- }
- const styles = StyleSheet.create({
- item: {
- flex: 1,
- width: "100%",
- flexDirection: "row",
- backgroundColor: "white"
- },
- item_text: {
- flex: 10,
- marginLeft: 10,
- textAlignVertical: "center",
- color: "black",
- fontSize: 20
- }
- });
|