• 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 WindowManager, { WindowType } from '../../../../../../../../common/src/main/ets/default/WindowManager';
18import Constants, {StatusBarGroupComponentData} from '../common/constants';
19
20const TAG = 'StatusBarVM';
21
22export class StatusBarVM {
23  mConfig: any;
24  mIsStart: boolean = false;
25  mStatusBarLayoutGroupTemplate: any[] = [];
26  mStatusBarLayout: any;
27  mStatusBarEmptyWidth: any;
28  mUseCount = 0;
29  mStatusBarEnable: boolean = true;
30  mDefaultStatusBarGroupComponentData: StatusBarGroupComponentData= {
31    ...new StatusBarGroupComponentData()
32  };
33  mStatusBarGroupComponentDataMap = {};
34  mWindowWidth = AppStorage.SetAndLink("maxWidth", 0);
35
36
37  setStatusBarEnable(isEnable: boolean) {
38    Log.showInfo(TAG, `setStatusBarEnable, isEnable ${isEnable}`);
39    if (this.mStatusBarEnable == isEnable) {
40      return;
41    }
42    this.mStatusBarEnable = isEnable;
43    this.mStatusBarEnable ? WindowManager.showWindow(WindowType.STATUS_BAR) : WindowManager.hideWindow(WindowType.STATUS_BAR);
44  }
45
46  getStatusBarGroupComponentData(groupId: string): StatusBarGroupComponentData{
47    Log.showInfo(TAG, `getStatusBarGroupComponentData, groupId: ${groupId}`);
48    return this.mStatusBarGroupComponentDataMap[groupId] ?? this.mDefaultStatusBarGroupComponentData;
49  }
50}
51
52let statusBarVM = new StatusBarVM();
53
54export default statusBarVM as StatusBarVM;