2020-10-30 17:35:07 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { StyleSheet, View } from 'react-native';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
2021-09-03 15:11:57 +00:00
|
|
|
import { useTheme, withTheme } from '../../theme';
|
2020-10-30 17:35:07 +00:00
|
|
|
import sharedStyles from '../Styles';
|
|
|
|
import { themes } from '../../constants/colors';
|
|
|
|
import TextInput from '../../presentation/TextInput';
|
|
|
|
import { isTablet, isIOS } from '../../utils/deviceInfo';
|
|
|
|
import { useOrientation } from '../../dimensions';
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
container: {
|
|
|
|
flex: 1,
|
|
|
|
justifyContent: 'center',
|
|
|
|
marginLeft: 0
|
|
|
|
},
|
|
|
|
title: {
|
|
|
|
...sharedStyles.textSemibold
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// TODO: it might be useful to refactor this component for reusage
|
2021-09-03 15:11:57 +00:00
|
|
|
const SearchHeader = ({ onSearchChangeText, placeholder }) => {
|
|
|
|
const { theme } = useTheme();
|
2020-10-30 17:35:07 +00:00
|
|
|
const titleColorStyle = { color: themes[theme].headerTitleColor };
|
|
|
|
const isLight = theme === 'light';
|
|
|
|
const { isLandscape } = useOrientation();
|
|
|
|
const scale = isIOS && isLandscape && !isTablet ? 0.8 : 1;
|
|
|
|
const titleFontSize = 16 * scale;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<View style={styles.container}>
|
|
|
|
<TextInput
|
|
|
|
autoFocus
|
|
|
|
style={[styles.title, isLight && titleColorStyle, { fontSize: titleFontSize }]}
|
2021-09-03 15:11:57 +00:00
|
|
|
placeholder={placeholder || 'Search'}
|
2020-10-30 17:35:07 +00:00
|
|
|
onChangeText={onSearchChangeText}
|
|
|
|
theme={theme}
|
|
|
|
testID='thread-messages-view-search-header'
|
|
|
|
/>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
SearchHeader.propTypes = {
|
2021-09-03 15:11:57 +00:00
|
|
|
onSearchChangeText: PropTypes.func,
|
|
|
|
placeholder: PropTypes.string
|
2020-10-30 17:35:07 +00:00
|
|
|
};
|
|
|
|
export default withTheme(SearchHeader);
|