import { useRef, useImperativeHandle, forwardRef, useState } from 'react' import Text from '@/components/common/Text' import { View, TouchableOpacity } from 'react-native' import { createStyle, openUrl } from '@/utils/tools' import { useTheme } from '@/store/theme/hook' import { useI18n } from '@/lang' import Dialog, { type DialogType } from '@/components/common/Dialog' import Button from '@/components/common/Button' import List from './List' import ScriptImportExport, { type ScriptImportExportType } from './ScriptImportExport' // interface UrlInputType { // setText: (text: string) => void // getText: () => string // focus: () => void // } // const UrlInput = forwardRef((props, ref) => { // const theme = useTheme() // const t = useI18n() // const [text, setText] = useState('') // const inputRef = useRef(null) // const [height, setHeight] = useState(100) // useImperativeHandle(ref, () => ({ // getText() { // return text.trim() // }, // setText(text) { // setText(text) // }, // focus() { // inputRef.current?.focus() // }, // })) // const handleLayout = useCallback(({ nativeEvent }: LayoutChangeEvent) => { // setHeight(nativeEvent.layout.height) // }, []) // return ( // // // // ) // }) // export interface UserApiEditModalProps { // onSave: (rules: string) => void // // onSourceChange: SourceSelectorProps['onSourceChange'] // } export interface UserApiEditModalType { show: () => void } export default forwardRef((props, ref) => { const dialogRef = useRef(null) const scriptImportExportRef = useRef(null) // const sourceSelectorRef = useRef(null) // const inputRef = useRef(null) const [visible, setVisible] = useState(false) const theme = useTheme() const t = useI18n() const handleShow = () => { dialogRef.current?.setVisible(true) // requestAnimationFrame(() => { // inputRef.current?.setText('') // sourceSelectorRef.current?.setSource(source) // setTimeout(() => { // inputRef.current?.focus() // }, 300) // }) } useImperativeHandle(ref, () => ({ show() { if (visible) handleShow() else { setVisible(true) requestAnimationFrame(() => { handleShow() }) } }, })) const handleCancel = () => { dialogRef.current?.setVisible(false) } const handleImport = () => { scriptImportExportRef.current?.import() } const openFAQPage = () => { void openUrl('https://lyswhut.github.io/lx-music-doc/mobile/custom-source') } return ( visible ? ( {/* */} {t('user_api_title')} {t('user_api_readme')} FAQ {t('user_api_note')} ) : null ) }) const styles = createStyle({ content: { // flexGrow: 1, flexShrink: 1, paddingHorizontal: 15, paddingTop: 15, paddingBottom: 10, flexDirection: 'column', }, title: { marginBottom: 15, textAlign: 'center', // backgroundColor: 'rgba(0, 0, 0, 0.2)', }, tips: { marginTop: 15, flexDirection: 'row', flexWrap: 'wrap', }, tipsText: { marginTop: 8, textAlignVertical: 'bottom', // lineHeight: 18, // backgroundColor: 'rgba(0, 0, 0, 0.2)', }, btns: { flexDirection: 'row', justifyContent: 'center', paddingBottom: 15, paddingLeft: 15, // paddingRight: 15, }, btn: { flex: 1, paddingTop: 8, paddingBottom: 8, paddingLeft: 10, paddingRight: 10, alignItems: 'center', borderRadius: 4, marginRight: 15, }, })