// import { useTheme } from "styled-components"; import { useCallback } from "react"; // import { RD_Theme } from "../../../styles/types"; import { minMaxSize } from "./functions"; import { useWindows } from "../../contexts/windows"; import { useSession } from "../../contexts/session"; type WindowSize = { updateWindowSize: (height: number, width: number) => void; }; const useWindowSize = (id: string): WindowSize => { const { setWindowStates } = useSession(); const { windows: { [id]: { lockAspectRatio = false, maximized = false } = {}, } = {}, } = useWindows(); const updateWindowSize = useCallback( (height: number, width: number) => setWindowStates((currentWindowStates) => ({ ...currentWindowStates, [id]: { ...currentWindowStates?.[id], maximized, size: minMaxSize( { height, width, }, lockAspectRatio ), }, })), [id, lockAspectRatio, maximized, setWindowStates] ); return { updateWindowSize, }; }; export default useWindowSize;