verdnatura-chat/app/views/ShareListView/Header/Header.android.js

53 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

2019-07-29 16:33:28 +00:00
import React from 'react';
2019-12-04 16:39:53 +00:00
import { View, StyleSheet, Text } from 'react-native';
2019-07-29 16:33:28 +00:00
import PropTypes from 'prop-types';
2019-12-04 16:39:53 +00:00
import TextInput from '../../../presentation/TextInput';
2019-07-29 16:33:28 +00:00
import I18n from '../../../i18n';
2019-12-04 16:39:53 +00:00
import { themes } from '../../../constants/colors';
2019-07-29 16:33:28 +00:00
import sharedStyles from '../../Styles';
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center'
},
search: {
fontSize: 20,
...sharedStyles.textRegular,
marginHorizontal: 14
},
title: {
fontSize: 20,
...sharedStyles.textBold,
marginHorizontal: 16
}
});
2019-12-04 16:39:53 +00:00
const Header = React.memo(({ searching, onChangeSearchText, theme }) => {
const titleColorStyle = { color: themes[theme].headerTintColor };
const isLight = theme === 'light';
2019-07-29 16:33:28 +00:00
if (searching) {
return (
<View style={styles.container}>
<TextInput
2019-12-04 16:39:53 +00:00
style={[styles.search, isLight && titleColorStyle]}
2019-07-29 16:33:28 +00:00
placeholder={I18n.t('Search')}
onChangeText={onChangeSearchText}
2019-12-04 16:39:53 +00:00
theme={theme}
2019-07-29 16:33:28 +00:00
autoFocus
/>
</View>
);
}
2019-12-04 16:39:53 +00:00
return <Text style={[styles.title, titleColorStyle]}>{I18n.t('Send_to')}</Text>;
2019-07-29 16:33:28 +00:00
});
Header.propTypes = {
searching: PropTypes.bool,
2019-12-04 16:39:53 +00:00
onChangeSearchText: PropTypes.func,
theme: PropTypes.string
2019-07-29 16:33:28 +00:00
};
export default Header;