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_LIST_LIST_ITEM_GROUP_MODEL_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_LIST_LIST_ITEM_GROUP_MODEL_H 18 19 #include <functional> 20 #include <memory> 21 #include <mutex> 22 23 #include "base/geometry/axis.h" 24 #include "base/geometry/dimension.h" 25 #include "core/components/common/layout/constants.h" 26 #include "core/components_ng/pattern/list/list_children_main_size.h" 27 #include "core/components_v2/list/list_properties.h" 28 29 namespace OHOS::Ace { 30 31 class ACE_FORCE_EXPORT ListItemGroupModel { 32 public: 33 static ListItemGroupModel* GetInstance(); 34 virtual ~ListItemGroupModel() = default; 35 36 virtual void Create(V2::ListItemGroupStyle listItemGroupStyle) = 0; 37 virtual void SetSpace(const Dimension& space) = 0; 38 virtual void SetDivider(const V2::ItemDivider& divider) = 0; 39 virtual void SetHeader(std::function<void()>&& header) = 0; 40 virtual void SetFooter(std::function<void()>&& footer) = 0; GetOrCreateListChildrenMainSize()41 virtual RefPtr<NG::ListChildrenMainSize> GetOrCreateListChildrenMainSize() 42 { 43 return nullptr; 44 } SetHeaderComponent(const RefPtr<NG::UINode> & headerComponent)45 virtual void SetHeaderComponent(const RefPtr<NG::UINode>& headerComponent) 46 { 47 return; 48 } SetFooterComponent(const RefPtr<NG::UINode> & footerComponent)49 virtual void SetFooterComponent(const RefPtr<NG::UINode>& footerComponent) 50 { 51 return; 52 } RemoveHeader()53 virtual void RemoveHeader() 54 { 55 return; 56 } RemoveFooter()57 virtual void RemoveFooter() 58 { 59 return; 60 } 61 62 private: 63 static std::unique_ptr<ListItemGroupModel> instance_; 64 static std::mutex mutex_; 65 }; 66 67 } // namespace OHOS::Ace 68 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_LIST_LIST_ITEM_MODEL_H 69