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 * list style config 23 */ 24export class AppListStyleConfig extends ILayoutConfig { 25 /** 26 * list style config 27 */ 28 static APP_LIST_STYLE_CONFIG = 'AppListStyleConfig'; 29 30 /** 31 * width of item 32 */ 33 mListItemWidth: any = StyleConstants.DEFAULT_APP_LIST_ITEM_WIDTH; 34 35 /** 36 * height of item 37 */ 38 mListItemHeight: any = StyleConstants.DEFAULT_APP_LIST_ITEM_HEIGHT; 39 40 /** 41 * gap of item 42 */ 43 mListItemGap = 0; 44 45 /** 46 * direction of list 47 */ 48 mListDirection: string = 'Vertical'; 49 50 /** 51 * isShow name 52 */ 53 mNameDisplaySide = false; 54 55 /** 56 * isShow app name 57 */ 58 mWithAppName = true; 59 60 /** 61 * icon size 62 */ 63 mIconSize: number = StyleConstants.DEFAULT_APP_ICON_SIZE_WIDTH; 64 65 /** 66 * name size 67 */ 68 mNameSize: number = StyleConstants.DEFAULT_APP_NAME_SIZE; 69 70 /** 71 * name color 72 */ 73 mNameFontColor: string = StyleConstants.DEFAULT_FONT_COLOR; 74 75 /** 76 * height of name 77 */ 78 mNameHeight: number = StyleConstants.DEFAULT_APP_NAME_HEIGHT; 79 80 /** 81 * name gap icon 82 */ 83 mNameIconGap = 0; 84 85 /** 86 * padding of item 87 */ 88 mItemPadding = 0; 89 90 /** 91 * background color of item 92 */ 93 mItemBackgroundColor: string = StyleConstants.DEFAULT_BG_COLOR; 94 95 /** 96 * border radius of item 97 */ 98 mItemBorderRadius = 0; 99 100 /** 101 * lines of name 102 */ 103 mNameLines: number = PresetStyleConstants.DEFAULT_APP_NAME_LINES; 104 105 /** 106 * icon name margin 107 */ 108 mIconNameMargin: number = PresetStyleConstants.DEFAULT_ICON_NAME_GAP; 109 110 /** 111 * list item offset 112 */ 113 mItemOffset: {x: number, y: number} = {x: 0, y: 0}; 114 115 constructor() { 116 super(); 117 } 118 119 /** 120 * get instance of list Style config 121 */ 122 static getInstance(): AppListStyleConfig { 123 if (globalThis.AppListStyleConfig == null) { 124 globalThis.AppListStyleConfig = new AppListStyleConfig(); 125 globalThis.AppListStyleConfig.initConfig(); 126 } 127 return globalThis.AppListStyleConfig; 128 } 129 130 initConfig(): void { 131 } 132 133 getConfigLevel(): string { 134 return CommonConstants.LAYOUT_CONFIG_LEVEL_COMMON; 135 } 136 137 getConfigType(): number { 138 return CommonConstants.LAYOUT_CONFIG_TYPE_STYLE; 139 } 140 141 getConfigName(): string { 142 return AppListStyleConfig.APP_LIST_STYLE_CONFIG; 143 } 144 145 getPersistConfigJson(): string { 146 const persistConfig = { 147 }; 148 return JSON.stringify(persistConfig); 149 } 150} 151