1/* 2 * Copyright (c) 2021-2022 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 16import Log from '../../../../../../../../common/src/main/ets/default/Log'; 17import StyleConfiguration, { ControlEditDialogStyle } from '../common/StyleConfiguration'; 18 19const TAG = 'Control-SimpleToggleLayoutEditDialogComponent'; 20 21@CustomDialog 22export default struct SimpleToggleLayoutEditDialogComponent { 23 private title: Resource; 24 private leftButton: Resource; 25 private rightButton: Resource; 26 private controller: CustomDialogController; 27 private leftAction: () => void; 28 private rightAction: () => void; 29 @State style: ControlEditDialogStyle = StyleConfiguration.getControlEditDialogStyle(); 30 31 aboutToAppear() { 32 Log.showInfo(TAG, 'aboutToAppear'); 33 } 34 35 aboutToDisappear() { 36 Log.showInfo(TAG, 'aboutToDisappear'); 37 } 38 39 build() { 40 Column() { 41 Row().height(this.style.editDialogFontMarginTop).layoutWeight(0).width(1) 42 Row() { 43 Column() { 44 Text(this.title) 45 .fontSize(this.style.editDialogFontSize) 46 }.layoutWeight(1) 47 }.width('100%') 48 .height(this.style.editDialogFontHeight) 49 50 Row().width('100%').height(this.style.editDialogBtnMarginTop) 51 52 Row() { 53 Column().width(this.style.editDialogBtnMarginLF).height(1).layoutWeight(0) 54 Row() { 55 Column() { 56 Button({ type: ButtonType.Capsule, stateEffect: true }) { 57 Text(this.leftButton) 58 .fontColor(this.style.editDialogBtnFontColor) 59 .fontSize(this.style.editDialogButtonSize) 60 } 61 .backgroundColor(this.style.editDialogBtnBgColor) 62 .width('100%') 63 .height('100%') 64 .onClick(() => { 65 Log.showInfo(TAG, `left button on click`) 66 if (this.leftAction) { 67 this.leftAction() 68 } 69 this.controller.close(); 70 }) 71 }.width(this.style.editDialogBtnWidth) 72 73 Divider() 74 .vertical(true) 75 .backgroundColor(this.style.editDialogDividerColor) 76 .strokeWidth(this.style.editDialogDividerWidth) 77 .height(this.style.editDialogDividerHeight) 78 79 Column() { 80 Button({ type: ButtonType.Capsule, stateEffect: true }) { 81 Text(this.rightButton) 82 .fontColor(this.style.editDialogBtnFontColor) 83 .fontSize(this.style.editDialogButtonSize) 84 } 85 .backgroundColor(this.style.editDialogBtnBgColor) 86 .width('100%') 87 .height('100%') 88 .onClick(() => { 89 Log.showInfo(TAG, `right button on click`) 90 if (this.rightAction) { 91 this.rightAction() 92 } 93 this.controller.close(); 94 }) 95 }.width(this.style.editDialogBtnWidth) 96 } 97 .height(this.style.editDialogButtonHeight) 98 99 Column().width(this.style.editDialogBtnMarginLF).height(1).layoutWeight(0) 100 } 101 .width('100%') 102 103 Row().width('100%').height(this.style.editDialogBtnMarginTop) 104 }.height(this.style.editDialogHeight) 105 .width(this.style.editDialogWidth) 106 .backgroundColor(this.style.editDialogColor) 107 .border({ width: 1, color: this.style.editDialogColor, 108 radius: this.style.editDialogRadius }) 109 } 110} 111