2018-08-31 16:46:33 +00:00
|
|
|
import React from 'react';
|
2018-09-25 19:28:42 +00:00
|
|
|
import {
|
|
|
|
Text, View, TouchableOpacity, Image, StyleSheet
|
|
|
|
} from 'react-native';
|
2018-08-31 16:46:33 +00:00
|
|
|
import PropTypes from 'prop-types';
|
2018-10-23 21:39:48 +00:00
|
|
|
import { TextInput } from 'react-native-gesture-handler';
|
2018-08-31 16:46:33 +00:00
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
container: {
|
|
|
|
flex: 1,
|
|
|
|
justifyContent: 'center'
|
|
|
|
},
|
|
|
|
button: {
|
|
|
|
flexDirection: 'row',
|
|
|
|
alignItems: 'center'
|
|
|
|
},
|
|
|
|
server: {
|
|
|
|
fontSize: 20,
|
|
|
|
color: '#FFF'
|
|
|
|
},
|
|
|
|
disclosure: {
|
|
|
|
marginLeft: 9,
|
|
|
|
marginTop: 1,
|
|
|
|
width: 10,
|
|
|
|
height: 5
|
|
|
|
},
|
|
|
|
upsideDown: {
|
|
|
|
transform: [{ scaleY: -1 }]
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-10-23 21:39:48 +00:00
|
|
|
const Header = ({
|
|
|
|
onPress, serverName, showServerDropdown, setSearchInputRef, showSearchHeader, onSearchChangeText
|
|
|
|
}) => {
|
|
|
|
if (showSearchHeader) {
|
|
|
|
return (
|
|
|
|
<View style={styles.container}>
|
|
|
|
<TextInput
|
|
|
|
ref={setSearchInputRef}
|
|
|
|
style={styles.server}
|
|
|
|
placeholder='Search'
|
|
|
|
placeholderTextColor='rgba(255, 255, 255, 0.5)'
|
|
|
|
onChangeText={onSearchChangeText}
|
|
|
|
/>
|
2018-08-31 16:46:33 +00:00
|
|
|
</View>
|
2018-10-23 21:39:48 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<View style={styles.container}>
|
|
|
|
<TouchableOpacity onPress={onPress} testID='rooms-list-header-server-dropdown-button'>
|
|
|
|
<View style={styles.button}>
|
|
|
|
<Text style={styles.server}>{serverName}</Text>
|
|
|
|
<Image style={[styles.disclosure, showServerDropdown && styles.upsideDown]} source={{ uri: 'disclosure_indicator_server' }} />
|
|
|
|
</View>
|
|
|
|
</TouchableOpacity>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
};
|
2018-08-31 16:46:33 +00:00
|
|
|
|
|
|
|
Header.propTypes = {
|
2018-10-23 21:39:48 +00:00
|
|
|
showServerDropdown: PropTypes.bool.isRequired,
|
|
|
|
showSearchHeader: PropTypes.bool.isRequired,
|
2018-08-31 16:46:33 +00:00
|
|
|
onPress: PropTypes.func.isRequired,
|
2018-10-23 21:39:48 +00:00
|
|
|
onSearchChangeText: PropTypes.func.isRequired,
|
|
|
|
setSearchInputRef: PropTypes.func.isRequired,
|
|
|
|
serverName: PropTypes.string
|
2018-08-31 16:46:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Header.defaultProps = {
|
|
|
|
serverName: 'Rocket.Chat'
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Header;
|