import React from 'react'; import { Avatar } from './Avatar'; import { SessionModal } from './session/SessionModal'; import { SessionButton, SessionButtonColor, SessionButtonType, } from './session/SessionButton'; import { SessionIdEditable } from './session/SessionIdEditable'; import { DefaultTheme } from 'styled-components'; interface Props { i18n: any; profileName: string; avatarPath: string; pubkey: string; onClose: any; onStartConversation: any; theme: DefaultTheme; } interface State { isEnlargedImageShown: boolean; } export class UserDetailsDialog extends React.Component { constructor(props: any) { super(props); this.closeDialog = this.closeDialog.bind(this); this.onKeyUp = this.onKeyUp.bind(this); this.onClickStartConversation = this.onClickStartConversation.bind(this); window.addEventListener('keyup', this.onKeyUp); this.state = { isEnlargedImageShown: false }; } public render() { const { i18n } = this.props; return (
{this.renderAvatar()}
); } private renderAvatar() { const { avatarPath, pubkey, profileName } = this.props; const size = this.state.isEnlargedImageShown ? 300 : 80; const userName = name || profileName || pubkey; return ( ); } private readonly handleShowEnlargedDialog = () => { this.setState({ isEnlargedImageShown: !this.state.isEnlargedImageShown }); }; private onKeyUp(event: any) { switch (event.key) { case 'Enter': this.onClickStartConversation(); break; case 'Esc': case 'Escape': this.closeDialog(); break; default: } } private closeDialog() { window.removeEventListener('keyup', this.onKeyUp); this.props.onClose(); } private onClickStartConversation() { this.props.onStartConversation(); this.closeDialog(); } }