Rocket.Chat.ReactNative/app/containers/SearchHeader.tsx

51 lines
1.3 KiB
TypeScript
Raw Normal View History

import React from 'react';
import { StyleSheet, View } from 'react-native';
import { withDimensions } from '../dimensions';
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;
width: number;
height: number;
}
const SearchHeader = ({ onSearchChangeText, placeholder, theme, testID, width, height }: ISearchHeaderProps) => {
const isLight = theme === 'light';
const isLandscape = width > height;
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>
);
};
export default withDimensions(SearchHeader);