• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 systemCapability from '@ohos.systemCapability';
17import { ColumnOperation } from '../components/ColumnOperation';
18
19@Preview
20@Component
21export struct SystemCapability {
22  @State result: string = '';
23
24  build() {
25    Scroll() {
26      Column() {
27        Row() {
28          Text(this.result)
29            .fontWeight(FontWeight.Medium)
30            .fontSize(20)
31        }
32        .alignItems(VerticalAlign.Top)
33        .width('100%')
34        .backgroundColor($r("app.color.white"))
35        .height(160)
36        .padding(16)
37        .borderRadius(20)
38        .margin({ top: 16 })
39        ColumnOperation({ operationRes: $r('app.strarray.system_capability'), doOperation: this.doOperation })
40      }
41      .width('100%')
42      .padding(4)
43    }
44    .scrollBar(BarState.Off)
45  }
46
47  doOperation = async (index: number) => {
48    switch (index) {
49      case 0:
50        try {
51          this.result = await systemCapability.querySystemCapabilities();
52        } catch (err) {
53          this.result = `query fail:${JSON.stringify(err)}`;
54        }
55        break
56      default:
57        break
58    }
59  }
60}