/** * 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, TextInput, Button, StatusBar, Modal, TouchableHighlight, DeviceEventEmitter } from "react-native"; type Props = {}; export default class PersonalInfoDialog extends Component { state = { modalVisible: false, title: "title", placeholder: "", touchcolor: "white", touchtextcolor: "#58A8FA", touch_cancel_color: "white", touch_cancel_textcolor: "#58A8FA", input_text: "", updateType: 0 //1修改昵称,2修改学校名称 }; setModalVisible(visible, type) { this.setState({ modalVisible: visible, updateType: type, input_text: "" }); } setInfo(mytitle, holder) { this.setState({ title: mytitle, placeholder: holder }); } touchDown() { this.setState({ touchcolor: "#58A8FA", touchtextcolor: "white" }); } touchUp() { this.setState({ touchcolor: "white", touchtextcolor: "#58A8FA" }); } touchCancelDown() { this.setState({ touch_cancel_color: "#58A8FA", touch_cancel_textcolor: "white" }); } touchCancelUp() { this.setState({ touch_cancel_color: "white", touch_cancel_textcolor: "#58A8FA" }); } setParentState() { let data; if (this.state.updateType == 1) { data = { nickName: this.state.input_text }; } else if (this.state.updateType == 2) { data = { schoolName: this.state.input_text }; } this.props.updateParentState(data); this.setModalVisible(false); } render() { return ( { this.setState({ modalVisible: false }); }} > {this.state.title} this.setState({ input_text: text })} /> this.touchDown()} onPressOut={() => this.touchUp()} onPress={() => { this.setParentState(); }} > 确定 this.touchCancelDown()} onPressOut={() => this.touchCancelUp()} onPress={() => this.setModalVisible(false)} > 取消 ); } }