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 '@ohos/common';
17import { AppListStyleConfig } from '@ohos/common';
18import { CommonConstants } from '@ohos/common';
19import { LayoutViewModel } from '@ohos/common';
20import SmartDockConstants from '../common/constants/SmartDockConstants';
21
22const TAG = 'SmartDockStyleConfig';
23
24/**
25 * smartdock layout style config
26 */
27export class SmartDockStyleConfig extends AppListStyleConfig {
28  /**
29   * dock list height, high
30   */
31  mDockHeight = 78;
32
33  /**
34   * dock list background color
35   */
36  mBackgroundColor = '#85FAFAFA';
37
38  /**
39   * dock list border radius
40   */
41  mDockRadius = 22;
42
43  /**
44   * dock list background blur
45   */
46  mBackdropBlur = 0;
47
48  /**
49   * dock list padding
50   */
51  mDockPadding = 9;
52
53  /**
54   * dock list margin
55   */
56  mDockMargin = 10;
57
58  /**
59   * dock list item width
60   */
61  mListItemWidth = 60;
62
63  /**
64   * dock list item height
65   */
66  mListItemHeight = 60;
67
68  /**
69   * dock list item gap
70   */
71  mListItemGap = 2;
72
73  /**
74   * dock list direction
75   */
76  mListDirection: string = 'Horizontal';
77
78  /**
79   * dock list name display side
80   */
81  mNameDisplaySide = true;
82
83  /**
84   * dock is show with app name
85   */
86  mWithAppName = false;
87
88  /**
89   * dock list item icon size
90   */
91  mIconSize = 54;
92
93  /**
94   * dock list item padding
95   */
96  mItemPadding = 3;
97
98  /**
99   * dock list item background color
100   */
101  mItemBackgroundColor = '';
102
103  /**
104   * dock list item border radius
105   */
106  mItemBorderRadius = 0;
107
108  /**
109   *  gap between resident dock and recent dock
110   */
111  mDockGap = 12;
112
113  /**
114   * resident dock max item number
115   */
116  mMaxDockNum = 16;
117
118  /**
119   * recent dock max item number
120   */
121  mMaxRecentNum = 3;
122
123  /**
124   * dock bottom margin
125   */
126  mMarginBottom = 24;
127
128  /**
129  * list item offset
130  */
131  mItemOffset: {x: number, y: number} = {x: 12, y: 12};
132
133  protected constructor() {
134    super();
135  }
136
137  /**
138   * get SmartDockStyleConfig getInstance
139   */
140  static getInstance(): SmartDockStyleConfig {
141    if (globalThis.SmartDockStyleConfig == null) {
142      globalThis.SmartDockStyleConfig = new SmartDockStyleConfig();
143      Log.showInfo(TAG, 'getInstance!');
144    }
145    globalThis.SmartDockStyleConfig.initConfig();
146    return globalThis.SmartDockStyleConfig;
147  }
148
149  initConfig(): void {
150    const result = LayoutViewModel.getInstance().calculateDock();
151    this.mDockGap = result.mDockGap;
152    this.mIconSize = result.mIconSize;
153    this.mListItemWidth = result.mListItemWidth;
154    this.mListItemHeight = result.mListItemHeight;
155    this.mListItemGap = result.mListItemGap;
156    this.mDockPadding = result.mDockPadding;
157    this.mMaxRecentNum = result.mMaxRecentNum;
158    this.mMaxDockNum = result.mMaxDockNum;
159    this.mDockHeight = result.mDockHeight;
160    this.mMarginBottom = result.mMarginBottom;
161    this.mItemOffset = {x: this.mDockPadding, y: this.mDockPadding};
162  }
163
164  getConfigLevel(): string {
165    return CommonConstants.LAYOUT_CONFIG_LEVEL_FEATURE;
166  }
167
168  getFeatureName(): string {
169    return SmartDockConstants.FEATURE_NAME;
170  }
171}
172