Skip to content

Commit

Permalink
Merge pull request #4904 from matrix-org/joriks/room-list-voip
Browse files Browse the repository at this point in the history
Move voip previews to bottom right corner
  • Loading branch information
turt2live committed Jul 8, 2020
2 parents fb6791e + 5ba64aa commit 0368bff
Show file tree
Hide file tree
Showing 16 changed files with 923 additions and 167 deletions.
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/_PulsedAvatar.scss";
@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/_PulsedAvatar.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;
}
}
}
}
96 changes: 96 additions & 0 deletions res/css/views/voip/_CallView2.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
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.
*/

// TODO: Rename on launch: https://github.com/vector-im/riot-web/issues/14231

.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 @@ -52,6 +52,7 @@ import {
} from "../../toasts/ServerLimitToast";
import { Action } from "../../dispatcher/actions";
import LeftPanel2 from "./LeftPanel2";
import CallContainer from '../views/voip/CallContainer';
import { ViewRoomDeltaPayload } from "../../dispatcher/payloads/ViewRoomDeltaPayload";

// We need to fetch each pinned message individually (if we don't already have it)
Expand Down Expand Up @@ -696,6 +697,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,33 @@ limitations under the License.
*/

import React, {useCallback, useContext, useEffect, useMemo, useState} from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
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>;
className?: string;
}

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,17 +86,17 @@ const useImageUrl = ({url, urls}) => {
return [imageUrl, onError];
};

const BaseAvatar = (props) => {
const BaseAvatar = (props: IProps) => {
const {
name,
idName,
title,
url,
urls,
width=40,
height=40,
resizeMethod="crop", // eslint-disable-line no-unused-vars
defaultToInitialLetter=true,
width = 40,
height = 40,
resizeMethod = "crop", // eslint-disable-line no-unused-vars
defaultToInitialLetter = true,
onClick,
inputRef,
...otherProps
Expand Down Expand Up @@ -117,7 +133,7 @@ const BaseAvatar = (props) => {
aria-hidden="true" />
);

if (onClick != null) {
if (onClick !== null) {
return (
<AccessibleButton
{...otherProps}
Expand All @@ -132,15 +148,20 @@ const BaseAvatar = (props) => {
);
} else {
return (
<span className="mx_BaseAvatar" ref={inputRef} {...otherProps} role="presentation">
<span
className="mx_BaseAvatar"
ref={inputRef}
{...otherProps}
role="presentation"
>
{ textNode }
{ imgNode }
</span>
);
}
}

if (onClick != null) {
if (onClick !== null) {
return (
<AccessibleButton
className="mx_BaseAvatar mx_BaseAvatar_image"
Expand Down Expand Up @@ -173,26 +194,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>;
Loading

0 comments on commit 0368bff

Please sign in to comment.