hide app bar in pip

This commit is contained in:
Timo
2025-06-24 18:03:52 +02:00
parent d5ba11956c
commit 12d1f4c03a
2 changed files with 22 additions and 3 deletions
+19 -2
View File
@@ -31,6 +31,7 @@ import styles from "./AppBar.module.css";
interface AppBarContext { interface AppBarContext {
setTitle: (value: string) => void; setTitle: (value: string) => void;
setSecondaryButton: (value: ReactNode) => void; setSecondaryButton: (value: ReactNode) => void;
setHidden: (value: boolean) => void;
} }
const AppBarContext = createContext<AppBarContext | null>(null); const AppBarContext = createContext<AppBarContext | null>(null);
@@ -52,15 +53,17 @@ export const AppBar: FC<Props> = ({ children }) => {
}, []); }, []);
const [title, setTitle] = useState<string>(""); const [title, setTitle] = useState<string>("");
const [hidden, setHidden] = useState<boolean>(false);
const [secondaryButton, setSecondaryButton] = useState<ReactNode>(null); const [secondaryButton, setSecondaryButton] = useState<ReactNode>(null);
const context = useMemo( const context = useMemo(
() => ({ setTitle, setSecondaryButton }), () => ({ setTitle, setSecondaryButton, setHidden }),
[setTitle, setSecondaryButton], [setTitle, setHidden, setSecondaryButton],
); );
return ( return (
<> <>
<div <div
style={{ display: hidden ? "none" : "block" }}
className={classNames( className={classNames(
styles.bar, styles.bar,
platform === "android" && styles.overlay, platform === "android" && styles.overlay,
@@ -107,6 +110,20 @@ export function useAppBarTitle(title: string): void {
}, [title, setTitle]); }, [title, setTitle]);
} }
/**
* React hook which sets the title to be shown in the app bar, if present. It is
* an error to call this hook from multiple sites in the same component tree.
*/
export function useAppBarHidden(hidden: boolean): void {
const setHidden = useContext(AppBarContext)?.setHidden;
useEffect(() => {
if (setHidden !== undefined) {
setHidden(hidden);
return (): void => setHidden(false);
}
}, [setHidden, hidden]);
}
/** /**
* React hook which sets the secondary button to be shown in the app bar, if * React hook which sets the secondary button to be shown in the app bar, if
* present. It is an error to call this hook from multiple sites in the same * present. It is an error to call this hook from multiple sites in the same
+3 -1
View File
@@ -113,7 +113,7 @@ import { muteAllAudio$ } from "../state/MuteAllAudioModel.ts";
import { useMatrixRTCSessionMemberships } from "../useMatrixRTCSessionMemberships.ts"; import { useMatrixRTCSessionMemberships } from "../useMatrixRTCSessionMemberships.ts";
import { useMediaDevices } from "../MediaDevicesContext.ts"; import { useMediaDevices } from "../MediaDevicesContext.ts";
import { EarpieceOverlay } from "./EarpieceOverlay.tsx"; import { EarpieceOverlay } from "./EarpieceOverlay.tsx";
import { useAppBarSecondaryButton } from "../AppBar.tsx"; import { useAppBarHidden, useAppBarSecondaryButton } from "../AppBar.tsx";
const canScreenshare = "getDisplayMedia" in (navigator.mediaDevices ?? {}); const canScreenshare = "getDisplayMedia" in (navigator.mediaDevices ?? {});
@@ -480,6 +480,8 @@ export const InCallView: FC<InCallViewProps> = ({
}, [t, earpieceMode, toggleEarpieceMode]), }, [t, earpieceMode, toggleEarpieceMode]),
); );
useAppBarHidden(!showHeader);
let header: ReactNode = null; let header: ReactNode = null;
if (showHeader) { if (showHeader) {
switch (headerStyle) { switch (headerStyle) {