import React from "react"; import { useTranslation } from "react-i18next"; import { Button, f7, Icon, Range, Sheet } from 'framework7-react'; import SvgIcon from '../../../../common/mobile//lib/component/SvgIcon' import IconDrawPen from '../../../../common/mobile/resources/icons/draw-pen.svg' import IconDrawHighlighter from '../../../../common/mobile/resources/icons/draw-highlighter.svg' import IconClearAll from '../../../../common/mobile/resources/icons/clear-all.svg' import IconClearObject from '../../../../common/mobile/resources/icons/clear-object.svg' import IconScroll from '../../../../common/mobile/resources/icons/scroll.svg' import IconPlusIos from '@common-ios-icons/icon-plus.svg?ios'; import IconPlusAndroid from '@common-android-icons/icon-plus.svg?android'; import { WheelColorPicker } from "../component/WheelColorPicker"; import { Device } from "../../utils/device"; export const DrawView = ({ currentTool, setTool, settings, setSettings, colors, addCustomColor, enableErasing, attachBackdropSwipeClose, removeBackdropSwipeClose }) => { const { t } = useTranslation(); const _t = t('Draw', { returnObjects: true }); const pickerRef = React.useRef(null); const isDrawingTool = currentTool === 'pen' || currentTool === 'highlighter'; const currentSettings = settings[currentTool] || {}; const currentColor = currentSettings.color || '#000000'; return ( {isDrawingTool && (<> { attachBackdropSwipeClose(); }} onSheetClosed={() => { f7.sheet.open('.draw-sheet--settings'); removeBackdropSwipeClose(); }}>
{_t.textCustomColor}
{ f7.sheet.close('.draw-sheet--color-picker') addCustomColor(color) }} />
{ document.activeElement?.blur() }} onSheetOpened={attachBackdropSwipeClose} onSheetClosed={removeBackdropSwipeClose} style={{ height: 'auto' }}>
{_t.textColor}
{colors.map((color, index) => { const isSelected = color.toLowerCase() === currentColor.toLowerCase(); return (
setSettings({ color })} onTouchStart={() => setSettings({ color })} />) })}
{ f7.sheet.close('.draw-sheet--settings'); f7.sheet.open('.draw-sheet--color-picker'); pickerRef.current?.update(); }} > {Device.ios ? () : () }
{_t.textLineSize}
{/*{Device.android ? (*/} setSettings({ lineSize: value })} /> {/*) : (*/} {/* setSettings({ lineSize: parseInt(e.target.value) })} />*/} {/* )}*/}
{_t.textOpacity}
setSettings({ opacity: parseInt(e.target.value) })}/>
)}
) }