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 FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_TEXTTIMER_H 17 #define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_TEXTTIMER_H 18 19 #include "bridge/declarative_frontend/jsview/js_container_base.h" 20 #include "core/components/texttimer/texttimer_controller.h" 21 22 namespace OHOS::Ace::Framework { 23 class JSTextTimer : public JSViewAbstract { 24 public: 25 static void JSBind(BindingTarget globalObj); 26 static void Create(const JSCallbackInfo& info); 27 28 protected: 29 static void SetFormat(const JSCallbackInfo& info); 30 static void SetTextColor(const JSCallbackInfo& info); 31 static void SetFontSize(const JSCallbackInfo& info); 32 static void SetFontWeight(const JSCallbackInfo& info); 33 static void SetFontStyle(int32_t value); 34 static void SetFontFamily(const JSCallbackInfo& info); 35 static void SetFontDefault(); 36 static void OnTimer(const JSCallbackInfo& info); 37 }; 38 39 class JSTextTimerController final : public Referenced { 40 public: 41 JSTextTimerController() = default; 42 ~JSTextTimerController() override = default; 43 44 static void JSBind(BindingTarget globalObj); 45 static void Constructor(const JSCallbackInfo& info); 46 static void Destructor(JSTextTimerController* timerController); 47 48 void Start(const JSCallbackInfo& info); 49 void Pause(const JSCallbackInfo& info); 50 void Reset(const JSCallbackInfo& info); 51 SetController(const RefPtr<TextTimerController> & controller)52 void SetController(const RefPtr<TextTimerController>& controller) 53 { 54 controller_ = controller; 55 } 56 GetController()57 RefPtr<TextTimerController> GetController() const 58 { 59 return controller_; 60 } 61 62 private: 63 RefPtr<TextTimerController> controller_; 64 65 ACE_DISALLOW_COPY_AND_MOVE(JSTextTimerController); 66 }; 67 } // namespace OHOS::Ace::Framework 68 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_TEXTTIMER_H 69