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_MODELS_SEARCH_MODEL_IMPL_H 17 #define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_MODELS_SEARCH_MODEL_IMPL_H 18 19 #include "core/components/search/search_component.h" 20 #include "core/components/search/search_theme.h" 21 #include "core/components/text_field/text_field_component.h" 22 #include "core/components_ng/pattern/search/search_model.h" 23 24 namespace OHOS::Ace::Framework { 25 26 class ACE_EXPORT SearchModelImpl : public OHOS::Ace::SearchModel { 27 public: 28 RefPtr<TextFieldControllerBase> Create(const std::optional<std::string>& value, 29 const std::optional<std::string>& placeholder, const std::optional<std::string>& icon) override; 30 void SetSearchButton(const std::string& text) override; 31 void SetPlaceholderColor(const Color& color) override; 32 void SetPlaceholderFont(const Font& font) override; 33 void SetTextFont(const Font& font) override; 34 void SetTextAlign(const TextAlign& textAlign) override; 35 void SetCopyOption(const CopyOptions& copyOptions) override; 36 void SetOnSubmit(std::function<void(const std::string&)>&& onSubmit) override; 37 void SetOnChange(std::function<void(const std::string&)>&& onChange) override; 38 void SetOnCopy(std::function<void(const std::string&)>&& func) override; 39 void SetOnCut(std::function<void(const std::string&)>&& func) override; 40 void SetOnPaste(std::function<void(const std::string&)>&& func) override; 41 42 private: 43 void InitializeDefaultValue(const RefPtr<BoxComponent>& boxComponent, const RefPtr<TextFieldComponent>& component, 44 const RefPtr<TextFieldTheme>& theme); 45 void UpdateDecorationStyle(const RefPtr<BoxComponent>& boxComponent, const RefPtr<TextFieldComponent>& component, 46 const Border& boxBorder, bool hasBoxRadius); 47 void InitializeComponent(OHOS::Ace::RefPtr<OHOS::Ace::SearchComponent>& searchComponent, 48 OHOS::Ace::RefPtr<OHOS::Ace::TextFieldComponent>& textFieldComponent, 49 const OHOS::Ace::RefPtr<OHOS::Ace::SearchTheme>& searchTheme, 50 const OHOS::Ace::RefPtr<OHOS::Ace::TextFieldTheme>& textFieldTheme); 51 void PrepareSpecializedComponent(OHOS::Ace::RefPtr<OHOS::Ace::SearchComponent>& searchComponent, 52 OHOS::Ace::RefPtr<OHOS::Ace::TextFieldComponent>& textFieldComponent); 53 }; 54 55 } // namespace OHOS::Ace::Framework 56 57 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_MODELS_SEARCH_MODEL_IMPL_H 58