1/* 2 * Copyright (c) 2021-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16@Styles 17function pressStyles() { 18 .backgroundColor($r('app.color.button_pressStyles')) 19} 20 21@Styles 22function normalStyles() { 23 .borderRadius($r('app.float.common_borderRadius8')) 24 .backgroundColor($r('app.color.transparent_color')) 25} 26 27@Component 28export struct DialogTitle { 29 title: Resource = $r('app.string.addFolder'); 30 31 constructor(title: Resource) { 32 super(); 33 this.title = title; // 通过构造函数初始化 34 } 35 36 37 build() { 38 Text(this.title) 39 .fontSize($r('app.float.common_font_size20')) 40 .fontColor($r('app.color.dialog_title_font_color')) 41 .fontWeight(FontWeight.Medium) 42 .width('100%') 43 .padding({ 44 top: $r('app.float.common_padding14'), 45 bottom: $r('app.float.common_padding14') 46 }) 47 } 48} 49 50@Component 51export struct DialogButton { 52 text: Resource = $r('app.string.cancel'); 53 color: Resource = $r('app.color.dialog_button_blue'); 54 bgColor: Resource = $r('app.color.transparent_color'); 55 @Prop isDisabled: boolean; 56 click: Function = () => {}; 57 58 build() { 59 Row() { 60 Row() { 61 Text(this.text) 62 .fontSize($r('app.float.common_font_size16')) 63 .fontColor(this.color) 64 .fontWeight(FontWeight.Medium) 65 }.height('100%') 66 .width('100%') 67 .justifyContent(FlexAlign.Center) 68 .onClick(() => { 69 if (!this.click || this.isDisabled) { 70 return 71 } 72 this.click() 73 }) 74 } 75 .height($r('app.float.common_line_height36')) 76 .layoutWeight(1) 77 .backgroundColor(this.bgColor) 78 .stateStyles({ 79 pressed: pressStyles, 80 normal: normalStyles 81 }) 82 .opacity(this.isDisabled ? $r('app.float.common_opacity5') : $r('app.float.common_opacity10')) 83 .borderRadius($r('app.float.common_borderRadius18')) 84 } 85} 86 87@Component 88export struct DialogButtonDivider { 89 build() { 90 Divider().vertical(true) 91 .margin({ left: $r('app.float.common_margin10'), right: $r('app.float.common_margin10') }) 92 .height($r('app.float.divider_height24')) 93 .color($r('app.color.dialog_button_divider_color')) 94 } 95} 96