1 /*
2  * Copyright (c) 2022-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_PANEL_SLIDING_PANEL_MODEL_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_PANEL_SLIDING_PANEL_MODEL_H
18 
19 #include <mutex>
20 
21 #include "base/geometry/axis.h"
22 #include "base/geometry/dimension.h"
23 #include "base/memory/referenced.h"
24 #include "core/components/common/layout/constants.h"
25 #include "core/components_ng/pattern/linear_layout/linear_layout_property.h"
26 #include "core/components_ng/pattern/panel/sliding_panel_event_hub.h"
27 #include "core/components_ng/pattern/panel/sliding_panel_node.h"
28 
29 namespace OHOS::Ace {
30 
31 class ACE_FORCE_EXPORT SlidingPanelModel {
32 public:
33     static SlidingPanelModel* GetInstance();
34     virtual ~SlidingPanelModel() = default;
35 
36     virtual void Create(bool isShow) = 0;
37     virtual void SetPanelType(PanelType type) = 0;
38     virtual void SetPanelMode(PanelMode mode) = 0;
39     virtual void SetHasDragBar(bool hasDragBar) = 0;
SetCustomHeight(const CalcDimension & customHeight)40     virtual void SetCustomHeight(const CalcDimension& customHeight) {};
41     virtual void SetMiniHeight(const Dimension& miniHeight) = 0;
42     virtual void SetHalfHeight(const Dimension& halfHeight) = 0;
43     virtual void SetFullHeight(const Dimension& fullHeight) = 0;
44     virtual void SetIsShow(bool isShow) = 0;
SetShowCloseIcon(bool showCloseIcon)45     virtual void SetShowCloseIcon(bool showCloseIcon) {};
46     virtual void SetBackgroundMask(const Color& backgroundMask) = 0;
47     virtual void SetBackgroundColor(const Color& backgroundColor) = 0;
48     virtual void SetOnSizeChange(std::function<void(const BaseEventInfo*)>&& changeEvent) = 0;
49     virtual void SetOnHeightChange(std::function<void(const float)>&& onHeightChange) = 0;
50     virtual void Pop();
51     virtual void SetBorderColor(const Color& borderColor);
52     virtual void SetBorderWidth(const Dimension& borderWidth);
53     virtual void SetBorderStyle(const BorderStyle& borderStyle);
54     virtual void SetBorder(const BorderStyle& borderStyle, const Dimension& borderWidth);
55     virtual void SetModeChangeEvent(std::function<void(const BaseEventInfo*)>&& modeChangeEvent) = 0;
56 
57 private:
58     static std::unique_ptr<SlidingPanelModel> instance_;
59     static std::mutex mutex_;
60 };
61 } // namespace OHOS::Ace
62 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_PANEL_SLIDING_PANEL_MODEL_H
63