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 {Log} from '@ohos/common' 17import Constants from '../../common/constants' 18import BatteryIcon from '../../../../../../../../../features/batterycomponent/src/main/ets/default/pages/batteryIcon' 19import ClockIcon from '../../../../../../../../../features/clockcomponent/src/main/ets/default/pages/clockIcon' 20import WifiIcon from '../../../../../../../../../features/wificomponent/src/main/ets/default/pages/wifiIcon' 21import SignalIcon from '../../../../../../../../../features/signalcomponent/src/main/ets/default/pages/signalIcon' 22import deviceInfo from '@ohos.deviceInfo'; 23 24const deviceTypeInfo = deviceInfo.deviceType 25const TAG = 'ScreenLock-StatusBar' 26 27@Component 28export default struct statusBar { 29 private isShow: boolean 30 31 aboutToAppear() { 32 Log.showInfo(TAG, `aboutToAppear`) 33 if (deviceTypeInfo === "phone" || deviceTypeInfo === "default") { 34 this.isShow = false 35 } else { 36 this.isShow = true 37 } 38 } 39 40 build() { 41 Row() { 42 Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start }) { 43 SignalIcon() 44 WifiIcon() 45 }.width(Constants.HALF_CONTAINER_WIDTH) 46 .height(Constants.FULL_CONTAINER_HEIGHT) 47 48 Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.End }) { 49 BatteryIcon() 50 if (this.isShow) { 51 ClockIcon() 52 } 53 }.width(Constants.HALF_CONTAINER_WIDTH) 54 .height(Constants.FULL_CONTAINER_HEIGHT) 55 } 56 .width(Constants.FULL_CONTAINER_WIDTH) 57 .height($r("app.float.status_bar_height")) 58 .padding({ 59 left: $r("app.float.status_bar_padding_left_right"), 60 right: $r("app.float.status_bar_padding_left_right") 61 }) 62 .margin({ top: $r("app.float.status_bar_margin_top") }) 63 .opacity($r("app.float.status_bar_opacity")) 64 } 65}