Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -32,13 +33,24 @@ class Select2 extends Component {
animatedHeight = new Animated.Value(INIT_HEIGHT);

componentDidMount() {
Dimensions.addEventListener("change", this.handleDimensionChange);
this.init();
};

UNSAFE_componentWillReceiveProps(newProps) {
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;
Expand Down Expand Up @@ -148,6 +160,7 @@ class Select2 extends Component {
animationOutTiming={300}
hideModalContentWhileAnimating
isVisible={show}>
<SafeAreaView style={{justifyContent: 'flex-end', margin: 0}}>
<Animated.View style={[styles.modalContainer, modalStyle, { height: this.animatedHeight }]}>
<View>
<Text style={[styles.title, this.defaultFont, { color: colorTheme }]}>
Expand Down Expand Up @@ -215,6 +228,7 @@ class Select2 extends Component {
style={[styles.button, buttonStyle, { marginLeft: 5, marginRight: 10 }]} />
</View>
</Animated.View>
</SafeAreaView>
</Modal>
{
preSelectedItem.length > 0
Expand Down