107ac75b1Sopenharmony_ci/*
207ac75b1Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd.
307ac75b1Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
407ac75b1Sopenharmony_ci * you may not use this file except in compliance with the License.
507ac75b1Sopenharmony_ci * You may obtain a copy of the License at
607ac75b1Sopenharmony_ci *
707ac75b1Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
807ac75b1Sopenharmony_ci *
907ac75b1Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1007ac75b1Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1107ac75b1Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1207ac75b1Sopenharmony_ci * See the License for the specific language governing permissions and
1307ac75b1Sopenharmony_ci * limitations under the License.
1407ac75b1Sopenharmony_ci */
1507ac75b1Sopenharmony_ci
1607ac75b1Sopenharmony_ciexports.source = `
1707ac75b1Sopenharmony_ciimport { CustomDialogExample1 as CustomDialogExample } from './test/pages/import@CustomDialog'
1807ac75b1Sopenharmony_ci
1907ac75b1Sopenharmony_ci@Entry
2007ac75b1Sopenharmony_ci@Component
2107ac75b1Sopenharmony_cistruct CustomDialogUser {
2207ac75b1Sopenharmony_ci  @State textValue: string = ''
2307ac75b1Sopenharmony_ci  @State inputValue: string = 'click me'
2407ac75b1Sopenharmony_ci  dialogController: CustomDialogController = new CustomDialogController({
2507ac75b1Sopenharmony_ci    builder: CustomDialogExample({
2607ac75b1Sopenharmony_ci      cancel: this.onCancel,
2707ac75b1Sopenharmony_ci      confirm: this.onAccept,
2807ac75b1Sopenharmony_ci      textValue: $textValue,
2907ac75b1Sopenharmony_ci      inputValue: $inputValue
3007ac75b1Sopenharmony_ci    }),
3107ac75b1Sopenharmony_ci    cancel: this.existApp,
3207ac75b1Sopenharmony_ci    autoCancel: true,
3307ac75b1Sopenharmony_ci    alignment: DialogAlignment.Default,
3407ac75b1Sopenharmony_ci    offset: { dx: 0, dy: -20 },
3507ac75b1Sopenharmony_ci    gridCount: 4,
3607ac75b1Sopenharmony_ci    customStyle: false
3707ac75b1Sopenharmony_ci  })
3807ac75b1Sopenharmony_ci
3907ac75b1Sopenharmony_ci  onCancel() {
4007ac75b1Sopenharmony_ci    console.info('Callback when the first button is clicked')
4107ac75b1Sopenharmony_ci  }
4207ac75b1Sopenharmony_ci
4307ac75b1Sopenharmony_ci  onAccept() {
4407ac75b1Sopenharmony_ci    console.info('Callback when the second button is clicked')
4507ac75b1Sopenharmony_ci  }
4607ac75b1Sopenharmony_ci
4707ac75b1Sopenharmony_ci  existApp() {
4807ac75b1Sopenharmony_ci    console.info('Click the callback in the blank area')
4907ac75b1Sopenharmony_ci  }
5007ac75b1Sopenharmony_ci
5107ac75b1Sopenharmony_ci  build() {
5207ac75b1Sopenharmony_ci    Column() {
5307ac75b1Sopenharmony_ci      Button(this.inputValue)
5407ac75b1Sopenharmony_ci        .onClick(() => {
5507ac75b1Sopenharmony_ci          this.dialogController.open()
5607ac75b1Sopenharmony_ci        }).backgroundColor(0x317aff)
5707ac75b1Sopenharmony_ci    }.width('100%').margin({ top: 5 })
5807ac75b1Sopenharmony_ci  }
5907ac75b1Sopenharmony_ci}
6007ac75b1Sopenharmony_ci`
6107ac75b1Sopenharmony_ci
6207ac75b1Sopenharmony_ciexports.expectResult =
6307ac75b1Sopenharmony_ci`"use strict";
6407ac75b1Sopenharmony_ciObject.defineProperty(exports, "__esModule", { value: true });
6507ac75b1Sopenharmony_cilet __generate__Id = 0;
6607ac75b1Sopenharmony_cifunction generateId() {
6707ac75b1Sopenharmony_ci    return "import@CustomDialog_" + ++__generate__Id;
6807ac75b1Sopenharmony_ci}
6907ac75b1Sopenharmony_ciconst import_CustomDialog_1 = require("./test/pages/import@CustomDialog");
7007ac75b1Sopenharmony_ciclass CustomDialogUser extends View {
7107ac75b1Sopenharmony_ci    constructor(compilerAssignedUniqueChildId, parent, params, localStorage) {
7207ac75b1Sopenharmony_ci        super(compilerAssignedUniqueChildId, parent, localStorage);
7307ac75b1Sopenharmony_ci        this.__textValue = new ObservedPropertySimple('', this, "textValue");
7407ac75b1Sopenharmony_ci        this.__inputValue = new ObservedPropertySimple('click me', this, "inputValue");
7507ac75b1Sopenharmony_ci        this.dialogController = new CustomDialogController({
7607ac75b1Sopenharmony_ci            builder: () => {
7707ac75b1Sopenharmony_ci                let jsDialog = new import_CustomDialog_1.CustomDialogExample1("2", this, {
7807ac75b1Sopenharmony_ci                    cancel: this.onCancel,
7907ac75b1Sopenharmony_ci                    confirm: this.onAccept,
8007ac75b1Sopenharmony_ci                    textValue: this.__textValue,
8107ac75b1Sopenharmony_ci                    inputValue: this.__inputValue
8207ac75b1Sopenharmony_ci                });
8307ac75b1Sopenharmony_ci                jsDialog.setController(this.dialogController);
8407ac75b1Sopenharmony_ci                View.create(jsDialog);
8507ac75b1Sopenharmony_ci            },
8607ac75b1Sopenharmony_ci            cancel: this.existApp,
8707ac75b1Sopenharmony_ci            autoCancel: true,
8807ac75b1Sopenharmony_ci            alignment: DialogAlignment.Default,
8907ac75b1Sopenharmony_ci            offset: { dx: 0, dy: -20 },
9007ac75b1Sopenharmony_ci            gridCount: 4,
9107ac75b1Sopenharmony_ci            customStyle: false
9207ac75b1Sopenharmony_ci        }, this);
9307ac75b1Sopenharmony_ci        this.updateWithValueParams(params);
9407ac75b1Sopenharmony_ci    }
9507ac75b1Sopenharmony_ci    updateWithValueParams(params) {
9607ac75b1Sopenharmony_ci        if (params.textValue !== undefined) {
9707ac75b1Sopenharmony_ci            this.textValue = params.textValue;
9807ac75b1Sopenharmony_ci        }
9907ac75b1Sopenharmony_ci        if (params.inputValue !== undefined) {
10007ac75b1Sopenharmony_ci            this.inputValue = params.inputValue;
10107ac75b1Sopenharmony_ci        }
10207ac75b1Sopenharmony_ci        if (params.dialogController !== undefined) {
10307ac75b1Sopenharmony_ci            this.dialogController = params.dialogController;
10407ac75b1Sopenharmony_ci        }
10507ac75b1Sopenharmony_ci    }
10607ac75b1Sopenharmony_ci    aboutToBeDeleted() {
10707ac75b1Sopenharmony_ci        this.__textValue.aboutToBeDeleted();
10807ac75b1Sopenharmony_ci        this.__inputValue.aboutToBeDeleted();
10907ac75b1Sopenharmony_ci        SubscriberManager.Get().delete(this.id());
11007ac75b1Sopenharmony_ci    }
11107ac75b1Sopenharmony_ci    get textValue() {
11207ac75b1Sopenharmony_ci        return this.__textValue.get();
11307ac75b1Sopenharmony_ci    }
11407ac75b1Sopenharmony_ci    set textValue(newValue) {
11507ac75b1Sopenharmony_ci        this.__textValue.set(newValue);
11607ac75b1Sopenharmony_ci    }
11707ac75b1Sopenharmony_ci    get inputValue() {
11807ac75b1Sopenharmony_ci        return this.__inputValue.get();
11907ac75b1Sopenharmony_ci    }
12007ac75b1Sopenharmony_ci    set inputValue(newValue) {
12107ac75b1Sopenharmony_ci        this.__inputValue.set(newValue);
12207ac75b1Sopenharmony_ci    }
12307ac75b1Sopenharmony_ci    onCancel() {
12407ac75b1Sopenharmony_ci        console.info('Callback when the first button is clicked');
12507ac75b1Sopenharmony_ci    }
12607ac75b1Sopenharmony_ci    onAccept() {
12707ac75b1Sopenharmony_ci        console.info('Callback when the second button is clicked');
12807ac75b1Sopenharmony_ci    }
12907ac75b1Sopenharmony_ci    existApp() {
13007ac75b1Sopenharmony_ci        console.info('Click the callback in the blank area');
13107ac75b1Sopenharmony_ci    }
13207ac75b1Sopenharmony_ci    render() {
13307ac75b1Sopenharmony_ci        Column.create();
13407ac75b1Sopenharmony_ci        Column.width('100%');
13507ac75b1Sopenharmony_ci        Column.margin({ top: 5 });
13607ac75b1Sopenharmony_ci        Button.createWithLabel(this.inputValue);
13707ac75b1Sopenharmony_ci        Button.onClick(() => {
13807ac75b1Sopenharmony_ci            this.dialogController.open();
13907ac75b1Sopenharmony_ci        });
14007ac75b1Sopenharmony_ci        Button.backgroundColor(0x317aff);
14107ac75b1Sopenharmony_ci        Button.pop();
14207ac75b1Sopenharmony_ci        Column.pop();
14307ac75b1Sopenharmony_ci    }
14407ac75b1Sopenharmony_ci}
14507ac75b1Sopenharmony_ciloadDocument(new CustomDialogUser("1", undefined, {}));
14607ac75b1Sopenharmony_ci`
147