2020-10-30 17:35:07 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { StyleSheet, View } from 'react-native';
|
|
|
|
|
2021-09-22 17:29:26 +00:00
|
|
|
import { withTheme } from '../theme';
|
|
|
|
import sharedStyles from '../views/Styles';
|
|
|
|
import { themes } from '../constants/colors';
|
|
|
|
import TextInput from '../presentation/TextInput';
|
|
|
|
import { isIOS, isTablet } from '../utils/deviceInfo';
|
|
|
|
import { useOrientation } from '../dimensions';
|
2020-10-30 17:35:07 +00:00
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
container: {
|
|
|
|
flex: 1,
|
|
|
|
justifyContent: 'center',
|
|
|
|
marginLeft: 0
|
|
|
|
},
|
|
|
|
title: {
|
|
|
|
...sharedStyles.textSemibold
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2022-01-17 16:10:39 +00:00
|
|
|
interface ISearchHeader {
|
|
|
|
theme?: string;
|
|
|
|
onSearchChangeText?: (text: string) => void;
|
|
|
|
}
|
|
|
|
|
2020-10-30 17:35:07 +00:00
|
|
|
// TODO: it might be useful to refactor this component for reusage
|
2022-01-17 16:10:39 +00:00
|
|
|
const SearchHeader = ({ theme, onSearchChangeText }: ISearchHeader) => {
|
|
|
|
const titleColorStyle = { color: themes[theme!].headerTitleColor };
|
2020-10-30 17:35:07 +00:00
|
|
|
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 }]}
|
|
|
|
placeholder='Search'
|
|
|
|
onChangeText={onSearchChangeText}
|
2022-01-17 16:10:39 +00:00
|
|
|
theme={theme!}
|
2020-10-30 17:35:07 +00:00
|
|
|
testID='thread-messages-view-search-header'
|
|
|
|
/>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default withTheme(SearchHeader);
|