1 /* 2 * Copyright (c) 2020-2021 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 OHOS_ACELITE_SWITCH_COMPONENT_H 17 #define OHOS_ACELITE_SWITCH_COMPONENT_H 18 #include "component.h" 19 #include "non_copyable.h" 20 #include "ui_toggle_button.h" 21 22 namespace OHOS { 23 namespace ACELite { 24 class SwitchComponent final : public Component { 25 public: 26 ACE_DISALLOW_COPY_AND_MOVE(SwitchComponent); 27 SwitchComponent() = delete; 28 SwitchComponent(jerry_value_t options, jerry_value_t children, AppStyleManager *styleManager); 29 ~SwitchComponent() override; 30 31 protected: 32 bool ApplyPrivateStyle(const AppStyleItem *style) override; 33 bool CreateNativeViews() override; 34 bool SetPrivateAttribute(uint16_t attrKeyId, jerry_value_t attrValue) override; 35 bool RegisterPrivateEventListener(uint16_t eventTypeId, jerry_value_t funcValue, bool isStopPropagation) override; 36 UIView *GetComponentRootView() const override; 37 void PostRender() override; 38 39 private: 40 UIToggleButton toggleButton_; 41 StateChangeListener *changeListener_; 42 ViewOnClickListener *clickListener_; 43 }; 44 } // namespace ACELite 45 } // namespace OHOS 46 47 #endif // OHOS_ACELITE_SWITCH_COMPONENT_H 48