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