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 SetTextShadow(const JSCallbackInfo& info); 37 static void OnTimer(const JSCallbackInfo& info); 38 }; 39 40 class JSTextTimerController final : public Referenced { 41 public: 42 JSTextTimerController() = default; 43 ~JSTextTimerController() override = default; 44 45 static void JSBind(BindingTarget globalObj); 46 static void Constructor(const JSCallbackInfo& info); 47 static void Destructor(JSTextTimerController* timerController); 48 49 void Start(const JSCallbackInfo& info); 50 void Pause(const JSCallbackInfo& info); 51 void Reset(const JSCallbackInfo& info); 52 SetController(const RefPtr<TextTimerController> & controller)53 void SetController(const RefPtr<TextTimerController>& controller) 54 { 55 controller_ = controller; 56 } 57 GetController()58 RefPtr<TextTimerController> GetController() const 59 { 60 return controller_; 61 } 62 SetInstanceId(int32_t id)63 void SetInstanceId(int32_t id) 64 { 65 instanceId_ = id; 66 } 67 68 private: 69 int32_t instanceId_ = INSTANCE_ID_UNDEFINED; 70 RefPtr<TextTimerController> controller_; 71 72 ACE_DISALLOW_COPY_AND_MOVE(JSTextTimerController); 73 }; 74 } // namespace OHOS::Ace::Framework 75 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_TEXTTIMER_H 76