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