1/** 2 * Copyright (c) 2024 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 16if (!('finalizeConstruction' in ViewPU.prototype)) { 17 Reflect.set(ViewPU.prototype, 'finalizeConstruction', () => { }); 18} 19interface Index_Params { 20 message?: string; 21} 22class Index extends ViewPU { 23 constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { 24 super(parent, __localStorage, elmtId, extraInfo); 25 if (typeof paramsLambda === 'function') { 26 this.paramsGenerator_ = paramsLambda; 27 } 28 this.__message = new ObservedPropertySimplePU('Hello World', this, 'message'); 29 this.setInitiallyProvidedValue(params); 30 this.finalizeConstruction(); 31 } 32 setInitiallyProvidedValue(params: Index_Params): void { 33 if (params.message !== undefined) { 34 this.message = params.message; 35 } 36 } 37 updateStateVars(params: Index_Params): void { 38 } 39 purgeVariableDependenciesOnElmtId(rmElmtId): void { 40 this.__message.purgeDependencyOnElmtId(rmElmtId); 41 } 42 aboutToBeDeleted(): void { 43 this.__message.aboutToBeDeleted(); 44 SubscriberManager.Get().delete(this.id__()); 45 this.aboutToBeDeletedInternal(); 46 } 47 private __message: ObservedPropertySimplePU<string>; 48 get message(): string { 49 return this.__message.get(); 50 } 51 set message(newValue: string) { 52 this.__message.set(newValue); 53 } 54 initialRender(): void { 55 this.observeComponentCreation2((elmtId, isInitialRender) => { 56 RelativeContainer.create(); 57 RelativeContainer.height('100%'); 58 RelativeContainer.width('100%'); 59 }, RelativeContainer); 60 this.observeComponentCreation2((elmtId, isInitialRender) => { 61 Text.create(this.message); 62 Text.id('HelloWorld'); 63 Text.fontSize(50); 64 Text.fontWeight(FontWeight.Bold); 65 Text.alignRules({ 66 center: { anchor: '__container__', align: VerticalAlign.Center }, 67 middle: { anchor: '__container__', align: HorizontalAlign.Center } 68 }); 69 }, Text); 70 Text.pop(); 71 RelativeContainer.pop(); 72 } 73 rerender(): void { 74 this.updateDirtyElements(); 75 } 76 static getEntryName(): string { 77 return 'Index'; 78 } 79} 80registerNamedRoute(() => new Index(undefined, {}), '', { bundleName: 'com.example.hello', moduleName: 'entry', pagePath: 'pages/Index', pageFullPath: 'entry/src/main/ets/pages/Index', integratedHsp: 'false', moduleType: 'followWithHap' }); 81