ActionSheetTitle.vue 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <FlexRow
  3. v-if="title || description || cancelText || confirmText"
  4. :innerStyle="{
  5. ...themeStyles.titleView.value,
  6. ...border ? themeStyles.titleViewBorder.value : {},
  7. }"
  8. justify="space-between"
  9. >
  10. <Button v-if="cancelText" type="text" :textColor="cancelTextColor" @click="emit('cancel')">{{ cancelText }}</Button>
  11. <view v-else />
  12. <FlexCol v-if="title || description" :style="themeStyles.titleTextView.value" center>
  13. <text v-if="title" :style="themeStyles.title.value">{{ title }}</text>
  14. <text v-if="description" :style="themeStyles.description.value">{{ description }}</text>
  15. </FlexCol>
  16. <Button v-if="confirmText" type="text" :textColor="confirmTextColor" :touchable="!confirmDisabled" @click="emit('confirm')">{{ confirmText }}</Button>
  17. <view v-else />
  18. </FlexRow>
  19. </template>
  20. <script setup lang="ts">
  21. import Button from '../basic/Button.vue';
  22. import FlexCol from '../layout/FlexCol.vue';
  23. import FlexRow from '../layout/FlexRow.vue';
  24. import { useTheme } from '../theme/ThemeDefine';
  25. import { DynamicColor, DynamicSize, DynamicSize2 } from '../theme/ThemeTools';
  26. export interface ActionSheetTitleProps {
  27. /**
  28. * 标题
  29. */
  30. title?: string,
  31. /**
  32. * 说明
  33. */
  34. description?: string,
  35. /**
  36. * 取消按钮文字,如果不为空则会在左边添加一个取消按钮
  37. */
  38. cancelText?: string,
  39. /**
  40. * 确定按钮文字,如果不为空则会在右边添加一个确定按钮
  41. */
  42. confirmText?: string,
  43. /**
  44. * 取消按钮文字颜色
  45. * @default text.content
  46. */
  47. cancelTextColor?: string,
  48. /**
  49. * 确定按钮文字颜色
  50. * @default primary
  51. */
  52. confirmTextColor?: string,
  53. /**
  54. * 确定按钮是否禁用
  55. * @default false
  56. */
  57. confirmDisabled?: boolean,
  58. /**
  59. * 是否显示底部边框
  60. * @default true
  61. */
  62. border?: boolean;
  63. }
  64. const themeContext = useTheme();
  65. const themeStyles = themeContext.useThemeStyles({
  66. titleView: {
  67. padding: DynamicSize2('ActionSheetTitlePaddingHorizontal', 'ActionSheetTitlePaddingVertical', 16, 20),
  68. },
  69. titleViewBorder: {
  70. borderBottomStyle: 'solid',
  71. borderBottomColor: DynamicColor('ActionSheetTitleBorderBottomColor', 'border.cell'),
  72. borderBottomWidth: DynamicSize('ActionSheetTitleBorderBottomWidth', 2),
  73. },
  74. titleTextView: {
  75. paddingTop: DynamicSize('ActionSheetTitleTextPaddingVertical', 5),
  76. paddingBottom: DynamicSize('ActionSheetTitleTextPaddingVertical', 10),
  77. },
  78. title: {
  79. fontSize: DynamicSize('ActionSheetTitleTextFontSize', 32),
  80. color: DynamicColor('ActionSheetTitleTextColor', 'text.content'),
  81. },
  82. description: {
  83. fontSize: DynamicSize('ActionSheetTitleDescriptionFontSize', 26),
  84. color: DynamicColor('ActionSheetTitleDescriptionColor', 'text.second'),
  85. },
  86. });
  87. const emit = defineEmits([ 'cancel', 'confirm' ]);
  88. const props = withDefaults(defineProps<ActionSheetTitleProps>(), {});
  89. </script>