import React, { useState } from 'react' import { View, Text } from '@tarojs/components' import { Popup, Button } from '@nutui/nutui-react-taro' import { gradientThemes, GradientTheme } from '@/styles/gradients' interface GradientThemeSelectorProps { visible: boolean onClose: () => void onSelect: (theme: GradientTheme) => void currentTheme?: GradientTheme } const GradientThemeSelector: React.FC = ({ visible, onClose, onSelect, currentTheme }) => { const [selectedTheme, setSelectedTheme] = useState(currentTheme || null) const handleThemeSelect = (theme: GradientTheme) => { setSelectedTheme(theme) } const handleConfirm = () => { if (selectedTheme) { onSelect(selectedTheme) onClose() } } const renderThemeItem = (theme: GradientTheme) => { const isSelected = selectedTheme?.name === theme.name return ( handleThemeSelect(theme)} > {/* 渐变预览 */} 预览 {/* 主题信息 */} {theme.description.split(' - ')[0]} {theme.description.split(' - ')[1]} {/* 选中标识 */} {isSelected && ( )} ) } return ( 选择主题 选择您喜欢的渐变主题,让界面更符合您的个人风格 {/* 主题网格 */} {gradientThemes.map(renderThemeItem)} {/* 确认按钮 */} ) } export default GradientThemeSelector