Merge pull request #681 from Bilb/655-clickable-profile

655 clickable profile
pull/693/head
Audric Ackermann 6 years ago committed by GitHub
commit 33c641e2f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1014,6 +1014,13 @@
}); });
Whisper.events.on('onShowUserDetails', async ({ userPubKey }) => { Whisper.events.on('onShowUserDetails', async ({ userPubKey }) => {
const isMe = userPubKey === textsecure.storage.user.getNumber();
if (isMe) {
Whisper.events.trigger('onEditProfile');
return;
}
const conversation = await ConversationController.getOrCreateAndWait( const conversation = await ConversationController.getOrCreateAndWait(
userPubKey, userPubKey,
'private' 'private'

@ -2199,6 +2199,27 @@
width: 42px; width: 42px;
} }
.module-avatar--300 {
height: 300px;
width: 300px;
img {
height: 300px;
width: 300px;
}
}
.module-avatar__label--300 {
width: 300px;
font-size: 150px;
line-height: 302px;
}
.module-avatar__icon--300 {
height: 158px;
width: 158px;
}
.module-avatar__icon--note-to-self { .module-avatar__icon--note-to-self {
width: 70%; width: 70%;
height: 70%; height: 70%;

@ -162,7 +162,13 @@ export class Avatar extends React.PureComponent<Props, State> {
const hasAvatar = avatarPath || conversationType === 'direct'; const hasAvatar = avatarPath || conversationType === 'direct';
const hasImage = !noteToSelf && hasAvatar && !imageBroken; const hasImage = !noteToSelf && hasAvatar && !imageBroken;
if (size !== 28 && size !== 36 && size !== 48 && size !== 80) { if (
size !== 28 &&
size !== 36 &&
size !== 48 &&
size !== 80 &&
size !== 300
) {
throw new Error(`Size ${size} is not supported!`); throw new Error(`Size ${size} is not supported!`);
} }

@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
const styles = { const styles = {
borderRadius: '50px', borderRadius: '50%',
display: 'inline-block', display: 'inline-block',
margin: 0, margin: 0,
overflow: 'hidden', overflow: 'hidden',

@ -232,6 +232,9 @@ export class MainHeader extends React.Component<Props, any> {
phoneNumber={phoneNumber} phoneNumber={phoneNumber}
profileName={profileName} profileName={profileName}
size={28} size={28}
onAvatarClick={() => {
trigger('onEditProfile');
}}
/> />
<div className="module-main-header__contact-name"> <div className="module-main-header__contact-name">
<ContactName <ContactName

@ -17,7 +17,13 @@ interface Props {
onStartConversation: any; onStartConversation: any;
} }
export class UserDetailsDialog extends React.Component<Props> { interface State {
isEnlargedImageShown: boolean;
}
export class UserDetailsDialog extends React.Component<Props, State> {
private modalRef: any;
constructor(props: any) { constructor(props: any) {
super(props); super(props);
@ -25,6 +31,16 @@ export class UserDetailsDialog extends React.Component<Props> {
this.onKeyUp = this.onKeyUp.bind(this); this.onKeyUp = this.onKeyUp.bind(this);
this.onClickStartConversation = this.onClickStartConversation.bind(this); this.onClickStartConversation = this.onClickStartConversation.bind(this);
window.addEventListener('keyup', this.onKeyUp); window.addEventListener('keyup', this.onKeyUp);
this.modalRef = React.createRef();
this.state = { isEnlargedImageShown: false };
}
public componentWillMount() {
document.addEventListener('mousedown', this.handleClick, false);
}
public componentWillUnmount() {
document.removeEventListener('mousedown', this.handleClick, false);
} }
public render() { public render() {
@ -34,6 +50,7 @@ export class UserDetailsDialog extends React.Component<Props> {
const startConversation = i18n('startConversation'); const startConversation = i18n('startConversation');
return ( return (
<div ref={element => (this.modalRef = element)}>
<div className="content"> <div className="content">
<div className="avatar-center"> <div className="avatar-center">
<div className="avatar-center-inner">{this.renderAvatar()}</div> <div className="avatar-center-inner">{this.renderAvatar()}</div>
@ -55,12 +72,14 @@ export class UserDetailsDialog extends React.Component<Props> {
</button> </button>
</div> </div>
</div> </div>
</div>
); );
} }
private renderAvatar() { private renderAvatar() {
const avatarPath = this.props.avatarPath; const avatarPath = this.props.avatarPath;
const color = this.props.avatarColor; const color = this.props.avatarColor;
const size = this.state.isEnlargedImageShown ? 300 : 80;
return ( return (
<Avatar <Avatar
@ -71,11 +90,17 @@ export class UserDetailsDialog extends React.Component<Props> {
name={this.props.profileName} name={this.props.profileName}
phoneNumber={this.props.pubkey} phoneNumber={this.props.pubkey}
profileName={this.props.profileName} profileName={this.props.profileName}
size={80} size={size}
onAvatarClick={this.handleShowEnlargedDialog}
borderWidth={size / 2}
/> />
); );
} }
private readonly handleShowEnlargedDialog = () => {
this.setState({ isEnlargedImageShown: !this.state.isEnlargedImageShown });
};
private onKeyUp(event: any) { private onKeyUp(event: any) {
switch (event.key) { switch (event.key) {
case 'Enter': case 'Enter':
@ -98,4 +123,11 @@ export class UserDetailsDialog extends React.Component<Props> {
this.props.onStartConversation(); this.props.onStartConversation();
this.closeDialog(); this.closeDialog();
} }
private readonly handleClick = (e: any) => {
if (this.modalRef.contains(e.target)) {
return;
}
this.closeDialog();
};
} }

Loading…
Cancel
Save