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

fix(renderer-app): error of whiteboard resize #1323

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions desktop/renderer-app/src/components/Whiteboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,15 @@ export const Whiteboard = observer<WhiteboardProps>(function Whiteboard({
if (whiteboardEl) {
const whiteboardRatio = whiteboardStore.getWhiteboardRatio();

const classRoomRightSideWidth = 304;
const isSmallClass = whiteboardStore.smallClassRatio === whiteboardRatio;
const classRoomRightSideWidth = whiteboardStore.isRightSideClose ? 0 : 304;

let classRoomTopBarHeight: number;
let classRoomMinWidth: number;
let classRoomMinHeight: number;
let smallClassAvatarWrapMaxWidth: number;

if (whiteboardStore.smallClassRatio === whiteboardRatio) {
if (isSmallClass) {
classRoomTopBarHeight = 182;
classRoomMinWidth = 1130;
classRoomMinHeight = 610;
Expand All @@ -110,6 +113,21 @@ export const Whiteboard = observer<WhiteboardProps>(function Whiteboard({
whiteboardEl.style.minWidth = `${whiteboardMinWidth}px`;
whiteboardEl.style.minHeight = `${whiteboardMinWidth * whiteboardRatio}px`;
}

const classRoomWidth = whiteboardWidth + classRoomRightSideWidth;
const classRoomWithoutRightSideWidth = classRoomMinWidth - classRoomRightSideWidth;

if (whiteboardStore.isRightSideClose) {
smallClassAvatarWrapMaxWidth =
classRoomWidth < classRoomWithoutRightSideWidth
? classRoomWithoutRightSideWidth
: classRoomWidth;
} else {
smallClassAvatarWrapMaxWidth =
classRoomWidth < classRoomMinWidth ? classRoomMinWidth : classRoomWidth;
}

whiteboardStore.updateSmallClassAvatarWrapMaxWidth(smallClassAvatarWrapMaxWidth);
}
}, [whiteboardEl, whiteboardStore]);

Expand All @@ -123,6 +141,11 @@ export const Whiteboard = observer<WhiteboardProps>(function Whiteboard({
};
}, [whiteboardEl, whiteboardOnResize]);

useEffect(() => {
whiteboardOnResize();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [whiteboardStore.isRightSideClose]);

const bindWhiteboard = useCallback((ref: HTMLDivElement | null) => {
if (ref) {
setWhiteboardEl(ref);
Expand Down
9 changes: 4 additions & 5 deletions desktop/renderer-app/src/pages/BigClassPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,10 @@ export const BigClassPage = observer<BigClassPageProps>(function BigClassPage()
)
}
title={isRealtimeSideOpen ? t("side-panel.hide") : t("side-panel.show")}
onClick={handleSideOpenerSwitch}
onClick={() => {
openRealtimeSide(isRealtimeSideOpen => !isRealtimeSideOpen);
whiteboardStore.setRightSideClose(isRealtimeSideOpen);
}}
/>
</>
);
Expand Down Expand Up @@ -363,10 +366,6 @@ export const BigClassPage = observer<BigClassPageProps>(function BigClassPage()
);
}

function handleSideOpenerSwitch(): void {
openRealtimeSide(isRealtimeSideOpen => !isRealtimeSideOpen);
}

function onVideoAvatarExpand(): void {
setMainSpeaker(mainSpeaker =>
mainSpeaker?.userUUID === classRoomStore.users.creator?.userUUID
Expand Down
9 changes: 4 additions & 5 deletions desktop/renderer-app/src/pages/OneToOnePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,10 @@ export const OneToOnePage = observer<OneToOnePageProps>(function OneToOnePage()
)
}
title={isRealtimeSideOpen ? t("side-panel.hide") : t("side-panel.show")}
onClick={handleSideOpenerSwitch}
onClick={() => {
openRealtimeSide(isRealtimeSideOpen => !isRealtimeSideOpen);
whiteboardStore.setRightSideClose(isRealtimeSideOpen);
}}
/>
</>
);
Expand Down Expand Up @@ -296,10 +299,6 @@ export const OneToOnePage = observer<OneToOnePageProps>(function OneToOnePage()
);
}

function handleSideOpenerSwitch(): void {
openRealtimeSide(isRealtimeSideOpen => !isRealtimeSideOpen);
}

function updateCloudRecordLayout(): void {
const { creator } = classRoomStore.users;
const backgroundConfig: AgoraCloudRecordBackgroundConfigItem[] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
height: 130px;
border-top: 0.5px #dbe1ea solid;
box-shadow: 0px 8px 24px 0px rgba(68, 78, 96, 0.08);
// border-bottom: 0.5px solid #dbe1e9;

&::-webkit-scrollbar {
display: none;
Expand Down
10 changes: 8 additions & 2 deletions desktop/renderer-app/src/pages/SmallClassPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,10 @@ export const SmallClassPage = observer<SmallClassPageProps>(function SmallClassP

function renderAvatars(): React.ReactNode {
return (
<div className="realtime-avatars-wrap">
<div
className="realtime-avatars-wrap"
style={{ maxWidth: `${whiteboardStore.smallClassAvatarWrapMaxWidth}px` }}
>
<div className="realtime-avatars">
<SmallClassAvatar
avatarUser={classRoomStore.users.creator}
Expand Down Expand Up @@ -320,7 +323,10 @@ export const SmallClassPage = observer<SmallClassPageProps>(function SmallClassP
)
}
title={isRealtimeSideOpen ? t("side-panel.hide") : t("side-panel.show")}
onClick={() => openRealtimeSide(isRealtimeSideOpen => !isRealtimeSideOpen)}
onClick={() => {
openRealtimeSide(isRealtimeSideOpen => !isRealtimeSideOpen);
whiteboardStore.setRightSideClose(isRealtimeSideOpen);
}}
/>
</>
);
Expand Down
10 changes: 10 additions & 0 deletions desktop/renderer-app/src/stores/whiteboard-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ export class WhiteboardStore {
public isKicked = false;
public isFocusWindow = false;
public isWindowMaximization = false;
public isRightSideClose = false;
public currentSceneIndex = 0;
public scenesCount = 0;
public smallClassRatio = 8.3 / 16;
public otherClassRatio = 10.46 / 16;
public smallClassAvatarWrapMaxWidth = 0;

/** is room Creator */
public readonly isCreator: boolean;
Expand Down Expand Up @@ -124,6 +126,10 @@ export class WhiteboardStore {
this.isFocusWindow = isFocus;
};

public updateSmallClassAvatarWrapMaxWidth = (smallClassAvatarWrapMaxWidth: number): void => {
this.smallClassAvatarWrapMaxWidth = smallClassAvatarWrapMaxWidth;
};

public getWhiteboardRatio = (): number => {
// the Ratio of whiteboard compute method is height / width.
if (this.getRoomType() === RoomType.SmallClass) {
Expand All @@ -148,6 +154,10 @@ export class WhiteboardStore {
this.isShowPreviewPanel = show;
};

public setRightSideClose = (close: boolean): void => {
this.isRightSideClose = close;
};

public switchMainViewToWriter = async (): Promise<void> => {
if (this.windowManager && this.isFocusWindow) {
await this.windowManager.switchMainViewToWriter();
Expand Down