diff --git a/index.js b/index.js index 5c94a58..35af10e 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,8 @@ //import liraries import React, { Component } from 'react'; -import { Text, StyleSheet, TouchableOpacity, View, FlatList, TextInput, Dimensions, Animated, Platform } from 'react-native'; +import { Text, StyleSheet, TouchableOpacity, View, FlatList, TextInput, Dimensions, Animated, Platform, SafeAreaView } from 'react-native'; import Icon from 'react-native-vector-icons/MaterialCommunityIcons'; +Icon.loadFont(); import Modal from 'react-native-modal'; import Button from './lib/Button'; import TagItem from './lib/TagItem'; @@ -32,6 +33,7 @@ class Select2 extends Component { animatedHeight = new Animated.Value(INIT_HEIGHT); componentDidMount() { + Dimensions.addEventListener("change", this.handleDimensionChange); this.init(); }; @@ -39,6 +41,16 @@ class Select2 extends Component { this.init(newProps); } + componentWillUnmount() { + Dimensions.removeEventListener("change", this.handleDimensionChange) + }; + + handleDimensionChange = e => { + const { height } = e.window; + const INIT_HEIGHT = height * 0.6; + this.animatedHeight.setValue(INIT_HEIGHT); + } + init(newProps) { let preSelectedItem = []; let { data } = newProps || this.props; @@ -148,6 +160,7 @@ class Select2 extends Component { animationOutTiming={300} hideModalContentWhileAnimating isVisible={show}> + @@ -215,6 +228,7 @@ class Select2 extends Component { style={[styles.button, buttonStyle, { marginLeft: 5, marginRight: 10 }]} /> + { preSelectedItem.length > 0