import { requireNativeComponent, ViewProps } from 'react-native'
import React from 'react'
import { Utils } from 'tuya-panel-kit'
import ThemeType from '../config/themeType'

const { withTheme } = Utils.ThemeUtils
const NativeStripLightView = requireNativeComponent('StripLightView')

export interface LightNode {
  color: string
  backgroundColor?: string
}

export interface StripLightViewProps extends ViewProps {
  theme?: ThemeType
  nodes: LightNode[]
  fixCount: number
  stripStyle: 'ONLY_LINE' | 'WITH_BEAD'
  touchingMode?: 'CLICK' | 'TOUCH'
  width: number
}

const StripLightView = (props: StripLightViewProps) => {
  const newNodes = props.nodes.map(node => ({...node, backgroundColor: props.theme?.card.background}))
  return (
    <NativeStripLightView {...props} nodes={JSON.stringify(newNodes)}/>
  )
}

export default withTheme(StripLightView)
