1 /* 2 * Copyright (c) 2021-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_MODELS_TEXT_FIELD_MODEL_IMPL_H 17 #define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_MODELS_TEXT_FIELD_MODEL_IMPL_H 18 19 #include <optional> 20 #include <string> 21 22 #include "frameworks/core/components_ng/pattern/text_field/text_field_model.h" 23 24 namespace OHOS::Ace::Framework { 25 26 class TextFieldModelImpl : public TextFieldModel { 27 public: 28 RefPtr<TextFieldControllerBase> CreateTextInput( 29 const std::optional<std::string>& placeholder, const std::optional<std::string>& value) override; 30 CreateTextArea(const std::optional<std::string> & placeholder,const std::optional<std::string> & value)31 RefPtr<TextFieldControllerBase> CreateTextArea( 32 const std::optional<std::string>& placeholder, const std::optional<std::string>& value) override 33 { 34 return nullptr; 35 } SetWidthAuto(bool isAuto)36 void SetWidthAuto(bool isAuto) override {}; 37 void SetType(TextInputType value) override; 38 void SetPlaceholderColor(const Color& value) override; 39 void SetPlaceholderFont(const Font& value) override; 40 void SetEnterKeyType(TextInputAction value) override; 41 void SetTextAlign(TextAlign value) override; 42 void SetCaretColor(const Color& value) override; 43 void SetMaxLength(uint32_t value) override; 44 void SetMaxLines(uint32_t value) override; 45 void SetFontSize(const Dimension& value) override; 46 void SetFontWeight(FontWeight value) override; 47 void SetTextColor(const Color& value) override; 48 void SetFontStyle(FontStyle value) override; 49 void SetFontFamily(const std::vector<std::string>& value) override; 50 void SetInputFilter(const std::string& value, const std::function<void(const std::string&)>& onError) override; 51 void SetInputStyle(InputStyle value) override; 52 void SetShowPasswordIcon(bool value) override; 53 void SetOnEditChanged(std::function<void(bool)>&& func) override; 54 void SetOnSubmit(std::function<void(int32_t)>&& func) override; 55 void SetOnChange(std::function<void(const std::string&)>&& func) override; 56 void SetOnCopy(std::function<void(const std::string&)>&& func) override; 57 void SetOnCut(std::function<void(const std::string&)>&& func) override; 58 void SetOnPaste(std::function<void(const std::string&)>&& func) override; 59 void SetCopyOption(CopyOptions copyOption) override; ResetMaxLength()60 void ResetMaxLength() override {}; 61 static void InitTextInputDefaultStyle(); 62 }; 63 64 } // namespace OHOS::Ace::Framework 65 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_MODELS_TEXT_FIELD_MODEL_IMPL_H 66