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_PATTERNS_LIST_LIST_ITEM_MODEL_NG_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_LIST_LIST_ITEM_MODEL_NG_H
18 
19 #include <functional>
20 
21 #include "base/utils/macros.h"
22 #include "core/components_ng/pattern/list/list_item_event_hub.h"
23 #include "core/components_ng/pattern/list/list_item_model.h"
24 
25 namespace OHOS::Ace::NG {
26 class ACE_EXPORT ListItemModelNG : public ListItemModel {
27 public:
28     void Create(std::function<void(int32_t)>&& deepRenderFunc, V2::ListItemStyle listItemStyle) override;
29     void Create() override;
30     void OnDidPop() override;
SetBorderRadius(const Dimension & borderRadius)31     void SetBorderRadius(const Dimension& borderRadius) override {}
SetType(const std::string & type)32     void SetType(const std::string& type) override {}
SetIsLazyCreating(bool isLazy)33     void SetIsLazyCreating(bool isLazy) override {}
34     void SetSticky(V2::StickyMode stickyMode) override;
35     void SetEditMode(uint32_t editMode) override;
36     void SetSelectable(bool selectable) override;
37     void SetSelected(bool selected) override;
38     void SetSelectChangeEvent(std::function<void(bool)>&& changeEvent) override;
39     void SetSwiperAction(std::function<void()>&& startAction, std::function<void()>&& endAction,
40         OnOffsetChangeFunc&& onOffsetChangeFunc, V2::SwipeEdgeEffect edgeEffect) override;
41     void SetSelectCallback(OnSelectFunc&& selectCallback) override;
SetOnDragStart(NG::OnDragStartFunc && onDragStart)42     void SetOnDragStart(NG::OnDragStartFunc&& onDragStart) override {}
43     void SetDeleteArea(std::function<void()>&& builderAction, OnDeleteEvent&& onDelete,
44         OnEnterDeleteAreaEvent&& onEnterDeleteArea, OnExitDeleteAreaEvent&& onExitDeleteArea,
45         OnStateChangedEvent&& onStateChangeEvent, const Dimension& length, bool isStartArea) override;
46 
47     static void SetDeleteArea(FrameNode* frameNode, FrameNode* footerNode, OnDeleteEvent&& onDelete,
48         OnEnterDeleteAreaEvent&& onEnterDeleteArea, OnExitDeleteAreaEvent&& onExitDeleteArea,
49         OnStateChangedEvent&& onStateChangeEvent, const Dimension& length, bool isStartArea);
50     static void SetSwiperAction(FrameNode* frameNode, std::function<void()>&& startAction,
51         std::function<void()>&& endAction, OnOffsetChangeFunc&& onOffsetChangeFunc,
52         V2::SwipeEdgeEffect edgeEffect);
53     static void SetSelected(FrameNode* frameNode, bool selected);
54     static void SetSelectable(FrameNode* frameNode, bool selectable);
55     static RefPtr<FrameNode> CreateFrameNode(int32_t nodeId);
56     static void SetSelectCallback(FrameNode* frameNode, OnSelectFunc&& selectCallback);
57 private:
58     void InstallSwiperCallBack(RefPtr<ListItemEventHub> eventHub,
59                                OnDeleteEvent&& onDelete,
60                                OnEnterDeleteAreaEvent&& onEnterDeleteArea,
61                                OnExitDeleteAreaEvent&& onExitDeleteArea,
62                                OnStateChangedEvent&& onStateChangeEvent,
63                                bool isStartArea);
64 };
65 } // namespace OHOS::Ace::NG
66 
67 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_LIST_LIST_ITEM_MODEL_NG_H
68