Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 5829dbd

Browse files
committed
Display the user's avatar when they shared their location
1 parent d7b3039 commit 5829dbd

File tree

3 files changed

+53
-12
lines changed

3 files changed

+53
-12
lines changed

res/css/views/messages/_MLocationBody.scss

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,30 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
.mx_MLocationBody_map {
18-
width: 450px;
19-
height: 300px;
17+
.mx_MLocationBody {
18+
.mx_MLocationBody_map {
19+
width: 450px;
20+
height: 300px;
2021

21-
border-radius: $timeline-image-border-radius;
22+
border-radius: $timeline-image-border-radius;
23+
}
24+
25+
.mx_MLocationBody_markerBorder {
26+
width: 31px;
27+
height: 31px;
28+
border-radius: 50%;
29+
background-color: $accent;
30+
filter: drop-shadow(0px 3px 5px rgba(0, 0, 0, 0.2));
31+
32+
.mx_BaseAvatar {
33+
margin-top: 2px;
34+
margin-left: 2px;
35+
}
36+
}
37+
38+
.mx_MLocationBody_pointer {
39+
position: absolute;
40+
bottom: -3px;
41+
left: 12px;
42+
}
2243
}

res/img/location/pointer.svg

Lines changed: 3 additions & 0 deletions
Loading

src/components/views/messages/MLocationBody.tsx

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import SdkConfig from '../../../SdkConfig';
2323
import { replaceableComponent } from "../../../utils/replaceableComponent";
2424
import { IBodyProps } from "./IBodyProps";
2525
import { _t } from '../../../languageHandler';
26+
import MemberAvatar from '../avatars/MemberAvatar';
2627

2728
interface IState {
2829
error: Error;
@@ -32,7 +33,6 @@ interface IState {
3233
export default class MLocationBody extends React.Component<IBodyProps, IState> {
3334
private map: maplibregl.Map;
3435
private coords: GeolocationCoordinates;
35-
private description: string;
3636

3737
constructor(props: IBodyProps) {
3838
super(props);
@@ -49,8 +49,6 @@ export default class MLocationBody extends React.Component<IBodyProps, IState> {
4949
this.state = {
5050
error: undefined,
5151
};
52-
53-
this.description = loc?.description ?? content['body'];
5452
}
5553

5654
componentDidMount() {
@@ -65,13 +63,12 @@ export default class MLocationBody extends React.Component<IBodyProps, IState> {
6563
zoom: 13,
6664
});
6765

68-
new maplibregl.Popup({
69-
closeButton: false,
70-
closeOnClick: false,
71-
closeOnMove: false,
66+
new maplibregl.Marker({
67+
element: document.getElementById(this.getMarkerId()),
68+
anchor: 'bottom',
69+
offset: [0, -1],
7270
})
7371
.setLngLat(coordinates)
74-
.setHTML(this.description)
7572
.addTo(this.map);
7673

7774
this.map.on('error', (e)=>{
@@ -88,6 +85,10 @@ export default class MLocationBody extends React.Component<IBodyProps, IState> {
8885
return `mx_MLocationBody_${this.props.mxEvent.getId()}`;
8986
};
9087

88+
private getMarkerId = () => {
89+
return `mx_MLocationBody_marker_${this.props.mxEvent.getId()}`;
90+
};
91+
9192
render() {
9293
const error = this.state.error ?
9394
<div className="mx_EventTile_tileError mx_EventTile_body">
@@ -97,6 +98,22 @@ export default class MLocationBody extends React.Component<IBodyProps, IState> {
9798
return <div className="mx_MLocationBody">
9899
<div id={this.getBodyId()} className="mx_MLocationBody_map" />
99100
{ error }
101+
<div className="mx_MLocationBody_marker" id={this.getMarkerId()}>
102+
<div className="mx_MLocationBody_markerBorder">
103+
<MemberAvatar
104+
member={this.props.mxEvent.sender}
105+
width={27}
106+
height={27}
107+
viewUserOnClick={false}
108+
/>
109+
</div>
110+
<img
111+
className="mx_MLocationBody_pointer"
112+
src={require("../../../../res/img/location/pointer.svg")}
113+
width="9"
114+
height="5"
115+
/>
116+
</div>
100117
</div>;
101118
}
102119
}

0 commit comments

Comments
 (0)