import {View, ViewStyle, TextStyle} from "react-native" import {Switch, Text} from "@/components/ignite" import {useAppTheme} from "@/contexts/ThemeContext" import {ThemedStyle} from "@/theme" import GlassView from "@/components/ui/GlassView" type ToggleSettingProps = { label: string subtitle?: string value: boolean onValueChange: (newValue: boolean) => void disabled?: boolean testID?: string style?: ViewStyle icon?: React.ReactNode compact?: boolean isFirst?: boolean isLast?: boolean plain?: boolean // Use plain View instead of GlassView (for when nested inside another GlassView) } const ToggleSetting: React.FC = ({ label, subtitle, value, onValueChange, disabled = false, testID, style, icon, compact = false, isFirst, isLast, plain = false, }) => { const {theme, themed} = useAppTheme() const groupedStyle: ViewStyle | undefined = isFirst !== undefined || isLast !== undefined ? { borderTopLeftRadius: isFirst ? theme.spacing.s4 : theme.spacing.s1, borderTopRightRadius: isFirst ? theme.spacing.s4 : theme.spacing.s1, borderBottomLeftRadius: isLast ? theme.spacing.s4 : theme.spacing.s1, borderBottomRightRadius: isLast ? theme.spacing.s4 : theme.spacing.s1, marginBottom: isLast ? 0 : theme.spacing.s2, } : undefined const Wrapper = plain ? View : GlassView return ( {icon && icon} {subtitle && } ) } const $container: ThemedStyle = ({colors, spacing}) => ({ flexDirection: "row", justifyContent: "space-between", alignItems: "center", width: "100%", backgroundColor: colors.primary_foreground, paddingVertical: spacing.s4, paddingHorizontal: spacing.s4, borderRadius: spacing.s4, // borderWidth: spacing.s0_5, // borderColor: colors.border, }) const $textContainer: ThemedStyle = () => ({ flexDirection: "column", alignItems: "flex-start", justifyContent: "flex-start", gap: 4, flex: 1, marginRight: 16, // Add spacing between text and toggle }) const $label: ThemedStyle = ({colors}) => ({ fontSize: 14, color: colors.text, }) const $subtitle: ThemedStyle = ({colors}) => ({ fontSize: 12, color: colors.textDim, }) export default ToggleSetting