1/* 2 * Copyright (c) 2021 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 16exports.source = ` 17const value5: boolean[] = [true, false] 18let value6: {item1: boolean} = {item1: true} 19 20@Entry 21@Component 22struct HomeComponent { 23 private value1: string = "hello world 1" 24 private value2: string = "hello world 2" 25 private value3: string = "hello world 3" 26 private value4: boolean = false 27 28 build() { 29 Column() { 30 Row() { 31 Text(this.value1) 32 Text(this.value2) 33 Text(this.value3) 34 Radio({value: "Radio", group: "1"}) 35 .checked($$this.value4) 36 } 37 Row() { 38 Button() { 39 Text(this.value1) 40 .fontSize(20) 41 .bindPopup($$value5[0], {message: "This is $$ for Array"}) 42 } 43 .bindPopup($$this.value4, {message: "This is $$ for regular"}) 44 .width(100) 45 .height(20) 46 Text(this.value2) 47 .fontSize(100) 48 .bindPopup($$value6.item1, {message: "This is $$ for Obj"}) 49 Text(this.value3) 50 Radio({value: "Radio", group: "1"}) 51 .checked($$value5[0]) 52 } 53 .width(20) 54 } 55 .height(500) 56 } 57}` 58 59exports.expectResult = 60`"use strict"; 61const value5 = [true, false]; 62let value6 = { item1: true }; 63class HomeComponent extends View { 64 constructor(compilerAssignedUniqueChildId, parent, params) { 65 super(compilerAssignedUniqueChildId, parent); 66 this.value1 = "hello world 1"; 67 this.value2 = "hello world 2"; 68 this.value3 = "hello world 3"; 69 this.value4 = false; 70 this.updateWithValueParams(params); 71 } 72 updateWithValueParams(params) { 73 if (params.value1 !== undefined) { 74 this.value1 = params.value1; 75 } 76 if (params.value2 !== undefined) { 77 this.value2 = params.value2; 78 } 79 if (params.value3 !== undefined) { 80 this.value3 = params.value3; 81 } 82 if (params.value4 !== undefined) { 83 this.value4 = params.value4; 84 } 85 } 86 aboutToBeDeleted() { 87 SubscriberManager.Get().delete(this.id()); 88 } 89 render() { 90 Column.create(); 91 Column.height(500); 92 Row.create(); 93 Text.create(this.value1); 94 Text.pop(); 95 Text.create(this.value2); 96 Text.pop(); 97 Text.create(this.value3); 98 Text.pop(); 99 Radio.create({ value: "Radio", group: "1" }); 100 Radio.checked(this.value4, newValue => { this.value4 = newValue; }); 101 Row.pop(); 102 Row.create(); 103 Row.width(20); 104 Button.createWithChild(); 105 Button.bindPopup({ value: this.value4, changeEvent: newValue => { this.value4 = newValue; } }, { message: "This is $$ for regular" }); 106 Button.width(100); 107 Button.height(20); 108 Text.create(this.value1); 109 Text.fontSize(20); 110 Text.bindPopup({ value: value5[0], changeEvent: newValue => { value5[0] = newValue; } }, { message: "This is $$ for Array" }); 111 Text.pop(); 112 Button.pop(); 113 Text.create(this.value2); 114 Text.fontSize(100); 115 Text.bindPopup({ value: value6.item1, changeEvent: newValue => { value6.item1 = newValue; } }, { message: "This is $$ for Obj" }); 116 Text.pop(); 117 Text.create(this.value3); 118 Text.pop(); 119 Radio.create({ value: "Radio", group: "1" }); 120 Radio.checked(value5[0], newValue => { value5[0] = newValue; }); 121 Row.pop(); 122 Column.pop(); 123 } 124} 125loadDocument(new HomeComponent("1", undefined, {})); 126` 127