mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-22 08:38:29 +02:00
Refactor desktop app into separate client and proxy apps
This commit is contained in:
27
apps/yaak-client/hooks/useZoom.ts
Normal file
27
apps/yaak-client/hooks/useZoom.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { patchModel, settingsAtom } from '@yaakapp-internal/models';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
export function useZoom() {
|
||||
const settings = useAtomValue(settingsAtom);
|
||||
|
||||
const zoomIn = useCallback(async () => {
|
||||
if (!settings) return;
|
||||
await patchModel(settings, {
|
||||
interfaceScale: Math.min(1.8, settings.interfaceScale * 1.1),
|
||||
});
|
||||
}, [settings]);
|
||||
|
||||
const zoomOut = useCallback(async () => {
|
||||
if (!settings) return;
|
||||
await patchModel(settings, {
|
||||
interfaceScale: Math.max(0.4, settings.interfaceScale * 0.9),
|
||||
});
|
||||
}, [settings]);
|
||||
|
||||
const zoomReset = useCallback(async () => {
|
||||
await patchModel(settings, { interfaceScale: 1 });
|
||||
}, [settings]);
|
||||
|
||||
return { zoomIn, zoomOut, zoomReset };
|
||||
}
|
||||
Reference in New Issue
Block a user