• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
16@Entry
17@Component
18struct UserView {
19
20    @State
21    button_name:string = "Before Click";
22
23    @State
24    currentView:string = "opacity";
25
26    build(){
27        Column() {
28            if(this.currentView === "opacity") {
29                Column(){
30                    Row(){
31                        Text("Row Text1")
32                    }
33                    .width(100).height(100).opacity(0.5).backgroundColor("#c4b0dd")
34                    Row(){
35                        Text("Row Text2")
36                    }
37                    .width(100).height(100).opacity(1).backgroundColor("#c4b0dd")
38                    Text("Column Text1").height(100).backgroundColor("#c4b0de")
39                    Text("Column Text2").height(100).backgroundColor("#c4deb0").opacity(0.5)
40                    Image("pages/pictures/0.jpeg").width(600).height(300)
41                    Image("pages/pictures/0.jpeg").width(600).height(300).opacity(0.5)
42                    Button("Button1").height(100).backgroundColor("#c4deb0")
43                    Button("Button2").height(100).backgroundColor("#c4deb0").opacity(0.5)
44                    Divider().height(10).color("red")
45                    Divider().height(10).color("red").opacity(0.5)
46                }
47                .width(700).backgroundColor("#b0c4de").margin(20)
48            } else if(this.currentView === "button") {
49                Button("V8 Button test:" + this.button_name)
50                .width(600).height(100).backgroundColor("#b0c4de").margin(50)
51                .onClick(() => {
52                    console.log("V8 Button test click start");
53                    this.button_name = "After click";
54                    console.log("V8 Button test click end");
55                })
56            } else if(this.currentView === "text") {
57                Text("V8 Text test")
58                .width(600).height(100).backgroundColor("#b0c4de")
59                .margin(50).fontColor("#ff33aa").fontSize(50).fontWeight("bold")
60            } else if(this.currentView === "image") {
61                Image("pages/pictures/0.jpeg").width(800).height(400).margin(50)
62            } else if(this.currentView === "column") {
63                Column(){
64                    Text("Column Text1").height(100).backgroundColor("#c4b0de")
65                    Text("Column Text2").height(100).backgroundColor("#c4deb0")
66                    Image("pages/pictures/0.jpeg").width(600).height(300)
67                    Text("Column Text3").height(100).backgroundColor("#c4b0de")
68                    Text("Column Text4").height(100).backgroundColor("#c4deb0")
69                }
70                .width(700).height(1000).backgroundColor("#b0c4de").margin(20)
71            } else if(this.currentView === "row") {
72                Row(){
73                    Text("Text1").height(100).backgroundColor("#c4b0de")
74                    Text("Text2").height(100).backgroundColor("#c4deb0")
75                    Image("pages/pictures/0.jpeg").width(300).height(150)
76                    Text("Text3").height(100).backgroundColor("#c4b0de")
77                    Text("Text4").height(100).backgroundColor("#c4deb0")
78                }
79                .width(700).height(200).backgroundColor("#b0c4de").margin(20)
80            }
81        }
82    }
83}
84