1/* 2 * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. 3 */ 4 5@Styles 6function pressStyles() { 7 .backgroundColor($r('sys.color.ohos_id_color_click_effect')) 8} 9 10@Styles 11function normalStyles() { 12 .backgroundColor($r('sys.color.ohos_id_color_background_transparent')) 13} 14 15@Component 16export struct DialogButton { 17 text?: Resource; 18 color: Resource | string = $r('sys.color.ohos_id_color_text_primary_activated'); 19 bgColor: Resource | string = $r('sys.color.ohos_id_color_background_transparent'); 20 @Prop isDisabled: boolean = false; 21 click?: Function; 22 compId?: Resource = $r('app.string.confirm'); 23 24 build() { 25 Row() { 26 Row() { 27 Text(this.text) 28 .fontSize($r('sys.float.ohos_id_text_size_button1')) 29 .fontColor(this.color) 30 .fontWeight(FontWeight.Medium) 31 .textCase(TextCase.UpperCase) 32 }.height('100%') 33 .width('100%') 34 .justifyContent(FlexAlign.Center) 35 .onClick(() => { 36 if ((!this.click) || this.isDisabled) { 37 return 38 } 39 this.click() 40 }) 41 } 42 .id(this.text === this.compId ? 'dialog_confirm' : 'dialog_cancel') 43 .enabled(!this.isDisabled) 44 .height(40) 45 .layoutWeight(1) 46 .backgroundColor(this.bgColor) 47 .stateStyles({ 48 normal: normalStyles, 49 pressed: pressStyles 50 }) 51 .opacity(this.isDisabled ? $r('app.float.common_opacity5') : $r('app.float.common_opacity10')) 52 .borderRadius($r('sys.float.ohos_id_corner_radius_dialog')) 53 } 54} 55 56@Component 57export struct DialogButtonDivider { 58 build() { 59 Divider().vertical(true) 60 .margin({ left: 8, right: 8 }) 61 .height($r('app.float.divider_height24')) 62 .color($r('sys.color.ohos_id_color_list_separator')) 63 } 64} 65 66