import * as React from "react"; import {Tabs, Tooltip} from "antd"; import {ViewMode, Player} from "white-web-sdk"; import WhiteboardChat from "./WhiteboardChat"; import {MessageType} from "./WhiteboardBottomRight"; import {GuestUserType, HostUserType} from "../../pages/RoomManager"; import user_empty from "../../assets/image/user_empty.svg"; import menu_in from "../../assets/image/menu_in.svg"; import teacher from "../../assets/image/teacher.svg"; import "./PlayerManager.less"; import Identicon from "@netless/identicon"; import {ClassModeType, LanguageEnum} from "../../pages/NetlessRoomTypes"; import { observer } from "mobx-react"; import { projectStore } from "../../models/ProjectStore"; const { TabPane } = Tabs; export type PlayerManagerProps = { player?: Player; userId: string; handleManagerState: () => void; isManagerOpen?: boolean; uuid?: string; userName?: string; userAvatarUrl?: string; messages: MessageType[]; isFirstScreenReady: boolean; isChatOpen: boolean; mediaUrl?: string; elementId: string; }; export type PlayerManagerStates = { isLandscape: boolean, isRtcReady: boolean, isManagerOpen: boolean, activeKey: string, }; @observer class PlayerManager extends React.Component { public constructor(props: PlayerManagerProps) { super(props); this.state = { isLandscape: false, isRtcReady: false, isManagerOpen: this.props.isManagerOpen !== undefined ? this.props.isManagerOpen : false, activeKey: "1", }; } private detectLandscape = (): void => { const width = window.innerWidth; const height = window.innerHeight; const isLandscape = (width / height) >= 1; this.setState({isLandscape: isLandscape}); } public componentDidMount(): void { this.detectLandscape(); window.addEventListener("resize", this.detectLandscape); } public componentWillReceiveProps(nextProps: PlayerManagerProps): void { if (this.props.isChatOpen !== nextProps.isChatOpen) { if (nextProps.isChatOpen) { this.setState({activeKey: "2"}); } else { this.setState({activeKey: "1"}); } } } public componentWillUnmount(): void { window.removeEventListener("resize", this.detectLandscape); } private handleTabsChange = (evt: any): void => { this.setState({activeKey: evt}); } private renderGuest = (): React.ReactNode => { const {player, isFirstScreenReady} = this.props; if (player && isFirstScreenReady) { const globalGuestUsers: GuestUserType[] = (player.state.globalState as any).guestUsers; if (globalGuestUsers) { const guestNodes = globalGuestUsers.map((guestUser: GuestUserType, index: number) => { return (
{guestUser.avatar ?
:
}
{guestUser.name}
); }); return (
{guestNodes}
); } else { return
{projectStore.isEnglish() ?
No students have joined
:
尚且无学生加入
}
; } } else { return
{projectStore.isEnglish() ?
No students have joined
:
尚且无学生加入
}
; } } private handleManagerStyle = (): string => { if (this.props.isManagerOpen) { return "manager-box"; } else { return "manager-box-mask-close"; } } private renderMedia = (): React.ReactNode => { const {mediaUrl} = this.props; if (mediaUrl) { return (
); } else { return null; } } private handleModeText = (mode: ClassModeType) => { switch (mode) { case ClassModeType.discuss: { return "Interactive"; } case ClassModeType.lecture: { return "Lecture"; } default: { return "Raise hand"; } } } private renderHostInf = (): React.ReactNode => { const {player, isFirstScreenReady} = this.props; if (player && isFirstScreenReady && (player.state.globalState as any).hostInfo !== undefined) { const hostInfo: HostUserType = (player.state.globalState as any).hostInfo; return (
{this.renderMedia()}
this.props.handleManagerState()} className="manager-box-btn-right-inner">
{hostInfo.avatar ? : }
老师:{hostInfo.name ? hostInfo.name : hostInfo.userId}
模式: {this.handleModeText(hostInfo.classMode)}
); } else { return (
{this.renderMedia()}
this.props.handleManagerState()} className="manager-box-btn-right-inner">
); } } public render(): React.ReactNode { return (
{this.renderHostInf()}
{this.renderGuest()}
); } } export default PlayerManager;