• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_REFRESH_MODEL_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_REFRESH_MODEL_H
18 
19 #include <mutex>
20 #include <string>
21 
22 #include "frameworks/base/geometry/dimension.h"
23 #include "frameworks/base/utils/macros.h"
24 #include "frameworks/core/components/common/properties/color.h"
25 #include "frameworks/core/components_ng/pattern/refresh/refresh_pattern.h"
26 
27 #include "core/common/resource/resource_object.h"
28 
29 namespace OHOS::Ace {
30 
31 class ACE_FORCE_EXPORT RefreshModel {
32 public:
33     static RefreshModel* GetInstance();
34     virtual ~RefreshModel() = default;
35 
36     virtual void Create() = 0;
37     virtual void Pop() = 0;
38     virtual void SetRefreshing(bool isRefreshing) = 0;
39     virtual void SetRefreshDistance(const Dimension& refreshDistance) = 0;
40     virtual void SetUseOffset(bool isUseOffset) = 0;
41     virtual void SetIndicatorOffset(const Dimension& indicatorOffset) = 0;
42     virtual void SetFriction(int32_t friction) = 0;
43     virtual void IsRefresh(bool isRefresh) = 0;
44 
45     virtual void SetLoadingDistance(const Dimension& loadingDistance) = 0;
46     virtual void SetProgressDistance(const Dimension& progressDistance) = 0;
47     virtual void SetProgressDiameter(const Dimension& progressDiameter) = 0;
48     virtual void SetMaxDistance(const Dimension& maxDistance) = 0;
49     virtual void SetIsShowLastTime(bool IsShowLastTime) = 0;
50     virtual void SetShowTimeDistance(const Dimension& showTimeDistance) = 0;
51 
52     virtual void SetTextStyle(const TextStyle& textStyle) = 0;
53     virtual void SetProgressColor(const Color& progressColor) = 0;
54     virtual void SetProgressBackgroundColor(const Color& backgroundColor) = 0;
55     virtual void SetOnStateChange(std::function<void(const int32_t)>&& stateChange) = 0;
56     virtual void SetOnRefreshing(std::function<void()>&& refreshing) = 0;
57     virtual void SetOnOffsetChange(std::function<void(const float)>&& dragOffset) = 0;
58     virtual void ResetOnOffsetChange() = 0;
SetMaxPullDownDistance(const std::optional<float> & maxDistance)59     virtual void SetMaxPullDownDistance(const std::optional<float>& maxDistance) {}
SetPullDownRatio(const std::optional<float> & pullDownRatio)60     virtual void SetPullDownRatio(const std::optional<float>& pullDownRatio) {}
61     virtual void SetChangeEvent(std::function<void(const std::string)>&& changeEvent) = 0;
62     virtual void SetCustomBuilder(const RefPtr<NG::UINode>& customBuilder) = 0;
63     virtual void SetLoadingText(const std::string& loadingText) = 0;
ResetLoadingText()64     virtual void ResetLoadingText() {}
65     virtual void SetRefreshOffset(const Dimension& offset) = 0;
66     virtual void SetPullToRefresh(bool isPullToRefresh) = 0;
SetIsCustomBuilderExist(bool isCustomBuilderExist)67     virtual void SetIsCustomBuilderExist(bool isCustomBuilderExist) {}
CreateWithResourceObj(const RefPtr<ResourceObject> & resObj)68     virtual void CreateWithResourceObj(const RefPtr<ResourceObject>& resObj) {};
69 private:
70     static std::unique_ptr<RefreshModel> instance_;
71     static std::mutex mutex_;
72 };
73 } // namespace OHOS::Ace
74 
75 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_REFRESH_MODEL_H
76