1/* 2 * Copyright (c) 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@CustomDialog 16export struct CustomDialogExample1 { 17 @Link textValue: string 18 @Link inputValue: string 19 controller: CustomDialogController 20 cancel: () => void 21 confirm: () => void 22 23 build() { 24 Column() { 25 Text('Change text').fontSize(20).margin({ top: 10, bottom: 10 }) 26 TextInput({ placeholder: '', text: this.textValue }).height(60).width('90%') 27 .onChange((value: string) => { 28 this.textValue = value 29 }) 30 Text('Whether to change a text?').fontSize(16).margin({ bottom: 10 }) 31 Flex({ justifyContent: FlexAlign.SpaceAround }) { 32 Button('cancel') 33 .onClick(() => { 34 this.controller.close() 35 this.cancel() 36 }).backgroundColor(0xffffff).fontColor(Color.Black) 37 Button('confirm') 38 .onClick(() => { 39 this.inputValue = this.textValue 40 this.controller.close() 41 this.confirm() 42 }).backgroundColor(0xffffff).fontColor(Color.Red) 43 }.margin({ bottom: 10 }) 44 } 45 } 46}