• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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_PATTERNS_TEXT_CLOCK_MODEL_NG_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TEXT_CLOCK_MODEL_NG_H
18 
19 #include "core/components_ng/base/common_configuration.h"
20 #include "core/components_ng/pattern/text/text_layout_property.h"
21 #include "core/components_ng/pattern/text_clock/text_clock_model.h"
22 
23 namespace OHOS::Ace::NG {
24 class TextClockConfiguration : public CommonConfiguration {
25 public:
TextClockConfiguration(float timeZoneOffset,bool started,int64_t timeValue,bool enabled)26     TextClockConfiguration(float timeZoneOffset, bool started, int64_t timeValue, bool enabled)
27         : CommonConfiguration(enabled), timeZoneOffset_(timeZoneOffset), started_(started), timeValue_(timeValue)
28     {}
29     float timeZoneOffset_;
30     bool started_;
31     int64_t timeValue_;
32 };
33 using TextClockMakeCallback = std::function<RefPtr<FrameNode>(const TextClockConfiguration& textClockConfiguration)>;
34 class ACE_EXPORT TextClockModelNG : public OHOS::Ace::TextClockModel {
35 public:
36     RefPtr<TextClockController> Create() override;
37     void SetFormat(const std::string& format) override;
38     void SetHoursWest(float hoursWest) override;
39     void SetOnDateChange(std::function<void(const std::string)>&& onChange) override;
40     void SetFontSize(const Dimension& value) override;
41     void SetTextColor(const Color& value) override;
42     void ResetTextColor() override;
43     void SetItalicFontStyle(Ace::FontStyle value) override;
44     void SetFontWeight(FontWeight value) override;
45     void SetFontFamily(const std::vector<std::string>& value) override;
46     void SetTextShadow(const std::vector<Shadow>& value) override;
47     void SetFontFeature(const FONT_FEATURES_LIST& value) override;
48     void InitFontDefault(const TextStyle& textStyle) override;
49     void SetDateTimeOptions(const ZeroPrefixType& hourType) override;
50     void CreateWithTextColorResourceObj(const RefPtr<ResourceObject>& resObj) override;
51     void CreateWithFontSizeResourceObj(const RefPtr<ResourceObject>& resObj) override;
52     void CreateWithFontFamilyResourceObj(const RefPtr<ResourceObject>& resObj) override;
53     void CreateWithFontWeightResourceObj(const RefPtr<ResourceObject>& resObj) override;
54     void CreateWithFormatResourceObj(const RefPtr<ResourceObject>& resObj) override;
55     void RemoveResObjByKey(const std::string& key) override;
56 
57     static RefPtr<FrameNode> CreateFrameNode(int32_t nodeId);
58     static RefPtr<TextClockController> InitTextController(FrameNode* frameNode);
59     static void SetFormat(FrameNode* frameNode, const std::string& format);
60     static void SetHoursWest(FrameNode* frameNode, float hoursWest);
61     static void SetFontColor(FrameNode* frameNode, const Color& value);
62     static void SetFontColorByUser(FrameNode* frameNode, bool isSetByUser);
63     static void ResetFontColor(FrameNode* frameNode);
64     static void SetFontSize(FrameNode* frameNode, const Dimension& value);
65     static void SetFontStyle(FrameNode* frameNode, Ace::FontStyle value);
66     static void SetFontWeight(FrameNode* frameNode, FontWeight value);
67     static void SetFontFamily(FrameNode* frameNode, const std::vector<std::string>& value);
68     static void SetTextShadow(FrameNode* frameNode, const std::vector<Shadow>& value);
69     static void SetFontFeature(FrameNode* frameNode, const FONT_FEATURES_LIST& value);
70     static void SetBuilderFunc(FrameNode* frameNode, TextClockMakeCallback&& jsMake);
71     static void InitFontDefault(FrameNode* frameNode, const TextStyle& textStyle);
72     static void SetDateTimeOptions(FrameNode* frameNode, const ZeroPrefixType& hourType);
73     static void SetJSTextClockController(FrameNode* frameNode, const RefPtr<Referenced>& controller);
74     static RefPtr<Referenced> GetJSTextClockController(FrameNode* frameNode);
75     static void SetOnDateChange(FrameNode* frameNode, std::function<void(const std::string)>&& onChange);
76     static void CreateWithTextColorResourceObj(FrameNode* frameNode, const RefPtr<ResourceObject>& resObj);
77     static void CreateWithFontSizeResourceObj(FrameNode* frameNode, const RefPtr<ResourceObject>& resObj);
78     static void CreateWithFontFamilyResourceObj(FrameNode* frameNode, const RefPtr<ResourceObject>& resObj);
79     static void CreateWithFontWeightResourceObj(FrameNode* frameNode, const RefPtr<ResourceObject>& resObj);
80     static void CreateWithFormatResourceObj(FrameNode* frameNode, const RefPtr<ResourceObject>& resObj);
81 };
82 } // namespace OHOS::Ace::NG
83 
84 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TEXT_CLOCK_MODEL_NG_H
85