mattermost-mobile/app/components/text_input_with_localized_placeholder.js
Elias Nahum 5ea470a235
V1 dependencies and bump to RN 0.67.2 (#5908)
* update dependencies

* eslint fixes

* Upgrade to RN 67

* update other deps

* Update to RN 0.67.2

* fix Android build (mmkv)

* Fix crash when root message is deleted from the thread screen

* Fix gif emoji playing at high speed on iOS ProMotion capable devices
2022-02-02 15:28:57 -03:00

54 lines
1.3 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import PropTypes from 'prop-types';
import React, {PureComponent} from 'react';
import {intlShape} from 'react-intl';
import {TextInput} from 'react-native';
import {changeOpacity} from '@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,
};
setInputRef = (ref) => {
this.inputRef = ref;
};
blur = () => {
this.inputRef.blur();
};
focus = () => {
this.inputRef.focus();
};
render() {
const {formatMessage} = this.context.intl;
const {placeholder, ...otherProps} = this.props;
let placeholderString = '';
if (placeholder.id) {
placeholderString = formatMessage(placeholder);
}
return (
<TextInput
ref={this.setInputRef}
{...otherProps}
placeholder={placeholderString}
disableFullscreenUI={true}
/>
);
}
}