• 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_PATTERN_REFRESH_RENDER_PROPERTY_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_REFRESH_RENDER_PROPERTY_H
18 
19 #include "frameworks/core/components/common/layout/constants.h"
20 #include "frameworks/core/components_ng/layout/layout_property.h"
21 #include "frameworks/core/components_ng/property/property.h"
22 #include "frameworks/core/components_ng/render/paint_property.h"
23 
24 namespace OHOS::Ace::NG {
25 
26 class RefreshRenderProperty : public PaintProperty {
27     DECLARE_ACE_TYPE(RefreshRenderProperty, PaintProperty)
28 
29 public:
30     RefreshRenderProperty() = default;
31     ~RefreshRenderProperty() override = default;
32 
Clone()33     RefPtr<PaintProperty> Clone() const override
34     {
35         auto paintProperty = MakeRefPtr<RefreshRenderProperty>();
36         paintProperty->UpdatePaintProperty(this);
37         paintProperty->propIsRefreshing_ = CloneIsRefreshing();
38         paintProperty->propTimeText_ = CloneTimeText();
39         paintProperty->propLastTimeText_ = CloneLastTimeText();
40         return paintProperty;
41     }
42 
Reset()43     void Reset() override
44     {
45         PaintProperty::Reset();
46         ResetIsRefreshing();
47         ResetTimeText();
48         ResetLastTimeText();
49     }
50 
ToJsonValue(std::unique_ptr<JsonValue> & json)51     void ToJsonValue(std::unique_ptr<JsonValue>& json) const override
52     {
53         PaintProperty::ToJsonValue(json);
54         json->Put("refreshing", propIsRefreshing_.value_or(false) ? "true" : "false");
55     }
56     ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(IsRefreshing, bool, PROPERTY_UPDATE_LAYOUT);
57     ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(TimeText, std::string, PROPERTY_UPDATE_LAYOUT);
58     ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(LastTimeText, std::string, PROPERTY_UPDATE_LAYOUT);
59 
60 private:
61     ACE_DISALLOW_COPY_AND_MOVE(RefreshRenderProperty);
62 };
63 
64 } // namespace OHOS::Ace::NG
65 
66 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_REFRESH_RENDER_PROPERTY_H
67