DialogButton.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <FlexRow
  3. :innerStyle="{
  4. ...themeStyles.dialogButton.value,
  5. ...vertical ? {} : themeStyles.dialogButtonHorz.value,
  6. }"
  7. :pressedColor="themeContext.resolveThemeColor(pressedColor)"
  8. touchable
  9. @click="loading ? undefined : $emit('click')"
  10. >
  11. <ActivityIndicator
  12. v-if="loading"
  13. :color="themeContext.resolveThemeColor(buttonColor)"
  14. :size="themeContext.resolveThemeSize('DialogButtonTextFontSize', 30)"
  15. />
  16. <text
  17. v-else
  18. :style="{
  19. ...themeStyles.buttonText.value,
  20. color: themeContext.resolveThemeColor(buttonColor)
  21. }"
  22. >
  23. {{props.text}}
  24. </text>
  25. </FlexRow>
  26. </template>
  27. <script setup lang="ts">
  28. import ActivityIndicator from '../basic/ActivityIndicator.vue';
  29. import FlexRow from '../layout/FlexRow.vue';
  30. import { propGetThemeVar, useTheme } from '../theme/ThemeDefine';
  31. import { DynamicColor, DynamicSize } from '../theme/ThemeTools';
  32. /**
  33. * 对话框底部按扭组件Props
  34. */
  35. export interface DialogButtonProps {
  36. /**
  37. * 按钮文字
  38. */
  39. text?: string|undefined,
  40. /**
  41. * 按钮文字
  42. * @default false
  43. */
  44. loading?: boolean,
  45. /**
  46. * 按钮文字
  47. * @default false
  48. */
  49. vertical?: boolean|undefined,
  50. /**
  51. * 按钮文字
  52. * @default undefined
  53. */
  54. buttonColor?: string|undefined,
  55. /**
  56. * 按钮文字
  57. * @default undefined
  58. */
  59. pressedColor?: string|undefined,
  60. }
  61. const themeContext = useTheme();
  62. const themeStyles = themeContext.useThemeStyles({
  63. dialogButton: {
  64. justifyContent: 'center',
  65. alignItems: 'center',
  66. height: DynamicSize('DialogButtonHeight', 90),
  67. borderTopStyle: 'solid',
  68. borderTopWidth: DynamicSize('DialogButtonBorderTopWidth', 2),
  69. borderTopColor: DynamicColor('DialogButtonBorderTopColor', 'border.cell'),
  70. borderRightStyle: 'solid',
  71. borderRightWidth: DynamicSize('DialogButtonBorderTopWidth', 2),
  72. borderRightColor: DynamicColor('DialogButtonBorderTopColor', 'border.cell'),
  73. },
  74. dialogButtonHorz: {
  75. flex: 1,
  76. borderBottomStyle: 'solid',
  77. borderBottomWidth: DynamicSize('DialogButtonBorderBottomWidth', 2),
  78. borderBottomColor: DynamicColor('DialogButtonBorderBottomColor', 'border.cell'),
  79. },
  80. buttonText: {
  81. fontSize: DynamicSize('DialogButtonTextFontSize', 30),
  82. fontWeight: DynamicSize('DialogButtonTextFontWeight', 'bold'),
  83. },
  84. });
  85. const emit = defineEmits([ 'click' ]);
  86. const props = withDefaults(defineProps<DialogButtonProps>(), {
  87. text: '确定',
  88. loading: false,
  89. vertical: false,
  90. buttonColor: undefined,
  91. pressedColor: () => propGetThemeVar('DialogButtonPressedColor', 'pressed.white'),
  92. });
  93. </script>