• 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 { ListModel } from '../model/ListModel';
17import { BatteryUtil } from '../util/BatteryUtil';
18
19@Extend(Text) function fancy() {
20  .height(50)
21  .fontSize(16)
22  .fontWeight(500)
23}
24
25@Component
26export struct BatteryInfo {
27  @State table: ListModel[] = [
28    new ListModel('Battery SOC', BatteryUtil.batterySOC),
29    new ListModel('Charging Status', BatteryUtil.chargingStatus),
30    new ListModel('Health Status', BatteryUtil.healthStatus),
31    new ListModel('Plugged Type', BatteryUtil.pluggedType),
32    new ListModel('Voltage', BatteryUtil.voltage),
33    new ListModel('Technology', BatteryUtil.technology),
34    new ListModel('Battery Temperature', BatteryUtil.batteryTemperature),
35    new ListModel('Battery Present', BatteryUtil.isBatteryPresent),
36    new ListModel('Battery Capacity Level', BatteryUtil.batteryCapacityLevel)
37  ];
38
39  build() {
40    List() {
41      ForEach(this.table, (item: ListModel) => {
42        ListItem() {
43          Row() {
44            Text(item.title)
45              .textAlign(TextAlign.Start)
46              .fontSize(20)
47              .fontWeight(FontWeight.Medium)
48              .fontColor($r("app.color.list_title"))
49            Blank()
50            Text(item.getValue())
51              .textAlign(TextAlign.End)
52              .fontSize(18)
53              .fontWeight(FontWeight.Regular)
54              .fontColor($r("app.color.list_sub_content"))
55          }
56          .padding({
57            left: 16,
58            right: 16
59          })
60          .height(62)
61          .width('100%')
62        }
63      })
64    }
65    .divider({
66      strokeWidth: px2vp(1),
67      color: $r("app.color.divider"),
68      startMargin: 16,
69      endMargin: 16
70    })
71    .margin({
72      top: 16,
73      bottom: 16,
74      left: 4,
75      right: 4
76    })
77    .width('100%')
78    .backgroundColor($r("app.color.white"))
79    .borderRadius(20)
80  }
81}