• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021-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
16import mBatteryModel from '../batteryModel';
17import BatteryPic from './batteryPic';
18import BatterySoc from './batterySoc';
19import Constants from '../common/constants';
20import Log from '../../../../../../../common/src/main/ets/default/Log';
21import StyleConfigurationCommon, { CommonStyle
22} from '../../../../../../../common/src/main/ets/default/StyleConfiguration'
23import StyleConfiguration, { BatteryComponentStyle } from '../common/StyleConfiguration'
24
25const TAG = 'BatteryComponent-batteryIcon';
26
27@Component
28export default struct BatteryIcon {
29  @StorageLink('batterySoc') batterySoc: number = 100;
30  @StorageLink('StatusCoefficient') StatusCoefficient: number = 1.0;
31  @State style: BatteryComponentStyle = StyleConfiguration.getBatteryComponentStyle();
32  @State styleCommon: CommonStyle = StyleConfigurationCommon.getCommonStyle();
33
34  aboutToAppear() {
35    mBatteryModel.initBatteryModel();
36    Log.showInfo(TAG, 'aboutToAppear');
37  }
38
39  aboutToDisappear() {
40    Log.showInfo(TAG, 'aboutToDisappear');
41  }
42
43  build() {
44    Row() {
45      Row().width(this.styleCommon.statusBarMarginLeftRight).height('100%')
46      BatterySoc()
47      Row().width(this.style.componentGap).height('100%')
48      BatteryPic()
49      Row().width(this.styleCommon.statusBarMarginLeftRight).height('100%')
50    }.height('100%').opacity($r("app.float.icon_component_opacity"))
51  }
52}