import { MovableView, Text, View } from '@tarojs/components'
import { useState } from 'react'
import classnames from 'classnames'
import IconFont from '../iconfont/iconfont'
import styles from './index.module.scss'
import { goLink } from '@/common/common'

interface param {
  y: number
}
export default ({ y }: param) => {
  const [screenHeight, setScreenHeight] = useState({
    customer_service_y: 0,
    code_list_y: 0,
  })
  const [showCode, setShowCode] = useState(false)

  return (<>
    {showCode && <View className={styles.mask} catchMove onClick={() => setShowCode(!showCode)}></View>}
    <MovableView className={classnames(styles.code_list, styles.fixed_btn)} direction="all" inertia x="630rpx" y={`${y}rpx`}>
      {showCode && <View className={classnames(styles.code_list__card, showCode && styles['code_list--open'])}>
        <View className={styles['code_list__card--item']}>
          <IconFont name="icon-yuanshimadanyulan" size={46} />
          <Text>原始码单预览</Text>
        </View>
        <View className={styles['code_list__card--item']} onClick={() => goLink('/pages/codeList/index')}>
          <IconFont name="icon-zidingyimadanyulan" size={46} />
          <Text>自定义码单预览</Text>
        </View>
        <View className={styles['code_list__card--item']}>
          <IconFont name="icon-bianjizidingyimadan" size={46} />
          <Text>编辑自定义码单</Text>
        </View>
      </View>}
      <View className={styles['code_list--text']} onClick={() => setShowCode(!showCode)}>码单</View>
    </MovableView>
  </>)
}
