2024-05-18 04:38:00 +08:00
|
|
|
/*
|
2024-09-06 16:22:13 +08:00
|
|
|
Copyright 2024 New Vector Ltd.
|
2024-05-18 04:38:00 +08:00
|
|
|
|
2024-09-06 16:22:13 +08:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
Please see LICENSE in the repository root for full details.
|
2024-05-18 04:38:00 +08:00
|
|
|
*/
|
|
|
|
|
2024-11-06 17:36:48 +08:00
|
|
|
import { forwardRef } from "react";
|
2024-05-18 04:38:00 +08:00
|
|
|
import { useObservableEagerState } from "observable-hooks";
|
2024-05-31 01:06:24 +08:00
|
|
|
import classNames from "classnames";
|
2024-05-18 04:38:00 +08:00
|
|
|
|
2024-11-06 17:36:48 +08:00
|
|
|
import { CallLayout } from "./CallLayout";
|
2024-07-04 03:08:30 +08:00
|
|
|
import { SpotlightLandscapeLayout as SpotlightLandscapeLayoutModel } from "../state/CallViewModel";
|
|
|
|
import styles from "./SpotlightLandscapeLayout.module.css";
|
2024-07-26 00:50:28 +08:00
|
|
|
import { useUpdateLayout } from "./Grid";
|
2024-05-18 04:38:00 +08:00
|
|
|
|
2024-07-18 23:33:20 +08:00
|
|
|
/**
|
|
|
|
* An implementation of the "spotlight landscape" layout, in which the spotlight
|
|
|
|
* tile takes up most of the space on the left, and the grid of participants is
|
|
|
|
* shown as a scrolling rail on the right.
|
|
|
|
*/
|
2024-07-04 03:08:30 +08:00
|
|
|
export const makeSpotlightLandscapeLayout: CallLayout<
|
|
|
|
SpotlightLandscapeLayoutModel
|
|
|
|
> = ({ minBounds }) => ({
|
|
|
|
scrollingOnTop: false,
|
2024-05-18 04:38:00 +08:00
|
|
|
|
2024-07-04 03:08:30 +08:00
|
|
|
fixed: forwardRef(function SpotlightLandscapeLayoutFixed(
|
|
|
|
{ model, Slot },
|
|
|
|
ref,
|
|
|
|
) {
|
2024-07-26 00:50:28 +08:00
|
|
|
useUpdateLayout();
|
2024-07-25 04:57:20 +08:00
|
|
|
useObservableEagerState(minBounds);
|
2024-05-18 04:38:00 +08:00
|
|
|
|
2024-05-31 01:06:24 +08:00
|
|
|
return (
|
2024-07-25 04:57:20 +08:00
|
|
|
<div ref={ref} className={styles.layer}>
|
2024-05-31 01:06:24 +08:00
|
|
|
<div className={styles.spotlight}>
|
2024-11-06 17:36:48 +08:00
|
|
|
<Slot
|
|
|
|
className={styles.slot}
|
|
|
|
id="spotlight"
|
|
|
|
model={model.spotlight}
|
|
|
|
/>
|
2024-05-18 04:38:00 +08:00
|
|
|
</div>
|
2024-05-31 01:06:24 +08:00
|
|
|
<div className={styles.grid} />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}),
|
2024-05-18 04:38:00 +08:00
|
|
|
|
2024-07-04 03:08:30 +08:00
|
|
|
scrolling: forwardRef(function SpotlightLandscapeLayoutScrolling(
|
2024-05-31 01:06:24 +08:00
|
|
|
{ model, Slot },
|
|
|
|
ref,
|
|
|
|
) {
|
2024-07-26 00:50:28 +08:00
|
|
|
useUpdateLayout();
|
2024-07-25 04:57:20 +08:00
|
|
|
useObservableEagerState(minBounds);
|
2024-11-06 17:36:48 +08:00
|
|
|
const withIndicators =
|
|
|
|
useObservableEagerState(model.spotlight.media).length > 1;
|
2024-05-18 04:38:00 +08:00
|
|
|
|
2024-05-31 01:06:24 +08:00
|
|
|
return (
|
2024-07-25 04:57:20 +08:00
|
|
|
<div ref={ref} className={styles.layer}>
|
2024-05-18 04:38:00 +08:00
|
|
|
<div
|
2024-05-31 01:06:24 +08:00
|
|
|
className={classNames(styles.spotlight, {
|
2024-11-06 17:36:48 +08:00
|
|
|
[styles.withIndicators]: withIndicators,
|
2024-05-31 01:06:24 +08:00
|
|
|
})}
|
|
|
|
/>
|
|
|
|
<div className={styles.grid}>
|
2024-11-06 17:36:48 +08:00
|
|
|
{model.grid.map((m) => (
|
2024-05-31 01:06:24 +08:00
|
|
|
<Slot
|
2024-11-06 17:36:48 +08:00
|
|
|
key={m.id}
|
2024-05-31 01:06:24 +08:00
|
|
|
className={styles.slot}
|
2024-11-06 17:36:48 +08:00
|
|
|
id={m.id}
|
2024-05-31 01:06:24 +08:00
|
|
|
model={m}
|
2024-11-06 17:36:48 +08:00
|
|
|
onVisibilityChange={m.setVisible}
|
2024-05-31 01:06:24 +08:00
|
|
|
/>
|
|
|
|
))}
|
2024-05-18 04:38:00 +08:00
|
|
|
</div>
|
2024-05-31 01:06:24 +08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}),
|
2024-05-18 04:38:00 +08:00
|
|
|
});
|