16e80583aSopenharmony_ci/**
26e80583aSopenharmony_ci * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
36e80583aSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
46e80583aSopenharmony_ci * you may not use this file except in compliance with the License.
56e80583aSopenharmony_ci * You may obtain a copy of the License at
66e80583aSopenharmony_ci *
76e80583aSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
86e80583aSopenharmony_ci *
96e80583aSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
106e80583aSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
116e80583aSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
126e80583aSopenharmony_ci * See the License for the specific language governing permissions and
136e80583aSopenharmony_ci * limitations under the License.
146e80583aSopenharmony_ci */
156e80583aSopenharmony_ci
166e80583aSopenharmony_ciimport { ILayoutConfig } from './ILayoutConfig';
176e80583aSopenharmony_ciimport { CommonConstants } from '../constants/CommonConstants';
186e80583aSopenharmony_ciimport folderLayoutInfo from '../configs/FolderLayoutInfo';
196e80583aSopenharmony_ci
206e80583aSopenharmony_ci/**
216e80583aSopenharmony_ci * Folder layout configuration
226e80583aSopenharmony_ci */
236e80583aSopenharmony_ciexport class FolderLayoutConfig extends ILayoutConfig {
246e80583aSopenharmony_ci
256e80583aSopenharmony_ci  /**
266e80583aSopenharmony_ci   *  The index of Folder layout configuration
276e80583aSopenharmony_ci   */
286e80583aSopenharmony_ci  static FOLDER_GRID_LAYOUT_INFO = 'FolderGridLayoutInfo';
296e80583aSopenharmony_ci  protected mFolderLayoutInfo: any = folderLayoutInfo;
306e80583aSopenharmony_ci
316e80583aSopenharmony_ci  constructor() {
326e80583aSopenharmony_ci    super();
336e80583aSopenharmony_ci  }
346e80583aSopenharmony_ci
356e80583aSopenharmony_ci  /**
366e80583aSopenharmony_ci   * Get folder layout configuration instance
376e80583aSopenharmony_ci   */
386e80583aSopenharmony_ci  static getInstance(): FolderLayoutConfig {
396e80583aSopenharmony_ci    if (globalThis.FolderLayoutConfigInstance == null) {
406e80583aSopenharmony_ci      globalThis.FolderLayoutConfigInstance = new FolderLayoutConfig();
416e80583aSopenharmony_ci      globalThis.FolderLayoutConfigInstance.initConfig();
426e80583aSopenharmony_ci    }
436e80583aSopenharmony_ci    return globalThis.FolderLayoutConfigInstance;
446e80583aSopenharmony_ci  }
456e80583aSopenharmony_ci
466e80583aSopenharmony_ci  initConfig(): void {
476e80583aSopenharmony_ci    const config = this.loadPersistConfig();
486e80583aSopenharmony_ci    this.mFolderLayoutInfo = config;
496e80583aSopenharmony_ci  }
506e80583aSopenharmony_ci
516e80583aSopenharmony_ci  getConfigLevel(): string {
526e80583aSopenharmony_ci    return CommonConstants.LAYOUT_CONFIG_LEVEL_COMMON;
536e80583aSopenharmony_ci  }
546e80583aSopenharmony_ci
556e80583aSopenharmony_ci  getConfigType(): number {
566e80583aSopenharmony_ci    return CommonConstants.LAYOUT_CONFIG_TYPE_FUNCTION;
576e80583aSopenharmony_ci  }
586e80583aSopenharmony_ci
596e80583aSopenharmony_ci  getConfigName(): string {
606e80583aSopenharmony_ci    return FolderLayoutConfig.FOLDER_GRID_LAYOUT_INFO;
616e80583aSopenharmony_ci  }
626e80583aSopenharmony_ci
636e80583aSopenharmony_ci  getPersistConfigJson(): string {
646e80583aSopenharmony_ci    return JSON.stringify(this.mFolderLayoutInfo);
656e80583aSopenharmony_ci  }
666e80583aSopenharmony_ci
676e80583aSopenharmony_ci  /**
686e80583aSopenharmony_ci   * Update folder layout data
696e80583aSopenharmony_ci   *
706e80583aSopenharmony_ci   * @params {gridLayoutInfo} folder layout data
716e80583aSopenharmony_ci   */
726e80583aSopenharmony_ci  updateFolderLayoutInfo(folderLayoutInfo: object): void {
736e80583aSopenharmony_ci    this.mFolderLayoutInfo = folderLayoutInfo;
746e80583aSopenharmony_ci    super.persistConfig();
756e80583aSopenharmony_ci  }
766e80583aSopenharmony_ci
776e80583aSopenharmony_ci  /**
786e80583aSopenharmony_ci   * Get folder layout data
796e80583aSopenharmony_ci   *
806e80583aSopenharmony_ci   * @return folder layout data
816e80583aSopenharmony_ci   */
826e80583aSopenharmony_ci  getFolderLayoutInfo(): any {
836e80583aSopenharmony_ci    return this.mFolderLayoutInfo;
846e80583aSopenharmony_ci  }
856e80583aSopenharmony_ci}
86