import React from 'react'
import { View } from '@tarojs/components'
import { Button } from '@nutui/nutui-react-taro'

interface FixedButtonProps {
  text?: string
  onClick?: () => void
  icon?: React.ReactNode
  disabled?: boolean
  background?: string
}

/**
 * 底部固定按钮组件
 * 用于地址列表"新增地址"、地址编辑"保存"等底部固定操作
 */
const FixedButton: React.FC<FixedButtonProps> = ({ text, onClick, icon, disabled, background }) => {
  return (
    <>
      {/* 底部安全区域占位 */}
      <View className="h-20 w-full" />
      <View
        className="z-50 bg-white border-t border-gray-200 px-4 py-3"
        style={{ paddingBottom: '12px', flexShrink: 0 }}
      >
        <Button
          type="primary"
          style={{ background }}
          size="large"
          block
          icon={icon}
          disabled={disabled}
          className="px-6"
          onClick={onClick}
        >
          {text || '确定'}
        </Button>
      </View>
    </>
  )
}

export default FixedButton
