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