• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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_MANAGER_DRAG_DROP_DRAG_DROP_SPRING_LOADING_STATE_BASE_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MANAGER_DRAG_DROP_DRAG_DROP_SPRING_LOADING_STATE_BASE_H
18 
19 #include <string_view>
20 
21 #include "core/components_ng/base/frame_node.h"
22 #include "core/gestures/drag_event.h"
23 
24 namespace OHOS::Ace::NG {
25 enum class DragDropSpringLoadingState : uint8_t {
26     IDLE = 0,
27     BEGIN = 1,
28     UPDATE = 2,
29     END = 3,
30     CANCEL = 4,
31 };
32 
33 const std::string DRAG_DROP_SPRING_LOADING_TASK_NAME("ArkUIDragDropSpringLoadingTimer");
34 
35 class DragDropSpringLoadingStateMachine;
36 class DragDropSpringLoadingStateBase : public AceType {
37     DECLARE_ACE_TYPE(DragDropSpringLoadingStateBase, AceType);
38 
39 public:
DragDropSpringLoadingStateBase(const WeakPtr<DragDropSpringLoadingStateMachine> & machine)40     DragDropSpringLoadingStateBase(const WeakPtr<DragDropSpringLoadingStateMachine>& machine)
41         : stateMachine_(machine) {};
42     virtual ~DragDropSpringLoadingStateBase() = default;
OnEnter(std::string_view extraInfo)43     virtual void OnEnter(std::string_view extraInfo) {};
44 
45 protected:
GetStateMachine()46     RefPtr<DragDropSpringLoadingStateMachine> GetStateMachine()
47     {
48         return stateMachine_.Upgrade();
49     }
50 
51     DragSpringLoadingState ConvertDragSpringLoadingState(DragDropSpringLoadingState state) const;
52 
53     void UpdateDragSpringLoadingContext(
54         RefPtr<OHOS::Ace::DragSpringLoadingContext>& context, std::string_view extraInfo);
55 
56 private:
57     WeakPtr<DragDropSpringLoadingStateMachine> stateMachine_;
58 };
59 
60 } // namespace OHOS::Ace::NG
61 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MANAGER_DRAG_DROP_DRAG_DROP_SPRING_LOADING_STATE_BASE_H