IOPaint/lama_cleaner/app/src/components/Settings/SettingsModal.tsx

55 lines
1.4 KiB
TypeScript
Raw Normal View History

2022-04-12 14:58:57 +02:00
import React from 'react'
2022-09-15 16:21:27 +02:00
import { useRecoilState, useRecoilValue } from 'recoil'
import { isSDState, settingState } from '../../store/Atoms'
2022-04-12 14:58:57 +02:00
import Modal from '../shared/Modal'
2022-04-23 14:21:34 +02:00
import ManualRunInpaintingSettingBlock from './ManualRunInpaintingSettingBlock'
2022-04-12 14:58:57 +02:00
import HDSettingBlock from './HDSettingBlock'
2022-04-14 14:43:07 +02:00
import ModelSettingBlock from './ModelSettingBlock'
2022-06-13 10:50:51 +02:00
import GraduallyInpaintingSettingBlock from './GraduallyInpaintingSettingBlock'
2022-07-12 16:26:28 +02:00
import DownloadMaskSettingBlock from './DownloadMaskSettingBlock'
2022-09-15 16:21:27 +02:00
import useHotKey from '../../hooks/useHotkey'
2022-04-12 14:58:57 +02:00
2022-04-17 17:31:12 +02:00
interface SettingModalProps {
onClose: () => void
}
export default function SettingModal(props: SettingModalProps) {
const { onClose } = props
2022-04-12 14:58:57 +02:00
const [setting, setSettingState] = useRecoilState(settingState)
2022-09-15 16:21:27 +02:00
const isSD = useRecoilValue(isSDState)
2022-04-12 14:58:57 +02:00
2022-04-17 17:31:12 +02:00
const handleOnClose = () => {
2022-04-12 14:58:57 +02:00
setSettingState(old => {
return { ...old, show: false }
})
2022-04-17 17:31:12 +02:00
onClose()
2022-04-12 14:58:57 +02:00
}
2022-09-15 16:21:27 +02:00
useHotKey(
's',
() => {
setSettingState(old => {
return { ...old, show: !old.show }
})
},
{},
[]
)
2022-04-12 14:58:57 +02:00
return (
<Modal
2022-04-17 17:31:12 +02:00
onClose={handleOnClose}
2022-04-12 14:58:57 +02:00
title="Settings"
className="modal-setting"
show={setting.show}
>
2022-09-15 16:21:27 +02:00
{isSD ? <></> : <ManualRunInpaintingSettingBlock />}
2022-06-13 10:50:51 +02:00
<GraduallyInpaintingSettingBlock />
2022-07-12 16:26:28 +02:00
<DownloadMaskSettingBlock />
2022-04-14 14:43:07 +02:00
<ModelSettingBlock />
2022-09-15 16:21:27 +02:00
{isSD ? <></> : <HDSettingBlock />}
2022-04-12 14:58:57 +02:00
</Modal>
)
}