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 { ILayoutConfig } from './ILayoutConfig'; 17import { CommonConstants } from '../constants/CommonConstants'; 18import { StyleConstants } from '../constants/StyleConstants'; 19import { PresetStyleConstants } from '../constants/PresetStyleConstants'; 20 21/** 22 * Style config for app grid. 23 */ 24export class AppGridStyleConfig extends ILayoutConfig { 25 /** 26 * Style config symbol for app grid 27 */ 28 static APP_GRID_STYLE_CONFIG = 'AppGridStyleConfig'; 29 30 /** 31 * 列数 32 */ 33 mColumns = StyleConstants.DEFAULT_APP_GRID_COLUMN; 34 35 /** 36 * 行数 37 */ 38 mRows = StyleConstants.DEFAULT_APP_GRID_ROW; 39 40 /** 41 * 类间隙 42 */ 43 mColumnsGap = StyleConstants.DEFAULT_APP_GRID_COLUMN_GAP; 44 45 /** 46 * 行间隙 47 */ 48 mRowsGap = StyleConstants.DEFAULT_APP_GRID_ROW_GAP; 49 50 /** 51 * grid margin 52 */ 53 mMargin = PresetStyleConstants.DEFAULT_LAYOUT_MARGIN; 54 55 /** 56 * grid minimum gutter 57 */ 58 mGridGutter = PresetStyleConstants.DEFAULT_APP_LAYOUT_MIN_GUTTER; 59 60 /** 61 * grid width 62 */ 63 mGridWidth: number; 64 65 /** 66 * grid height 67 */ 68 mGridHeight: number; 69 70 /** 71 * app width 72 */ 73 mAppItemSize: number; 74 75 /** 76 * icon size 77 */ 78 mIconSize = StyleConstants.DEFAULT_APP_ICON_SIZE_WIDTH; 79 80 /** 81 * app name font size 82 */ 83 mNameSize = StyleConstants.DEFAULT_APP_NAME_SIZE; 84 85 /** 86 * app name font color 87 */ 88 mNameFontColor = StyleConstants.DEFAULT_FONT_COLOR; 89 90 /** 91 * app name font height 92 */ 93 mNameHeight = StyleConstants.DEFAULT_APP_NAME_HEIGHT; 94 95 /** 96 * app name lines 97 */ 98 mNameLines = PresetStyleConstants.DEFAULT_APP_NAME_LINES; 99 100 /** 101 * left margin of app center 102 */ 103 mAppCenterMarginLeft: number = PresetStyleConstants.DEFAULT_APP_CENTER_MARGIN; 104 105 /** 106 * app icon margin top 107 */ 108 mIconMarginVertical: number = PresetStyleConstants.DEFAULT_ICON_PADDING_TOP; 109 110 /** 111 * app icon margin horizontal 112 */ 113 mIconMarginHorizontal: number = PresetStyleConstants.DEFAULT_ICON_PADDING_LEFT; 114 115 /** 116 * icon name margin 117 */ 118 mIconNameMargin: number = PresetStyleConstants.DEFAULT_ICON_NAME_GAP; 119 120 constructor() { 121 super(); 122 } 123 124 /** 125 * Get single instance. 126 */ 127 static getInstance(): AppGridStyleConfig { 128 if (globalThis.AppGridStyleConfig == null) { 129 globalThis.AppGridStyleConfig = new AppGridStyleConfig(); 130 globalThis.AppGridStyleConfig.initConfig(); 131 } 132 return globalThis.AppGridStyleConfig; 133 } 134 135 initConfig(): void { 136 } 137 138 getConfigLevel(): string { 139 return CommonConstants.LAYOUT_CONFIG_LEVEL_COMMON; 140 } 141 142 getConfigType(): number { 143 return CommonConstants.LAYOUT_CONFIG_TYPE_STYLE; 144 } 145 146 getConfigName(): string { 147 return AppGridStyleConfig.APP_GRID_STYLE_CONFIG; 148 } 149 150 getPersistConfigJson(): string { 151 const persistConfig = { 152 }; 153 return JSON.stringify(persistConfig); 154 } 155} 156