<template>
  <IconButton
    v-if="!isListStyle"
    icon="add"
    :size="themeContext.getVar('UploaderAddIconSize', 60)"
    :pressedBackgroundColor="themeContext.getVar('UploaderListAddItemPressedBackgroundColor', 'pressed.grey')"
    :buttonStyle="{
      ...themeStyles.itemAddButton.value, 
      ...props.style, 
      width: themeContext.resolveSize(itemSize.width),
      height: themeContext.resolveSize(itemSize.height),
    }"
    @click="emit('click')"
  />
  <Button block v-else text="上传" icon="upload" @click="emit('click')" />
</template>

<script setup lang="ts">
import Button from '../basic/Button.vue';
import IconButton from '../basic/IconButton.vue';
import { useTheme, type ViewStyle } from '../theme/ThemeDefine';
import { DynamicColor, DynamicSize } from '../theme/ThemeTools';

export interface UploaderListAddItemProps {
  style?: ViewStyle;
  isListStyle?: boolean;
  itemSize: { width: number, height: number };
}

const props = defineProps<UploaderListAddItemProps>();
const emit = defineEmits(['click'])
const themeContext = useTheme();

const themeStyles = themeContext.useThemeStyles({
  itemAddButton: {
    overflow: 'hidden',
    backgroundColor: DynamicColor('UploaderListAddItemBackgroundColor', 'grey'),
    borderRadius: DynamicSize('UploaderListAddItemBorderRadius', 20),
    margin: DynamicSize('UploaderListAddItemMargin', 4),
  },
});

</script>