Add share button and refoctor
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
parent
e5188a5258
commit
c5ee2a6b32
2 changed files with 55 additions and 30 deletions
|
@ -53,6 +53,7 @@ limitations under the License.
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mx_desktopCapturerSourcePicker_stream_button_selected,
|
||||||
.mx_desktopCapturerSourcePicker_stream_button:hover,
|
.mx_desktopCapturerSourcePicker_stream_button:hover,
|
||||||
.mx_desktopCapturerSourcePicker_stream_button:focus {
|
.mx_desktopCapturerSourcePicker_stream_button:focus {
|
||||||
background: $roomtile-selected-bg-color;
|
background: $roomtile-selected-bg-color;
|
||||||
|
|
|
@ -17,9 +17,11 @@ limitations under the License.
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { _t } from '../../../languageHandler';
|
import { _t } from '../../../languageHandler';
|
||||||
import BaseDialog from "..//dialogs/BaseDialog"
|
import BaseDialog from "..//dialogs/BaseDialog"
|
||||||
|
import DialogButtons from "./DialogButtons"
|
||||||
import AccessibleButton from './AccessibleButton';
|
import AccessibleButton from './AccessibleButton';
|
||||||
import {getDesktopCapturerSources} from "matrix-js-sdk/src/webrtc/call";
|
import { getDesktopCapturerSources } from "matrix-js-sdk/src/webrtc/call";
|
||||||
import {replaceableComponent} from "../../../utils/replaceableComponent";
|
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
||||||
|
import classNames from 'classnames';
|
||||||
|
|
||||||
export interface DesktopCapturerSource {
|
export interface DesktopCapturerSource {
|
||||||
id: string;
|
id: string;
|
||||||
|
@ -28,13 +30,14 @@ export interface DesktopCapturerSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum Tabs {
|
export enum Tabs {
|
||||||
Screens = "screens",
|
Screens = "screen",
|
||||||
Windows = "windows",
|
Windows = "window",
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ExistingSourceIProps {
|
export interface ExistingSourceIProps {
|
||||||
source: DesktopCapturerSource;
|
source: DesktopCapturerSource;
|
||||||
onSelect(source: DesktopCapturerSource): void;
|
onSelect(source: DesktopCapturerSource): void;
|
||||||
|
selected: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ExistingSource extends React.Component<ExistingSourceIProps> {
|
export class ExistingSource extends React.Component<ExistingSourceIProps> {
|
||||||
|
@ -47,9 +50,14 @@ export class ExistingSource extends React.Component<ExistingSourceIProps> {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const classes = classNames({
|
||||||
|
mx_desktopCapturerSourcePicker_stream_button: true,
|
||||||
|
mx_desktopCapturerSourcePicker_stream_button_selected: this.props.selected,
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AccessibleButton
|
<AccessibleButton
|
||||||
className="mx_desktopCapturerSourcePicker_stream_button"
|
className={classes}
|
||||||
title={this.props.source.name}
|
title={this.props.source.name}
|
||||||
onClick={this.onClick} >
|
onClick={this.onClick} >
|
||||||
<img
|
<img
|
||||||
|
@ -65,6 +73,7 @@ export class ExistingSource extends React.Component<ExistingSourceIProps> {
|
||||||
export interface PickerIState {
|
export interface PickerIState {
|
||||||
selectedTab: Tabs;
|
selectedTab: Tabs;
|
||||||
sources: Array<DesktopCapturerSource>;
|
sources: Array<DesktopCapturerSource>;
|
||||||
|
selectedSource: DesktopCapturerSource | null;
|
||||||
}
|
}
|
||||||
export interface PickerIProps {
|
export interface PickerIProps {
|
||||||
onFinished(source: DesktopCapturerSource): void;
|
onFinished(source: DesktopCapturerSource): void;
|
||||||
|
@ -83,6 +92,7 @@ export default class DesktopCapturerSourcePicker extends React.Component<
|
||||||
this.state = {
|
this.state = {
|
||||||
selectedTab: Tabs.Screens,
|
selectedTab: Tabs.Screens,
|
||||||
sources: [],
|
sources: [],
|
||||||
|
selectedSource: null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,40 +117,47 @@ export default class DesktopCapturerSourcePicker extends React.Component<
|
||||||
}
|
}
|
||||||
|
|
||||||
onSelect = (source) => {
|
onSelect = (source) => {
|
||||||
this.props.onFinished(source);
|
this.setState({ selectedSource: source });
|
||||||
}
|
}
|
||||||
|
|
||||||
onScreensClick = (ev) => {
|
onShare = () => {
|
||||||
this.setState({selectedTab: Tabs.Screens});
|
this.props.onFinished(this.state.selectedSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
onWindowsClick = (ev) => {
|
onScreensClick = () => {
|
||||||
this.setState({selectedTab: Tabs.Windows});
|
if (this.state.selectedTab === Tabs.Screens) return;
|
||||||
|
this.setState({
|
||||||
|
selectedTab: Tabs.Screens,
|
||||||
|
selectedSource: null,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onCloseClick = (ev) => {
|
onWindowsClick = () => {
|
||||||
|
if (this.state.selectedTab === Tabs.Windows) return;
|
||||||
|
this.setState({
|
||||||
|
selectedTab: Tabs.Windows,
|
||||||
|
selectedSource: null,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onCloseClick = () => {
|
||||||
this.props.onFinished(null);
|
this.props.onFinished(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let sources;
|
const sources = this.state.sources.filter((source) => {
|
||||||
if (this.state.selectedTab === Tabs.Screens) {
|
return source.id.startsWith(this.state.selectedTab)
|
||||||
sources = this.state.sources
|
});
|
||||||
.filter((source) => {
|
const sourceElements = sources.map((source) => {
|
||||||
return source.id.startsWith("screen");
|
return (
|
||||||
})
|
<ExistingSource
|
||||||
.map((source) => {
|
selected={this.state.selectedSource?.id === source.id}
|
||||||
return <ExistingSource source={source} onSelect={this.onSelect} key={source.id} />;
|
source={source}
|
||||||
});
|
onSelect={this.onSelect}
|
||||||
} else {
|
key={source.id}
|
||||||
sources = this.state.sources
|
/>
|
||||||
.filter((source) => {
|
);
|
||||||
return source.id.startsWith("window");
|
});
|
||||||
})
|
|
||||||
.map((source) => {
|
|
||||||
return <ExistingSource source={source} onSelect={this.onSelect} key={source.id} />;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const buttonStyle = "mx_desktopCapturerSourcePicker_tabLabel";
|
const buttonStyle = "mx_desktopCapturerSourcePicker_tabLabel";
|
||||||
const screensButtonStyle = buttonStyle + ((this.state.selectedTab === Tabs.Screens) ? "_selected" : "");
|
const screensButtonStyle = buttonStyle + ((this.state.selectedTab === Tabs.Screens) ? "_selected" : "");
|
||||||
|
@ -167,8 +184,15 @@ export default class DesktopCapturerSourcePicker extends React.Component<
|
||||||
</AccessibleButton>
|
</AccessibleButton>
|
||||||
</div>
|
</div>
|
||||||
<div className="mx_desktopCapturerSourcePicker_panel">
|
<div className="mx_desktopCapturerSourcePicker_panel">
|
||||||
{ sources }
|
{ sourceElements }
|
||||||
</div>
|
</div>
|
||||||
|
<DialogButtons
|
||||||
|
primaryButton={_t("Share")}
|
||||||
|
hasCancel={true}
|
||||||
|
onCancel={this.onCloseClick}
|
||||||
|
onPrimaryButtonClick={this.onShare}
|
||||||
|
primaryDisabled={!this.state.selectedSource}
|
||||||
|
/>
|
||||||
</BaseDialog>
|
</BaseDialog>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue