Skip to content

Instantly share code, notes, and snippets.

@hisothreed
Last active January 8, 2020 03:20
Show Gist options
  • Select an option

  • Save hisothreed/845bc1136729c558961db8d93e829e92 to your computer and use it in GitHub Desktop.

Select an option

Save hisothreed/845bc1136729c558961db8d93e829e92 to your computer and use it in GitHub Desktop.
import React, {useState, useEffect} from 'react';
import styled from 'styled-components/native';
import {Animated, StyleSheet, FlatList, Text} from 'react-native';
const SearchItem = styled.TouchableOpacity`
border-bottom-color: rgba(0, 0, 0, 0.05);
border-bottom-width: 1;
padding-vertical: 20;
padding-horizontal: 15;
`;
function SearchOverlay(props) {
const [isVisible, setIsVisible] = useState(false);
useEffect(() => {
setIsVisible(props.isVisible);
}, [props.isVisible]);
const renderItem = ({item}) => {
return (
<SearchItem>
<Text>{item.label}</Text>
</SearchItem>
);
};
return isVisible ? (
<Animated.View style={[styles.container]}>
<FlatList
keyExtractor={item => item.value}
renderItem={renderItem}
data={[{label: 'New York', value: 1}]}
/>
</Animated.View>
) : null;
}
const styles = StyleSheet.create({
container: {
flexGrow: 1,
left: 0,
right: 0,
top: 0,
bottom: 0,
backgroundColor: 'white',
position: 'absolute',
width: '100%',
height: '100%',
zIndex: 1000000,
},
});
export default SearchOverlay;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment