• 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 
51     static RefPtr<FrameNode> CreateFrameNode(int32_t nodeId);
52     static RefPtr<TextClockController> InitTextController(FrameNode* frameNode);
53     static void SetFormat(FrameNode* frameNode, const std::string& format);
54     static void SetHoursWest(FrameNode* frameNode, float hoursWest);
55     static void SetFontColor(FrameNode* frameNode, const Color& value);
56     static void ResetFontColor(FrameNode* frameNode);
57     static void SetFontSize(FrameNode* frameNode, const Dimension& value);
58     static void SetFontStyle(FrameNode* frameNode, Ace::FontStyle value);
59     static void SetFontWeight(FrameNode* frameNode, FontWeight value);
60     static void SetFontFamily(FrameNode* frameNode, const std::vector<std::string>& value);
61     static void SetTextShadow(FrameNode* frameNode, const std::vector<Shadow>& value);
62     static void SetFontFeature(FrameNode* frameNode, const FONT_FEATURES_LIST& value);
63     static void SetBuilderFunc(FrameNode* frameNode, TextClockMakeCallback&& jsMake);
64     static void InitFontDefault(FrameNode* frameNode, const TextStyle& textStyle);
65     static void SetDateTimeOptions(FrameNode* frameNode, const ZeroPrefixType& hourType);
66     static void SetJSTextClockController(FrameNode* frameNode, const RefPtr<Referenced>& controller);
67     static RefPtr<Referenced> GetJSTextClockController(FrameNode* frameNode);
68     static void SetOnDateChange(FrameNode* frameNode, std::function<void(const std::string)>&& onChange);
69 };
70 } // namespace OHOS::Ace::NG
71 
72 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TEXT_CLOCK_MODEL_NG_H
73