mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-19 15:21:23 +02:00
Fix header in fullscreen mode on Mac
This commit is contained in:
@@ -40,7 +40,12 @@ export const SettingsDialog = () => {
|
|||||||
</HStack>
|
</HStack>
|
||||||
<Separator className="my-4" />
|
<Separator className="my-4" />
|
||||||
|
|
||||||
<Heading size={2}>Workspace ({workspace.name})</Heading>
|
<Heading size={2}>
|
||||||
|
Workspace{' '}
|
||||||
|
<div className="inline-block ml-1 bg-gray-500 dark:bg-gray-300 px-2 py-0.5 !text-md rounded text-base text-white dark:text-gray-900">
|
||||||
|
{workspace.name}
|
||||||
|
</div>
|
||||||
|
</Heading>
|
||||||
<VStack className="w-full" space={3}>
|
<VStack className="w-full" space={3}>
|
||||||
<Input
|
<Input
|
||||||
size="xs"
|
size="xs"
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { appWindow } from '@tauri-apps/api/window';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { motion } from 'framer-motion';
|
import { motion } from 'framer-motion';
|
||||||
import type {
|
import type {
|
||||||
@@ -7,7 +8,8 @@ import type {
|
|||||||
ReactNode,
|
ReactNode,
|
||||||
} from 'react';
|
} from 'react';
|
||||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { useWindowSize } from 'react-use';
|
import { useFullscreen, useWindowSize } from 'react-use';
|
||||||
|
import { useIsFullscreen } from '../hooks/useIsFullscreen';
|
||||||
import { useOsInfo } from '../hooks/useOsInfo';
|
import { useOsInfo } from '../hooks/useOsInfo';
|
||||||
import { useSidebarHidden } from '../hooks/useSidebarHidden';
|
import { useSidebarHidden } from '../hooks/useSidebarHidden';
|
||||||
import { useSidebarWidth } from '../hooks/useSidebarWidth';
|
import { useSidebarWidth } from '../hooks/useSidebarWidth';
|
||||||
@@ -173,12 +175,14 @@ interface HeaderSizeProps extends HTMLAttributes<HTMLDivElement> {
|
|||||||
|
|
||||||
function HeaderSize({ className, ...props }: HeaderSizeProps) {
|
function HeaderSize({ className, ...props }: HeaderSizeProps) {
|
||||||
const platform = useOsInfo();
|
const platform = useOsInfo();
|
||||||
|
const fullscreen = useIsFullscreen();
|
||||||
|
const stoplightsVisible = platform?.osType === 'Darwin' && !fullscreen;
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={classNames(
|
className={classNames(
|
||||||
className,
|
className,
|
||||||
'h-md pt-[1px] flex items-center w-full border-b',
|
'h-md pt-[1px] flex items-center w-full border-b',
|
||||||
platform?.osType === 'Darwin' ? 'pl-20 pr-1' : 'pl-1',
|
stoplightsVisible ? 'pl-20 pr-1' : 'pl-1',
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
|
|||||||
26
src-web/hooks/useIsFullscreen.ts
Normal file
26
src-web/hooks/useIsFullscreen.ts
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import { appWindow } from '@tauri-apps/api/window';
|
||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import { useWindowSize } from 'react-use';
|
||||||
|
|
||||||
|
export function useIsFullscreen() {
|
||||||
|
const [isFullscreen, setIsFullscreen] = useState<boolean>(false);
|
||||||
|
const windowSize = useWindowSize();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
(async function () {
|
||||||
|
// Fullscreen state isn't updated right after resize event on Mac (needs to wait for animation) so
|
||||||
|
// we'll poll for 10 seconds to see if it changes. Hopefully Tauri eventually adds a way to listen
|
||||||
|
// for this.
|
||||||
|
for (let i = 0; i < 100; i++) {
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||||
|
const newIsFullscreen = await appWindow.isFullscreen();
|
||||||
|
if (newIsFullscreen !== isFullscreen) {
|
||||||
|
setIsFullscreen(newIsFullscreen);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}, [windowSize, isFullscreen]);
|
||||||
|
|
||||||
|
return isFullscreen;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user