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_TIMER_MODEL_NG_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TEXT_TIMER_MODEL_NG_H 18 19 #include "core/components_ng/base/common_configuration.h" 20 #include "core/components_ng/base/frame_node.h" 21 #include "core/components_ng/pattern/texttimer/text_timer_model.h" 22 23 namespace OHOS::Ace::NG { 24 class TextTimerConfiguration : public CommonConfiguration { 25 public: TextTimerConfiguration(double count,bool isCountDown,bool started,int64_t elapsedTime,bool enabled)26 TextTimerConfiguration(double count, bool isCountDown, bool started, int64_t elapsedTime, bool enabled) 27 : CommonConfiguration(enabled), 28 count_(count), 29 isCountDown_(isCountDown), 30 started_(started), 31 elapsedTime_(elapsedTime) 32 {} 33 double count_ = 60000.0; 34 bool isCountDown_ = false; 35 bool started_ = false; 36 uint64_t elapsedTime_ = 0; 37 }; 38 using TextTimerMakeCallback = 39 std::function<RefPtr<FrameNode>(const TextTimerConfiguration& textTimerConfiguration)>; 40 class ACE_EXPORT TextTimerModelNG : public OHOS::Ace::TextTimerModel { 41 public: 42 RefPtr<TextTimerController> Create() override; 43 void SetFormat(const std::string& format) override; 44 void SetIsCountDown(bool isCountDown) override; 45 void SetInputCount(double count) override; 46 void SetOnTimer(std::function<void(int64_t, int64_t)> && onChange) override; 47 void SetFontSize(const Dimension& value) override; 48 void SetTextColor(const Color& value) override; 49 void SetTextShadow(const std::vector<Shadow>& value) override; 50 void SetItalicFontStyle(Ace::FontStyle value) override; 51 void SetFontWeight(FontWeight value) override; 52 void SetFontFamily(const std::vector<std::string>& value) override; 53 static RefPtr<FrameNode> CreateFrameNode(int32_t nodeId); 54 static RefPtr<TextTimerController> InitTextController(FrameNode* frameNode); 55 static void SetIsCountDown(FrameNode* frameNode, bool isCountDown); 56 static void SetInputCount(FrameNode* frameNode, double count); 57 static void SetFontColor(FrameNode* frameNode, const Color& value); 58 static void SetFontSize(FrameNode* frameNode, const Dimension& value); 59 static void SetFontStyle(FrameNode* frameNode, Ace::FontStyle value); 60 static void SetFontWeight(FrameNode* frameNode, FontWeight value); 61 static void SetFontFamily(FrameNode* frameNode, const std::vector<std::string>& value); 62 static void SetFormat(FrameNode* frameNode, const std::string& format); 63 static void SetTextShadow(FrameNode* frameNode, const std::vector<Shadow>& value); 64 static void SetBuilderFunc(FrameNode* frameNode, TextTimerMakeCallback&& jsMake); 65 static void SetJSTextTimerController(FrameNode* frameNode, const RefPtr<Referenced>& controller); 66 static RefPtr<Referenced> GetJSTextTimerController(FrameNode* frameNode); 67 }; 68 } // namespace OHOS::Ace::NG 69 70 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TEXT_TIMER_MODEL_NG_H 71