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 16 17@Entry 18@Component 19struct EntryComponent { 20 build() { 21 Text("hello") 22 } 23} 24 25let storage = LocalStorage.GetShared() 26 27@Entry(storage) 28@Component 29struct LocalStorageComponent { 30 @LocalStorageLink('storageSimpleProp') simpleVarName: number = 0 31 32 build() { 33 Column() { 34 Button(`LocalStorageLink: ${this.simpleVarName.toString()}`) 35 .margin(20) 36 .onClick(() => { 37 this.simpleVarName += 1 38 }) 39 }.width('100%') 40 } 41} 42 43@Preview 44@Component 45struct index { 46 build() { 47 Text("heelo") 48 } 49} 50 51@Component 52struct index2 { 53 build() { 54 Text("heelo") 55 } 56} 57 58 59@CustomDialog 60@Component 61struct DialogExample { 62 controller: CustomDialogController 63 action: () => void 64 65 build() { 66 Row() { 67 Button('Close CustomDialog') 68 .onClick(() => { 69 this.controller.close() 70 this.action() 71 }) 72 }.padding(20) 73 } 74} 75 76@Observed 77class ClassA { 78 public name: string 79 public c: number 80 81 constructor(c: number, name: string = 'OK') { 82 this.name = name 83 this.c = c 84 } 85} 86 87@Component 88struct PropertyAndMethod { 89 @Consume("reviewVote") reviewVotes: number 90 @Link buttonPlaying: boolean 91 @LocalStorageLink("PropA") storageLink: number = 1; 92 @LocalStorageProp('storageSimpleProp') simpleVarName: number = 0 93 @ObjectLink a: string; 94 @Prop property5: number 95 @Provide("property") property6: number; 96 @State count: number = 0 97 @StorageLink('varA') varA: number = 2 98 @StorageProp('languageCode') languageCode: string = 'en' 99 @State @Watch('onBasketUpdated') shopBasket: Array<number> = [7, 12, 47, 3] 100 @BuilderParam noParam: () => void 101 102 @Builder CompC(value: string) { 103 Text("hello").fontSize(value) 104 }; 105 106 @Styles globalFancy() { 107 .width(150) 108 .height(100) 109 .backgroundColor(Color.Pink) 110 }; 111 112 build() { 113 } 114} 115 116@Builder function specificParam02(label1: string, label2: string) { 117 Column() { 118 Text(label1) 119 .fontSize(30) 120 Text(label2) 121 .fontSize(30) 122 } 123} 124