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 { CommonConstants } from '@ohos/common'; 17import { LayoutViewModel } from '@ohos/common'; 18import { PageDesktopGridStyleConfig } from '@ohos/pagedesktop'; 19import StyleConstants from './constants/StyleConstants'; 20 21/** 22 * Pad grid style config class 23 */ 24export default class PadPageDesktopGridStyleConfig extends PageDesktopGridStyleConfig { 25 /** 26 * icon size 27 */ 28 mIconSize = StyleConstants.DEFAULT_APP_ICON_SIZE_WIDTH; 29 30 /** 31 * name size 32 */ 33 mNameSize = StyleConstants.DEFAULT_APP_NAME_SIZE; 34 35 /** 36 * margin 37 */ 38 mMargin = StyleConstants.DEFAULT_MARGIN_SIZE; 39 40 /** 41 * name height 42 */ 43 mNameHeight = StyleConstants.DEFAULT_APP_NAME_HEIGHT; 44 45 /** 46 * item padding 47 */ 48 mPaddingTop = StyleConstants.DEFAULT_APP_TOP_RATIO; 49 50 protected constructor() { 51 super(); 52 } 53 54 /** 55 * get PadPageDesktopGridStyleConfig instance 56 */ 57 static getInstance(): PadPageDesktopGridStyleConfig { 58 if (globalThis.PadPageDesktopGridStyleConfig == undefined) { 59 globalThis.PadPageDesktopGridStyleConfig = new PadPageDesktopGridStyleConfig(); 60 } 61 globalThis.PadPageDesktopGridStyleConfig.initConfig(); 62 return globalThis.PadPageDesktopGridStyleConfig; 63 } 64 65 initConfig(): void { 66 const result = LayoutViewModel.getInstance().calculateDesktop(); 67 this.mMargin = result.mMargin; 68 this.mColumnsGap = result.mColumnsGap; 69 this.mRowsGap = result.mRowsGap; 70 this.mColumns = result.mColumns; 71 this.mRows = result.mRows; 72 this.mDesktopMarginTop = result.mDesktopMarginTop; 73 this.mGridWidth = result.mGridWidth; 74 this.mGridHeight = result.mGridHeight; 75 this.mAppItemSize = result.mAppItemSize; 76 this.mNameSize = result.mNameSize; 77 this.mNameHeight = result.mNameHeight; 78 this.mIconNameMargin = result.mIconNameMargin; 79 this.mIconSize = result.mIconSize; 80 this.mNameLines = result.mNameLines; 81 this.mIconMarginHorizontal = result.mIconMarginHorizontal; 82 this.mIconMarginVertical = result.mIconMarginVertical; 83 } 84 85 getConfigLevel(): string { 86 return CommonConstants.LAYOUT_CONFIG_LEVEL_PRODUCT; 87 } 88}