Add UI for displaying room avatars full size

Change the onClick action on the RoomAvatar inside RoomHeader so that it brings
up a lightbox with the full-size avatar.
pull/21833/head
Aidan Gauland 2018-04-21 15:47:31 +12:00
parent 1aadaa3cc5
commit 6a918861bb
2 changed files with 19 additions and 4 deletions

View File

@ -17,6 +17,7 @@ import React from "react";
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import {ContentRepo} from "matrix-js-sdk"; import {ContentRepo} from "matrix-js-sdk";
import MatrixClientPeg from "../../../MatrixClientPeg"; import MatrixClientPeg from "../../../MatrixClientPeg";
import Modal from '../../../Modal';
import sdk from "../../../index"; import sdk from "../../../index";
module.exports = React.createClass({ module.exports = React.createClass({
@ -31,6 +32,7 @@ module.exports = React.createClass({
width: PropTypes.number, width: PropTypes.number,
height: PropTypes.number, height: PropTypes.number,
resizeMethod: PropTypes.string, resizeMethod: PropTypes.string,
viewAvatarOnClick: PropTypes.bool,
}, },
getDefaultProps: function() { getDefaultProps: function() {
@ -159,6 +161,19 @@ module.exports = React.createClass({
} }
}, },
onRoomAvatarClick: function() {
const avatarUrl = this.props.room.getAvatarUrl(
MatrixClientPeg.get().getHomeserverUrl(),
null, null, null, false);
const ImageView = sdk.getComponent("elements.ImageView");
const params = {
src: avatarUrl,
name: this.props.room.name,
};
Modal.createDialog(ImageView, params, "mx_Dialog_lightbox");
},
render: function() { render: function() {
const BaseAvatar = sdk.getComponent("avatars.BaseAvatar"); const BaseAvatar = sdk.getComponent("avatars.BaseAvatar");
@ -169,7 +184,8 @@ module.exports = React.createClass({
return ( return (
<BaseAvatar {...otherProps} name={roomName} <BaseAvatar {...otherProps} name={roomName}
idName={room ? room.roomId : null} idName={room ? room.roomId : null}
urls={this.state.urls} /> urls={this.state.urls}
onClick={this.props.viewAvatarOnClick ? this.onRoomAvatarClick : null} />
); );
}, },
}); });

View File

@ -327,9 +327,8 @@ module.exports = React.createClass({
); );
} else if (this.props.room || (this.props.oobData && this.props.oobData.name)) { } else if (this.props.room || (this.props.oobData && this.props.oobData.name)) {
roomAvatar = ( roomAvatar = (
<div onClick={this.props.onSettingsClick}> <RoomAvatar room={this.props.room} width={48} height={48} oobData={this.props.oobData}
<RoomAvatar room={this.props.room} width={48} height={48} oobData={this.props.oobData} /> viewAvatarOnClick={true} />
</div>
); );
} }