Skip to content

Commit ccbbdcd

Browse files
committed
Put a switch camera button on the local user's tile
1 parent 496fe86 commit ccbbdcd

File tree

1 file changed

+28
-14
lines changed

1 file changed

+28
-14
lines changed

src/tile/GridTile.tsx

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
UserProfileIcon,
2828
ExpandIcon,
2929
VolumeOffSolidIcon,
30+
SwitchCameraSolidIcon,
3031
} from "@vector-im/compound-design-tokens/assets/web/icons";
3132
import {
3233
ContextMenu,
@@ -62,6 +63,7 @@ interface UserMediaTileProps extends TileProps {
6263
vm: UserMediaViewModel;
6364
mirror: boolean;
6465
locallyMuted: boolean;
66+
primaryButton?: ReactNode;
6567
menuStart?: ReactNode;
6668
menuEnd?: ReactNode;
6769
}
@@ -72,6 +74,7 @@ const UserMediaTile = forwardRef<HTMLDivElement, UserMediaTileProps>(
7274
vm,
7375
showSpeakingIndicators,
7476
locallyMuted,
77+
primaryButton,
7578
menuStart,
7679
menuEnd,
7780
className,
@@ -160,20 +163,22 @@ const UserMediaTile = forwardRef<HTMLDivElement, UserMediaTileProps>(
160163
}
161164
displayName={displayName}
162165
primaryButton={
163-
<Menu
164-
open={menuOpen}
165-
onOpenChange={setMenuOpen}
166-
title={displayName}
167-
trigger={
168-
<button aria-label={t("common.options")}>
169-
<OverflowHorizontalIcon aria-hidden width={20} height={20} />
170-
</button>
171-
}
172-
side="left"
173-
align="start"
174-
>
175-
{menu}
176-
</Menu>
166+
primaryButton ?? (
167+
<Menu
168+
open={menuOpen}
169+
onOpenChange={setMenuOpen}
170+
title={displayName}
171+
trigger={
172+
<button aria-label={t("common.options")}>
173+
<OverflowHorizontalIcon aria-hidden width={20} height={20} />
174+
</button>
175+
}
176+
side="left"
177+
align="start"
178+
>
179+
{menu}
180+
</Menu>
181+
)
177182
}
178183
raisedHandTime={handRaised ?? undefined}
179184
currentReaction={reaction ?? undefined}
@@ -205,6 +210,8 @@ const LocalUserMediaTile = forwardRef<HTMLDivElement, LocalUserMediaTileProps>(
205210
const { t } = useTranslation();
206211
const mirror = useObservableEagerState(vm.mirror$);
207212
const alwaysShow = useObservableEagerState(vm.alwaysShow$);
213+
const switchCamera = useObservableEagerState(vm.switchCamera$);
214+
208215
const latestAlwaysShow = useLatest(alwaysShow);
209216
const onSelectAlwaysShow = useCallback(
210217
(e: Event) => {
@@ -220,6 +227,13 @@ const LocalUserMediaTile = forwardRef<HTMLDivElement, LocalUserMediaTileProps>(
220227
vm={vm}
221228
locallyMuted={false}
222229
mirror={mirror}
230+
primaryButton={
231+
switchCamera === null ? undefined : (
232+
<button aria-label={t("switch_camera")} onClick={switchCamera}>
233+
<SwitchCameraSolidIcon aria-hidden width={20} height={20} />
234+
</button>
235+
)
236+
}
223237
menuStart={
224238
<ToggleMenuItem
225239
Icon={VisibilityOnIcon}

0 commit comments

Comments
 (0)