import { KeyboardAwareScrollView } from "react-native-keyboard-controller"; import { styles } from "@/styles/components/colorPicker"; import { View, Pressable, Text } from "react-native"; import { isLightColor } from "@/functions/color"; import TextInput from "@/components/TextInput"; import { useEffect, useState } from "react"; import Button from "@/components/Button"; import Popup from "@/components/Popup"; import type React from "react"; import NativeColorPicker, { type returnedResults, HSLSaturationSlider, BrightnessSlider, LuminanceSlider, OpacitySlider, InputWidget, HueSlider, Swatches, Preview, Panel1, Panel2, Panel3, Panel4, Panel5, } from "reanimated-color-picker"; type PanelType = "saturation" | "brightness" | "hsl-saturation"; type PanelComponent = "panel1" | "panel2" | "panel3" | "panel4" | "panel5"; interface CustomColorPickerProps { defaultInputFormats?: Array<"HEX" | "RGB" | "HSL" | "HWB" | "HSV">; onSelectColor: (color: returnedResults) => void; previewHideInitialColor?: boolean; defaultColors?: Array; showHSLSaturation?: boolean; previewHideText?: boolean; showBrightness?: boolean; showLuminance?: boolean; disableAlpha?: boolean; initialColor?: string; showOpacity?: boolean; showPreview?: boolean; description?: string; showInput?: boolean; disabled?: boolean; showHue?: boolean; title?: string; previewColorFormat?: | "hex" | "rgb" | "rgba" | "hsl" | "hsla" | "hsv" | "hsva" | "hwb" | "hwba"; panel?: | "panel1" | "panel2" | "panel2_saturation" | "panel2_brightness" | "panel2_hsl-saturation" | "panel3" | "panel3_saturation" | "panel3_brightness" | "panel3_hsl-saturation" | "panel4" | "panel5"; } export default function ColorPicker({ showHSLSaturation = false, initialColor = "#ffffff", previewHideInitialColor, showBrightness = false, showLuminance = false, disableAlpha = false, defaultInputFormats, defaultColors = [], showOpacity = true, showPreview = true, previewColorFormat, showInput = true, disabled = false, previewHideText, showHue = true, onSelectColor, description, title, panel, }: CustomColorPickerProps) { const [showPicker, setShowPicker] = useState(false); const [color, setColor] = useState(initialColor || "#ffffff"); const [selectedColorData, setSelectedColorData] = useState(); const [panelType, setPanelType] = useState(); const [panelComponent, setPanelComponent] = useState("panel1"); useEffect(() => { if (panel) { const panelData = panel.split("_") as [ PanelComponent, PanelType | undefined, ]; setPanelComponent(panelData[0]); setPanelType(panelData[1]); } else { setPanelComponent("panel1"); } }, [panel]); useEffect(() => { setColor(initialColor || "#ffffff"); }, [initialColor]); return ( <> {title && ( <> {title} {description && ( {description} )} )} setShowPicker(true)} style={styles.input} >