import Taro, { Component } from '@tarojs/taro'
import { View, Button, Image } from '@tarojs/components'
import './index.scss'
import { ComponentClass } from 'react'

type PageOwnProps = {
  className?: string
  image: string,
  title?: string,
  disabled?: boolean,
  onClick?: any
  fullImage?: boolean
}

type IProps = PageOwnProps

interface Index {
  props: IProps;
}
class Index extends Component {

  static options = {
    addGlobalClass: true
  }

  handleClick = () => {
    this.props.onClick()
  }

  render() {

    return (
      <View className={'sd-float-button ' + (this.props.className || '')} >
        <Button
          disabled={this.props.disabled}
          onClick={this.handleClick}
        >
          {
            this.props.fullImage ?
              <View className='sd-float-button-content sd-float-button-image-only'>
                <Image className='sd-float-button-image' src={this.props.image} />
              </View>
              :
              <View className='sd-float-button-content'>
                <Image className='sd-float-button-image' src={this.props.image} />
                <View>{this.props.title}</View>
              </View>
          }
        </Button>

      </View>
    )
  }
}

export default Index as ComponentClass<PageOwnProps>

