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_INPUT_EDIT_TEXT_COMPONENT_H 17 #define OHOS_ACELITE_INPUT_EDIT_TEXT_COMPONENT_H 18 #include "acelite_config.h" 19 #if (FEATURE_COMPONENT_EDITTEXT == 1) 20 #include "component.h" 21 #include "flex_layout.h" 22 #include "non_copyable.h" 23 #include "key_parser.h" 24 #include "ui_edit_text.h" 25 26 namespace OHOS { 27 namespace ACELite { 28 class InputEditTextComponent final : public Component { 29 public: 30 31 ACE_DISALLOW_COPY_AND_MOVE(InputEditTextComponent); 32 InputEditTextComponent() = delete; InputEditTextComponent(jerry_value_t options,jerry_value_t children,AppStyleManager * manager)33 InputEditTextComponent(jerry_value_t options, jerry_value_t children, AppStyleManager *manager) 34 : Component(options, children, manager), 35 onValueChangeListener_(nullptr), 36 fontFamily_(nullptr), 37 fontSize_(DEFAULT_FONT_SIZE) 38 { 39 SetComponentName(K_INPUT); 40 } ~InputEditTextComponent()41 ~InputEditTextComponent() override {}; 42 bool CreateNativeViews() override; 43 void ReleaseNativeViews() override; 44 bool SetPrivateAttribute(uint16_t attrKeyId, jerry_value_t attrValue) override; 45 bool RegisterPrivateEventListener(uint16_t eventTypeId, jerry_value_t funcValue, bool isStopPropagation) override; 46 bool ApplyPrivateStyle(const AppStyleItem *style) override; 47 void PostUpdate(uint16_t attrKeyId) override; 48 uint8_t GetFontSize(); 49 protected: GetComponentRootView()50 UIView *GetComponentRootView() const override 51 { 52 return const_cast<UIEditText *>(&edittext_); 53 } 54 55 private: 56 bool SetFontSize(const AppStyleItem *style); 57 bool SetColor(const AppStyleItem &style); 58 bool SetPlaceholderColor(const AppStyleItem &style); 59 UIEditText edittext_; 60 ValueChangeListener* onValueChangeListener_; 61 char *fontFamily_; 62 uint8_t fontSize_; 63 }; 64 } // namespace ACELite 65 } // namespace OHOS 66 #endif // FEATURE_COMPONENT_EDITTEXT 67 #endif // OHOS_ACELITE_INPUT_EDIT_TEXT_COMPONENT_H 68