import { PureComponent } from 'react'; import Column from 'flavours/glitch/components/column'; import ColumnBackButton from 'flavours/glitch/components/column_back_button'; import PropTypes from 'prop-types'; import { me, domain } from 'flavours/glitch/initial_state'; import { connect } from 'react-redux'; import ImmutablePropTypes from 'react-immutable-proptypes'; import { defineMessages, injectIntl, FormattedMessage, FormattedHTMLMessage } from 'react-intl'; import classNames from 'classnames'; import { Icon } from 'flavours/glitch/components/icon'; import ArrowSmallRight from './components/arrow_small_right'; import { Link } from 'react-router-dom'; import SwipeableViews from 'react-swipeable-views'; const messages = defineMessages({ shareableMessage: { id: 'onboarding.share.message', defaultMessage: 'I\'m {username} on #Mastodon! Come follow me at {url}' }, }); const mapStateToProps = state => ({ account: state.getIn(['accounts', me]), }); class CopyPasteText extends PureComponent { static propTypes = { value: PropTypes.string, }; state = { copied: false, focused: false, }; setRef = c => { this.input = c; }; handleInputClick = () => { this.setState({ copied: false }); this.input.focus(); this.input.select(); this.input.setSelectionRange(0, this.props.value.length); }; handleButtonClick = e => { e.stopPropagation(); const { value } = this.props; navigator.clipboard.writeText(value); this.input.blur(); this.setState({ copied: true }); this.timeout = setTimeout(() => this.setState({ copied: false }), 700); }; handleFocus = () => { this.setState({ focused: true }); }; handleBlur = () => { this.setState({ focused: false }); }; componentWillUnmount () { if (this.timeout) clearTimeout(this.timeout); } render () { const { value } = this.props; const { copied, focused } = this.state; return (