Files
mattermost-mobile/app/components/text_input_with_localized_placeholder.js
Miguel Alatzar d8f9dcc233 [MM-17637] Add flex 1 to wrapper view (#3087)
* Add flex 1

* Add snapshot test

* Fix placeholder text color
2019-08-12 08:22:21 -04:00

51 lines
1.3 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';
import {intlShape} from 'react-intl';
import {TextInput} from 'react-native';
import {changeOpacity} from 'app/utils/theme';
export default class TextInputWithLocalizedPlaceholder extends PureComponent {
static propTypes = {
...TextInput.propTypes,
placeholder: PropTypes.object.isRequired,
};
static defaultProps = {
placeholderTextColor: changeOpacity('#000', 0.5),
};
static contextTypes = {
intl: intlShape.isRequired,
};
blur = () => {
this.refs.input.blur();
};
focus = () => {
this.refs.input.focus();
};
render() {
const {formatMessage} = this.context.intl;
const {placeholder, ...otherProps} = this.props;
let placeholderString = '';
if (placeholder.id) {
placeholderString = formatMessage(placeholder);
}
return (
<TextInput
ref='input'
{...otherProps}
placeholder={placeholderString}
disableFullscreenUI={true}
/>
);
}
}