Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move voip previews to bottom right corner #4904

Merged
merged 10 commits into from
Jul 8, 2020
3 changes: 3 additions & 0 deletions res/css/_components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
@import "./views/avatars/_BaseAvatar.scss";
@import "./views/avatars/_DecoratedRoomAvatar.scss";
@import "./views/avatars/_MemberStatusMessageAvatar.scss";
@import "./views/avatars/_PulsedAatar.scss";
turt2live marked this conversation as resolved.
Show resolved Hide resolved
@import "./views/context_menus/_MessageContextMenu.scss";
@import "./views/context_menus/_RoomTileContextMenu.scss";
@import "./views/context_menus/_StatusMessageContextMenu.scss";
Expand Down Expand Up @@ -225,6 +226,8 @@
@import "./views/settings/tabs/user/_VoiceUserSettingsTab.scss";
@import "./views/terms/_InlineTermsAgreement.scss";
@import "./views/verification/_VerificationShowSas.scss";
@import "./views/voip/_CallContainer.scss";
@import "./views/voip/_CallView.scss";
@import "./views/voip/_CallView2.scss";
@import "./views/voip/_IncomingCallbox.scss";
@import "./views/voip/_VideoView.scss";
30 changes: 30 additions & 0 deletions res/css/views/avatars/_PulsedAatar.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
Copyright 2020 The Matrix.org Foundation C.I.C.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

.mx_PulsedAvatar {
@keyframes shadow-pulse {
0% {
box-shadow: 0 0 0 0px rgba($accent-color, 0.2);
}
100% {
box-shadow: 0 0 0 6px rgba($accent-color, 0);
}
}

img {
animation: shadow-pulse 1s infinite;
}
}
89 changes: 89 additions & 0 deletions res/css/views/voip/_CallContainer.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
Copyright 2020 The Matrix.org Foundation C.I.C.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

.mx_CallContainer {
position: absolute;
right: 20px;
bottom: 72px;
border-radius: 8px;
overflow: hidden;
z-index: 100;
box-shadow: 0px 14px 24px rgba(0, 0, 0, 0.08);

cursor: pointer;

.mx_CallPreview {
.mx_VideoView {
width: 350px;
}

.mx_VideoView_localVideoFeed {
border-radius: 8px;
overflow: hidden;
}
}

.mx_IncomingCallBox2 {
min-width: 250px;
background-color: $primary-bg-color;
padding: 8px;

.mx_IncomingCallBox2_CallerInfo {
display: flex;
direction: row;

img {
margin: 8px;
}

> div {
display: flex;
flex-direction: column;

justify-content: center;
}

h1, p {
margin: 0px;
padding: 0px;
font-size: $font-14px;
line-height: $font-16px;
}

h1 {
font-weight: bold;
}
}

.mx_IncomingCallBox2_buttons {
padding: 8px;
display: flex;
flex-direction: row;

> .mx_IncomingCallBox2_spacer {
width: 8px;
}

> * {
flex-shrink: 0;
flex-grow: 1;
margin-right: 0;
font-size: $font-15px;
line-height: $font-24px;
}
}
}
}
94 changes: 94 additions & 0 deletions res/css/views/voip/_CallView2.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
Copyright 2015, 2016 OpenMarket Ltd
Copyright 2020 The Matrix.org Foundation C.I.C.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

turt2live marked this conversation as resolved.
Show resolved Hide resolved
.mx_CallView2_voice {
background-color: $accent-color;
color: $accent-fg-color;
cursor: pointer;
padding: 6px;
font-weight: bold;

border-radius: 8px;
min-width: 200px;

display: flex;
align-items: center;

img {
margin: 4px;
margin-right: 10px;
}

> div {
display: flex;
flex-direction: column;
// Hacky vertical align
padding-top: 3px;
}

> div > p,
> div > h1 {
padding: 0;
margin: 0;
font-size: $font-13px;
line-height: $font-15px;
}

> div > p {
font-weight: bold;
}

> * {
flex-grow: 0;
flex-shrink: 0;
}
}

.mx_CallView2_hangup {
position: absolute;

right: 8px;
bottom: 10px;

height: 35px;
width: 35px;

border-radius: 35px;

background-color: $notice-primary-color;

z-index: 101;

cursor: pointer;

&::before {
content: '';
position: absolute;

height: 20px;
width: 20px;

top: 6.5px;
left: 7.5px;

mask: url('$(res)/img/hangup.svg');
mask-size: contain;
background-size: contain;

background-color: $primary-fg-color;
}
}
2 changes: 2 additions & 0 deletions src/components/structures/LoggedInView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import {
} from "../../toasts/ServerLimitToast";
import { Action } from "../../dispatcher/actions";
import LeftPanel2 from "./LeftPanel2";
import CallContainer from '../views/voip/CallContainer';

// We need to fetch each pinned message individually (if we don't already have it)
// so each pinned message may trigger a request. Limit the number per room for sanity.
Expand Down Expand Up @@ -703,6 +704,7 @@ class LoggedInView extends React.Component<IProps, IState> {
</div>
</DragDropContext>
</div>
<CallContainer />
</MatrixClientContext.Provider>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,31 @@ limitations under the License.
*/

import React, {useCallback, useContext, useEffect, useMemo, useState} from 'react';
import PropTypes from 'prop-types';
import * as AvatarLogic from '../../../Avatar';
import SettingsStore from "../../../settings/SettingsStore";
import AccessibleButton from '../elements/AccessibleButton';
import MatrixClientContext from "../../../contexts/MatrixClientContext";
import {useEventEmitter} from "../../../hooks/useEventEmitter";
import {toPx} from "../../../utils/units";

const useImageUrl = ({url, urls}) => {
const [imageUrls, setUrls] = useState([]);
const [urlsIndex, setIndex] = useState();
interface IProps {
name: string; // The name (first initial used as default)
idName?: string; // ID for generating hash colours
title?: string; // onHover title text
url?: string; // highest priority of them all, shortcut to set in urls[0]
urls?: string[]; // [highest_priority, ... , lowest_priority]
width?: number;
height?: number;
// XXX: resizeMethod not actually used.
resizeMethod?: string;
defaultToInitialLetter?: boolean; // true to add default url
onClick?: React.MouseEventHandler;
inputRef?: React.RefObject<HTMLImageElement & HTMLSpanElement>;
}

const useImageUrl = ({url, urls}): [string, () => void] => {
const [imageUrls, setUrls] = useState<string[]>([]);
const [urlsIndex, setIndex] = useState<number>();

const onError = useCallback(() => {
setIndex(i => i + 1); // try the next one
Expand Down Expand Up @@ -70,7 +84,7 @@ const useImageUrl = ({url, urls}) => {
return [imageUrl, onError];
};

const BaseAvatar = (props) => {
const BaseAvatar = (props: IProps) => {
const {
name,
idName,
Expand Down Expand Up @@ -173,26 +187,5 @@ const BaseAvatar = (props) => {
}
};

BaseAvatar.displayName = "BaseAvatar";

BaseAvatar.propTypes = {
name: PropTypes.string.isRequired, // The name (first initial used as default)
idName: PropTypes.string, // ID for generating hash colours
title: PropTypes.string, // onHover title text
url: PropTypes.string, // highest priority of them all, shortcut to set in urls[0]
urls: PropTypes.array, // [highest_priority, ... , lowest_priority]
width: PropTypes.number,
height: PropTypes.number,
// XXX resizeMethod not actually used.
resizeMethod: PropTypes.string,
defaultToInitialLetter: PropTypes.bool, // true to add default url
onClick: PropTypes.func,
inputRef: PropTypes.oneOfType([
// Either a function
PropTypes.func,
// Or the instance of a DOM native element
PropTypes.shape({ current: PropTypes.instanceOf(Element) }),
]),
};

export default BaseAvatar;
export type BaseAvatarType = React.FC<IProps>;
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,36 @@ limitations under the License.
*/

import React from 'react';
import PropTypes from 'prop-types';
import createReactClass from 'create-react-class';
import * as sdk from '../../../index';
import {MatrixClientPeg} from '../../../MatrixClientPeg';

export default createReactClass({
displayName: 'GroupAvatar',

propTypes: {
groupId: PropTypes.string,
groupName: PropTypes.string,
groupAvatarUrl: PropTypes.string,
width: PropTypes.number,
height: PropTypes.number,
resizeMethod: PropTypes.string,
onClick: PropTypes.func,
},

getDefaultProps: function() {
return {
width: 36,
height: 36,
resizeMethod: 'crop',
};
},

getGroupAvatarUrl: function() {
import BaseAvatar from './BaseAvatar';

export interface IProps {
groupId?: string,
groupName?: string,
groupAvatarUrl?: string,
width?: number,
height?: number,
resizeMethod?: string,
onClick?: React.MouseEventHandler,
}

export default class GroupAvatar extends React.Component<IProps> {
public static defaultProps = {
width: 36,
height: 36,
resizeMethod: 'crop',
};

getGroupAvatarUrl() {
return MatrixClientPeg.get().mxcUrlToHttp(
this.props.groupAvatarUrl,
this.props.width,
this.props.height,
this.props.resizeMethod,
);
},
}

render: function() {
const BaseAvatar = sdk.getComponent("avatars.BaseAvatar");
render() {
// extract the props we use from props so we can pass any others through
// should consider adding this as a global rule in js-sdk?
/*eslint no-unused-vars: ["error", { "ignoreRestSiblings": true }]*/
Expand All @@ -65,5 +58,5 @@ export default createReactClass({
{...otherProps}
/>
);
},
});
}
}
Loading