2021-09-08 23:56:35 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { StyleSheet, View } from 'react-native';
|
|
|
|
|
2022-01-17 20:02:53 +00:00
|
|
|
import { useOrientation } from '../dimensions';
|
2021-09-08 23:56:35 +00:00
|
|
|
import { isIOS, isTablet } from '../utils/deviceInfo';
|
|
|
|
import { themes } from '../constants/colors';
|
|
|
|
import sharedStyles from '../views/Styles';
|
|
|
|
import TextInput from '../presentation/TextInput';
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
container: {
|
|
|
|
flex: 1,
|
|
|
|
justifyContent: 'center',
|
|
|
|
marginLeft: 0
|
|
|
|
},
|
|
|
|
title: {
|
|
|
|
...sharedStyles.textSemibold
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-09-17 19:22:40 +00:00
|
|
|
interface ISearchHeaderProps {
|
2021-10-04 17:19:01 +00:00
|
|
|
onSearchChangeText?: (text: string) => void;
|
2021-09-17 19:22:40 +00:00
|
|
|
placeholder: string;
|
|
|
|
theme: string;
|
|
|
|
testID: string;
|
|
|
|
}
|
|
|
|
|
2022-01-17 20:02:53 +00:00
|
|
|
const SearchHeader = ({ onSearchChangeText, placeholder, theme, testID }: ISearchHeaderProps) => {
|
2021-09-08 23:56:35 +00:00
|
|
|
const isLight = theme === 'light';
|
2020-10-30 17:35:07 +00:00
|
|
|
const { isLandscape } = useOrientation();
|
2021-09-08 23:56:35 +00:00
|
|
|
const scale = isIOS && isLandscape && !isTablet ? 0.8 : 1;
|
|
|
|
const titleFontSize = 16 * scale;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<View style={styles.container}>
|
|
|
|
<TextInput
|
|
|
|
autoFocus
|
|
|
|
style={[styles.title, isLight && { color: themes[theme].headerTitleColor }, { fontSize: titleFontSize }]}
|
|
|
|
placeholder={placeholder}
|
|
|
|
onChangeText={onSearchChangeText}
|
|
|
|
theme={theme}
|
|
|
|
testID={testID}
|
|
|
|
/>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2022-01-17 20:02:53 +00:00
|
|
|
export default SearchHeader;
|