import { WebApplication } from '@/ui_models/application'; import { FeatureIdentifier } from '@standardnotes/features'; import { FeatureStatus } from '@standardnotes/snjs'; import { FunctionComponent } from 'preact'; import { useState } from 'preact/hooks'; import { JSXInternal } from 'preact/src/jsx'; import { Icon } from '../Icon'; import { PremiumFeaturesModal } from '../PremiumFeaturesModal'; import { Switch } from '../Switch'; type Props = { application: WebApplication; closeQuickSettingsMenu: () => void; focusModeEnabled: boolean; setFocusModeEnabled: (enabled: boolean) => void; }; export const FocusModeSwitch: FunctionComponent = ({ application, closeQuickSettingsMenu, focusModeEnabled, setFocusModeEnabled, }) => { const [showUpgradeModal, setShowUpgradeModal] = useState(false); const isEntitledToFocusMode = application.getFeatureStatus(FeatureIdentifier.FocusMode) === FeatureStatus.Entitled; const toggleFocusMode = ( e: JSXInternal.TargetedMouseEvent ) => { e.preventDefault(); if (isEntitledToFocusMode) { setFocusModeEnabled(!focusModeEnabled); closeQuickSettingsMenu(); } else { setShowUpgradeModal(true); } }; return ( <> setShowUpgradeModal(false)} /> ); };