import PropTypes from 'prop-types'; import { PureComponent } from 'react'; import { defineMessages, useIntl, FormattedMessage } from 'react-intl'; import classNames from 'classnames'; import { Link } from 'react-router-dom'; import SwipeableViews from 'react-swipeable-views'; import ArrowRightAltIcon from '@/material-icons/400-24px/arrow_right_alt.svg?react'; import { ColumnBackButton } from 'mastodon/components/column_back_button'; import { CopyPasteText } from 'mastodon/components/copy_paste_text'; import { Icon } from 'mastodon/components/icon'; import { me, domain } from 'mastodon/initial_state'; import { useAppSelector } from 'mastodon/store'; const messages = defineMessages({ shareableMessage: { id: 'onboarding.share.message', defaultMessage: 'I\'m {username} on #Mastodon! Come follow me at {url}' }, }); class TipCarousel extends PureComponent { static propTypes = { children: PropTypes.node, }; state = { index: 0, }; handleSwipe = index => { this.setState({ index }); }; handleChangeIndex = e => { this.setState({ index: Number(e.currentTarget.getAttribute('data-index')) }); }; handleKeyDown = e => { switch(e.key) { case 'ArrowLeft': e.preventDefault(); this.setState(({ index }, { children }) => ({ index: Math.abs(index - 1) % children.length })); break; case 'ArrowRight': e.preventDefault(); this.setState(({ index }, { children }) => ({ index: (index + 1) % children.length })); break; } }; render () { const { children } = this.props; const { index } = this.state; return (
{children}
{children.map((_, i) => ( ))}
); } } export const Share = () => { const account = useAppSelector(state => state.getIn(['accounts', me])); const intl = useIntl(); const url = (new URL(`/@${account.get('username')}`, document.baseURI)).href; return ( <>

{chunks} }} />

{chunks} }} />

{chunks} }} />

); };