• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 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
16import { ColumnOperation } from '../components/ColumnOperation';
17import { changeValue, deleteNode, getFirstNode, insertNode } from '../util/UrlUtil';
18
19const URL_NET: string = 'https://gitee.com/openharmony/';
20
21@Preview
22@Component
23export struct Url {
24  @State output: string = URL_NET;
25
26  build() {
27    Scroll() {
28      Column() {
29        Text(this.output)
30          .id('output')
31          .width('95%')
32          .height('30%')
33          .fontSize(15)
34          .padding(10)
35          .margin({ left: 10, right: 10, top: 10 })
36          .border({ width: 2, radius: 5, color: Color.Gray })
37        Text(URL_NET)
38          .fontSize(15)
39          .margin({ top: 15 })
40          .fontWeight(FontWeight.Bold)
41        ColumnOperation({ operationRes: $r('app.strarray.url_operations'), doOperation: this.doOperation })
42      }
43      .width('100%')
44      .padding(16)
45    }
46    .scrollBar(BarState.Off)
47    .align(Alignment.Start)
48  }
49
50  doOperation = (index: number) => {
51    switch (index) {
52      case 0:
53        this.output = insertNode();
54        break;
55      case 1:
56        this.output = deleteNode();
57        break;
58      case 2:
59        this.output = getFirstNode();
60        break;
61      case 3:
62        this.output = changeValue();
63        break;
64      default:
65        break;
66    }
67  }
68}