1 /*
2  * Copyright (c) 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 
16 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_GRID_GRID_ITEM_MODEL_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_GRID_GRID_ITEM_MODEL_H
18 
19 #include <functional>
20 #include <memory>
21 #include <mutex>
22 #include "core/components_ng/pattern/grid/grid_item_theme.h"
23 
24 namespace OHOS::Ace {
25 class ACE_FORCE_EXPORT GridItemModel {
26 public:
27     static GridItemModel* GetInstance();
28     virtual ~GridItemModel() = default;
29 
30     virtual void Create(NG::GridItemStyle gridItemStyle) = 0;
31     virtual void Create(
32         std::function<void(int32_t)>&& deepRenderFunc, bool isLazy, NG::GridItemStyle gridItemStyle) = 0;
33     virtual void SetRowStart(int32_t value) = 0;
34     virtual void SetRowEnd(int32_t value) = 0;
35     virtual void SetColumnStart(int32_t value) = 0;
36     virtual void SetColumnEnd(int32_t value) = 0;
37     virtual void SetForceRebuild(bool value) = 0;
38     virtual void SetSelectable(bool value) = 0;
39     virtual void SetSelected(bool selected) = 0;
40     virtual void SetSelectChangeEvent(std::function<void(bool)>&& changeEvent) = 0;
41     virtual void SetOnSelect(std::function<void(bool)>&& onSelect) = 0;
42 
43 private:
44     static std::unique_ptr<GridItemModel> instance_;
45     static std::mutex mutex_;
46 };
47 
48 } // namespace OHOS::Ace
49 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_GRID_GRID_ITEM_MODEL_H
50