2021-09-08 23:56:35 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { StyleSheet, View } from 'react-native';
|
|
|
|
|
2022-01-24 15:51:31 +00:00
|
|
|
import I18n from '../i18n';
|
2022-01-17 20:15:58 +00:00
|
|
|
import { useTheme } from '../theme';
|
2021-09-08 23:56:35 +00:00
|
|
|
import sharedStyles from '../views/Styles';
|
2022-04-07 14:10:03 +00:00
|
|
|
import { themes } from '../lib/constants';
|
2022-05-18 19:17:42 +00:00
|
|
|
import TextInput from './TextInput';
|
2022-01-17 20:15:58 +00:00
|
|
|
import { isIOS, isTablet } from '../utils/deviceInfo';
|
|
|
|
import { useOrientation } from '../dimensions';
|
2021-09-08 23:56:35 +00:00
|
|
|
|
|
|
|
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;
|
2022-02-04 22:15:01 +00:00
|
|
|
testID?: string;
|
2021-09-17 19:22:40 +00:00
|
|
|
}
|
|
|
|
|
2022-01-24 15:51:31 +00:00
|
|
|
const SearchHeader = ({ onSearchChangeText, testID }: ISearchHeaderProps): JSX.Element => {
|
2022-01-17 20:15:58 +00:00
|
|
|
const { theme } = useTheme();
|
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 }]}
|
2022-01-24 15:51:31 +00:00
|
|
|
placeholder={I18n.t('Search')}
|
2021-09-08 23:56:35 +00:00
|
|
|
onChangeText={onSearchChangeText}
|
|
|
|
theme={theme}
|
|
|
|
testID={testID}
|
|
|
|
/>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2022-01-17 20:02:53 +00:00
|
|
|
export default SearchHeader;
|