import clsx from 'clsx'; import React from 'react'; import { MdCheck } from 'react-icons/md'; import { useEnv } from '@/context/EnvContext'; import { useSettingsStore } from '@/store/settingsStore'; import { useTranslation } from '@/hooks/useTranslation'; import { useReaderStore } from '@/store/readerStore'; import { useCustomFontStore } from '@/store/customFontStore'; import { saveViewSettings } from '@/helpers/settings'; import { SettingsPanelType } from './SettingsDialog'; import Menu from '@/components/Menu'; import MenuItem from '@/components/MenuItem'; interface DialogMenuProps { bookKey: string; activePanel: SettingsPanelType; setIsDropdownOpen?: (open: boolean) => void; onReset: () => void; resetLabel?: string; } const DialogMenu: React.FC = ({ bookKey, activePanel, setIsDropdownOpen, onReset, resetLabel, }) => { const _ = useTranslation(); const { envConfig, appService } = useEnv(); const { setFontPanelView } = useSettingsStore(); const { getViewSettings } = useReaderStore(); const { getAllFonts, removeFont, saveCustomFonts } = useCustomFontStore(); const viewSettings = getViewSettings(bookKey); const isSettingsGlobal = viewSettings?.isGlobal ?? true; const handleToggleGlobal = () => { saveViewSettings(envConfig, bookKey, 'isGlobal', !isSettingsGlobal, true, false); setIsDropdownOpen?.(false); }; const handleResetToDefaults = () => { onReset(); setIsDropdownOpen?.(false); }; const handleManageCustomFont = () => { setFontPanelView('custom-fonts'); setIsDropdownOpen?.(false); }; const handleClearCustomFont = () => { getAllFonts().forEach((font) => { if (removeFont(font.id)) { appService!.deleteFont(font); } }); saveCustomFonts(envConfig); setIsDropdownOpen?.(false); }; return ( {activePanel === 'Font' && ( <> )} ); }; export default DialogMenu;