Browse Source

1.提交修改

zhangmengjie 5 years ago
parent
commit
ba1c24e5d6
2 changed files with 42 additions and 8 deletions
  1. 1 1
      pages/components/PersonalInfo.js
  2. 41 7
      pages/components/PersonalInfoDialog.js

+ 1 - 1
pages/components/PersonalInfo.js

@@ -49,7 +49,7 @@ export default class PersonalInfo extends BasePage {
   }
   render() {
     return (
-      <View style={{ flex: 1 }}>
+      <View style={{ width: "100%", height: this.getWindowHeight() }}>
         <PersonalInfoDialog
           ref={view => (this.dialog = view)}
           updateParentState={this.updateState.bind(this)}

+ 41 - 7
pages/components/PersonalInfoDialog.js

@@ -16,6 +16,7 @@ import {
   TouchableOpacity,
   ImageBackground,
   TextInput,
+  Keyboard,
   Button,
   StatusBar,
   Modal,
@@ -34,7 +35,8 @@ export default class PersonalInfoDialog extends Component<Props> {
     touch_cancel_color: "white",
     touch_cancel_textcolor: "#58A8FA",
     input_text: "",
-    updateType: 0 //1修改昵称,2修改学校名称
+    updateType: 0, //1修改昵称,2修改学校名称,
+    keyBoardHeight: 0
   };
 
   setModalVisible(visible, type) {
@@ -80,12 +82,39 @@ export default class PersonalInfoDialog extends Component<Props> {
     if (this.state.updateType == 1) {
       data = { nickName: this.state.input_text };
     } else if (this.state.updateType == 2) {
-      data = { schoolName: this.state.input_text };
+      data = {
+        schoolName: this.state.input_text
+      };
     }
     this.props.updateParentState(data);
     this.setModalVisible(false);
   }
+  componentWillMount() {
+    this.keyboardDidShowListener = Keyboard.addListener(
+      "keyboardDidShow",
+      this._keyboardDidShow
+    );
+    this.keyboardDidHideListener = Keyboard.addListener(
+      "keyboardDidHide",
+      this._keyboardDidHide
+    );
+  }
 
+  componentWillUnmount() {
+    this.keyboardDidShowListener.remove();
+    this.keyboardDidHideListener.remove();
+  }
+
+  _keyboardDidShow = e => {
+    this.setState({
+      keyBoardHeight: e.endCoordinates.height
+    });
+  };
+  _keyboardDidHide = () => {
+    this.setState({
+      keyBoardHeight: 0
+    });
+  };
   render() {
     return (
       <Modal
@@ -110,12 +139,13 @@ export default class PersonalInfoDialog extends Component<Props> {
             style={{
               width: "100%",
               height: "20%",
-              backgroundColor: "white"
+              backgroundColor: "white",
+              bottom: this.state.keyBoardHeight
             }}
           >
             <View
               style={{
-                height: 150,
+                height: "100%",
                 width: "100%",
                 backgroundColor: "white"
               }}
@@ -156,7 +186,11 @@ export default class PersonalInfoDialog extends Component<Props> {
                     marginLeft: 5,
                     fontSize: 20
                   }}
-                  onChangeText={text => this.setState({ input_text: text })}
+                  onChangeText={text =>
+                    this.setState({
+                      input_text: text
+                    })
+                  }
                 />
               </View>
               <View
@@ -191,7 +225,7 @@ export default class PersonalInfoDialog extends Component<Props> {
                       style={{
                         textAlignVertical: "center",
                         textAlign: "center",
-                        fontSize: 25,
+                        fontSize: 23,
                         borderRadius: 30,
                         color: this.state.touchtextcolor
                       }}
@@ -219,7 +253,7 @@ export default class PersonalInfoDialog extends Component<Props> {
                       style={{
                         textAlignVertical: "center",
                         textAlign: "center",
-                        fontSize: 25,
+                        fontSize: 23,
                         color: this.state.touch_cancel_textcolor
                       }}
                     >