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