ActionSheetItem.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <template>
  2. <Touchable
  3. center
  4. direction="column"
  5. :touchable="!disabled"
  6. :innerStyle="themeStyles.item.value"
  7. :pressedColor="themeContext.resolveThemeColor('ActionSheetItemPressedColor', 'pressed.white')"
  8. @click="disabled === true ? undefined : emit('click')"
  9. >
  10. <text
  11. :style="{
  12. ...themeStyles.itemTitle.value,
  13. color: themeContext.resolveThemeColor(props.disabled === true ? themeContext.resolveThemeColor('ActionSheetItemDisabledTextColor', 'grey') : props.color),
  14. fontWeight: bold ? 'bold' : 'normal',
  15. }"
  16. >
  17. {{ name }}
  18. </text>
  19. <text v-if="subname" :style="themeStyles.itemSubTitle.value">{{subname}}</text>
  20. </Touchable>
  21. </template>
  22. <script setup lang="ts">
  23. import Touchable from '../feedback/Touchable.vue';
  24. import { useTheme } from '../theme/ThemeDefine';
  25. import { DynamicColor, DynamicSize } from '../theme/ThemeTools';
  26. export interface ActionSheetItemProps {
  27. name: string;
  28. subname: string|undefined;
  29. bold: boolean|undefined;
  30. color: string|undefined;
  31. disabled: boolean|undefined;
  32. }
  33. const themeContext = useTheme();
  34. const themeStyles = themeContext.useThemeStyles({
  35. item: {
  36. paddingTop: DynamicSize('ActionSheetItemPaddingVertical', 26),
  37. paddingBottom: DynamicSize('ActionSheetItemPaddingVertical', 26),
  38. backgroundColor: DynamicColor('ActionSheetItemBackgroundColor', 'white'),
  39. },
  40. itemTitle: {
  41. fontSize: DynamicSize('ActionSheetItemTitleFontSize', 32),
  42. color: DynamicColor('ActionSheetItemTitleColor', 'text.content'),
  43. },
  44. itemSubTitle: {
  45. fontSize: DynamicSize('ActionSheetItemSubTitleFontSize', 26),
  46. color: DynamicColor('ActionSheetItemSubTitleColor', 'text.second'),
  47. marginTop: DynamicSize('ActionSheetItemSubTitleMarginTop', 4),
  48. },
  49. });
  50. const emit = defineEmits([ 'click' ]);
  51. const props = withDefaults(defineProps<ActionSheetItemProps>(), {});
  52. </script>