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_MODEL_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_LIST_LIST_ITEM_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/event/gesture_event_hub.h" 27 #include "core/components_v2/list/list_properties.h" 28 29 namespace OHOS::Ace { 30 31 class ACE_FORCE_EXPORT ListItemModel { 32 public: 33 static ListItemModel* GetInstance(); 34 virtual ~ListItemModel() = default; 35 36 virtual void Create() = 0; 37 virtual void Create(std::function<void(int32_t)>&& deepRenderFunc, V2::ListItemStyle listItemStyle) = 0; 38 virtual void OnDidPop(); 39 virtual void SetBorderRadius(const Dimension& borderRadius) = 0; 40 virtual void SetType(const std::string& type) = 0; 41 virtual void SetIsLazyCreating(bool isLazy) = 0; 42 virtual void SetSticky(V2::StickyMode stickyMode) = 0; 43 virtual void SetEditMode(uint32_t editMode) = 0; 44 virtual void SetSelectable(bool selectable) = 0; 45 virtual void SetSelected(bool selected) = 0; 46 virtual void SetSelectChangeEvent(std::function<void(bool)>&& changeEvent) = 0; 47 // use SetDeleteArea to update builder function 48 virtual void SetSwiperAction(std::function<void()>&& startAction, std::function<void()>&& endAction, 49 OnOffsetChangeFunc&& onOffsetChangeFunc, V2::SwipeEdgeEffect edgeEffect) = 0; 50 virtual void SetSelectCallback(OnSelectFunc&& selectCallback) = 0; 51 virtual void SetOnDragStart(NG::OnDragStartFunc&& onDragStart) = 0; 52 virtual void SetDeleteArea(std::function<void()>&& builderAction, OnDeleteEvent&& onDelete, 53 OnEnterDeleteAreaEvent&& onEnterDeleteArea, OnExitDeleteAreaEvent&& onExitDeleteArea, 54 OnStateChangedEvent&& onStateChange, const Dimension& length, bool isStartArea) = 0; 55 56 private: 57 static std::unique_ptr<ListItemModel> instance_; 58 static std::mutex mutex_; 59 }; 60 61 } // namespace OHOS::Ace 62 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_LIST_LIST_ITEM_MODEL_H 63