1 /*
2  * Copyright (c) 2023 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_VIEW_VIEW_CONTEXT_MODEL_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_VIEW_VIEW_CONTEXT_MODEL_H
18 
19 #include <mutex>
20 
21 #include "core/components/common/properties/animation_option.h"
22 #include "core/components_ng/pattern/overlay/sheet_style.h"
23 
24 namespace OHOS::Ace {
25 class ACE_FORCE_EXPORT ViewContextModel {
26 public:
27     static ViewContextModel* GetInstance();
28     virtual ~ViewContextModel() = default;
29 
30     virtual void closeAnimation(const AnimationOption& option, bool needFlush) = 0;
31     virtual void openAnimation(const AnimationOption& option) = 0;
32     virtual int32_t OpenBindSheet(const RefPtr<NG::FrameNode>& bindContentNode,
33         std::function<void()>&& titleBuildFunc, NG::SheetStyle& sheetStyle,
34         std::function<void()>&& onAppear, std::function<void()>&& onDisappear, std::function<void()>&& shouldDismiss,
35         std::function<void(const int32_t info)>&& onWillDismiss, std::function<void()>&& onWillAppear,
36         std::function<void()>&& onWillDisappear, std::function<void(const float)>&& onHeightDidChange,
37         std::function<void(const float)>&& onDetentsDidChange, std::function<void(const float)>&& onWidthDidChange,
38         std::function<void(const float)>&& onTypeDidChange, std::function<void()>&& sheetSpringBack,
39         int32_t currentInstanceId, int32_t targetId) = 0;
40     virtual int32_t UpdateBindSheet(
41         const RefPtr<NG::FrameNode>& bindContentNode, NG::SheetStyle& sheetStyle, bool isPartialUpdate,
42         int32_t currentInstanceId) = 0;
43     virtual int32_t CloseBindSheet(const RefPtr<NG::FrameNode>& bindContentNode, int32_t currentInstanceId) = 0;
44 
45 private:
46     static std::unique_ptr<ViewContextModel> instance_;
47     static std::mutex mutex_;
48 };
49 } // namespace OHOS::Ace
50 
51 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_VIEW_VIEW_CONTEXT_MODEL_H
52