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 from '../../../../../../../common/src/main/ets/default/StyleConfiguration' 22import StyleConfiguration from '../common/StyleConfiguration' 23import {StatusBarGroupComponentData 24} from '../../../../../../screenlock/src/main/ets/com/ohos/common/constants' 25import StatusBarVM from '../../../../../../screenlock/src/main/ets/com/ohos/vm/StatusBarVM' 26 27const TAG = 'BatteryComponent-batteryIcon' 28 29@Component 30export default struct BatteryIcon { 31 @StorageLink('batterySoc') batterySoc: number = 100 32 @StorageLink('StatusCoefficient') StatusCoefficient: number = 1.0 33 private mGroupId: string = '' 34 @State mStatusBarGroupComponentData: StatusBarGroupComponentData = new StatusBarGroupComponentData() 35 @State style: any = StyleConfiguration.getBatteryComponentStyle() 36 @State styleCommon: any = StyleConfigurationCommon.getCommonStyle() 37 38 aboutToAppear() { 39 this.mStatusBarGroupComponentData = StatusBarVM.getStatusBarGroupComponentData(this.mGroupId) 40 mBatteryModel.initBatteryModel(); 41 Log.showInfo(TAG, 'aboutToAppear'); 42 } 43 44 aboutToDisappear() { 45 Log.showInfo(TAG, 'aboutToDisappear'); 46 } 47 48 build() { 49 Row() { 50 Row().width(this.styleCommon.statusBarMarginLeftRight).height('100%') 51 BatterySoc({ mContentColor: this.mStatusBarGroupComponentData.contentColor }) 52 Row().width(this.style.componentGap).height('100%') 53 BatteryPic({ mContentColor: this.mStatusBarGroupComponentData.contentColor }) 54 Row().width(this.styleCommon.statusBarMarginLeftRight).height('100%') 55 } 56 .height('100%') 57 } 58}