import React, { useState } from 'react' import { useRecoilState, useRecoilValue } from 'recoil' import * as PopoverPrimitive from '@radix-ui/react-popover' import { useToggle } from 'react-use' import { UploadIcon } from '@radix-ui/react-icons' import { isInpaintingState, paintByExampleImageState, settingState, } from '../../store/Atoms' import NumberInputSetting from '../Settings/NumberInputSetting' import SettingBlock from '../Settings/SettingBlock' import { Switch, SwitchThumb } from '../shared/Switch' import Button from '../shared/Button' import emitter, { EVENT_PAINT_BY_EXAMPLE } from '../../event' import { useImage } from '../../utils' import ImageResizeScale from './ImageResizeScale' const INPUT_WIDTH = 30 const PESidePanel = () => { const [open, toggleOpen] = useToggle(true) const [setting, setSettingState] = useRecoilState(settingState) const [paintByExampleImage, setPaintByExampleImage] = useRecoilState( paintByExampleImageState ) const [uploadElemId] = useState( `example-file-upload-${Math.random().toString()}` ) const [exampleImage, isExampleImageLoaded] = useImage(paintByExampleImage) const isInpainting = useRecoilValue(isInpaintingState) const renderUploadIcon = () => { return ( ) } return (
toggleOpen()} > Configurations { setSettingState(old => { return { ...old, showCroper: value } }) }} > } /> { const val = value.length === 0 ? 0 : parseInt(value, 10) setSettingState(old => { return { ...old, paintByExampleSteps: val } }) }} /> { const val = value.length === 0 ? 0 : parseFloat(value) setSettingState(old => { return { ...old, paintByExampleGuidanceScale: val } }) }} /> { const val = value.length === 0 ? 0 : parseInt(value, 10) setSettingState(old => { return { ...old, paintByExampleMaskBlur: val } }) }} /> { setSettingState(old => { return { ...old, paintByExampleMatchHistograms: value } }) }} > } /> {/* 每次会从服务器返回更新该值 */} { const val = value.length === 0 ? 0 : parseInt(value, 10) setSettingState(old => { return { ...old, paintByExampleSeed: val } }) }} /> { setSettingState(old => { return { ...old, paintByExampleSeedFixed: value } }) }} style={{ marginLeft: '8px' }} >
} />
{paintByExampleImage ? (
example
) : ( <> )}
) } export default PESidePanel