• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/image/image_component.h"
20 #include "core/components/search/search_component.h"
21 #include "core/components/search/search_theme.h"
22 #include "core/components/text_field/text_field_component.h"
23 #include "core/components_ng/pattern/search/search_model.h"
24 
25 namespace OHOS::Ace::Framework {
26 
27 class ACE_EXPORT SearchModelImpl : public OHOS::Ace::SearchModel {
28 public:
29     RefPtr<TextFieldControllerBase> Create(const std::optional<std::string>& value,
30         const std::optional<std::string>& placeholder, const std::optional<std::string>& icon) override;
RequestKeyboardOnFocus(bool needToRequest)31     void RequestKeyboardOnFocus(bool needToRequest) override {};
32     void SetSearchButton(const std::string& text) override;
SetCaretWidth(const Dimension & value)33     void SetCaretWidth(const Dimension& value) override {}
SetCaretColor(const Color & color)34     void SetCaretColor(const Color& color) override {}
SetSearchIconSize(const Dimension & value)35     void SetSearchIconSize(const Dimension& value) override {}
SetSearchIconColor(const Color & color)36     void SetSearchIconColor(const Color& color) override {}
SetSearchSrcPath(const std::string & src)37     void SetSearchSrcPath(const std::string& src) override {}
SetRightIconSrcPath(const std::string & src)38     void SetRightIconSrcPath(const std::string& src) override {}
SetCancelButtonStyle(OHOS::Ace::CancelButtonStyle cancelButtonStyle)39     void SetCancelButtonStyle(OHOS::Ace::CancelButtonStyle cancelButtonStyle) override {}
SetCancelIconSize(const Dimension & value)40     void SetCancelIconSize(const Dimension& value) override {}
SetCancelIconColor(const Color & color)41     void SetCancelIconColor(const Color& color) override {}
SetSearchButtonFontSize(const Dimension & value)42     void SetSearchButtonFontSize(const Dimension& value) override {}
SetSearchButtonFontColor(const Color & color)43     void SetSearchButtonFontColor(const Color& color) override {}
44     void SetPlaceholderColor(const Color& color) override;
45     void SetPlaceholderFont(const Font& font) override;
46     void SetTextFont(const Font& font) override;
SetTextColor(const Color & color)47     void SetTextColor(const Color& color) override {}
48     void SetTextAlign(const TextAlign& textAlign) override;
49     void SetCopyOption(const CopyOptions& copyOptions) override;
50     void SetMenuOptionItems(std::vector<NG::MenuOptionsParam>&& menuOptionsItems) override;
51     void SetFocusable(bool focusable) override;
52     void SetFocusNode(bool isFocusNode) override;
53     void SetHeight(const Dimension& value) override;
54     void SetBackBorder() override;
55     void SetOnSubmit(std::function<void(const std::string&)>&& onSubmit) override;
56     void SetOnChange(std::function<void(const std::string&)>&& onChange) override;
SetOnTextSelectionChange(std::function<void (int32_t,int32_t)> && func)57     void SetOnTextSelectionChange(std::function<void(int32_t, int32_t)>&& func) override {};
SetOnScroll(std::function<void (float,float)> && func)58     void SetOnScroll(std::function<void(float, float)>&& func) override {};
59     void SetOnCopy(std::function<void(const std::string&)>&& func) override;
60     void SetOnCut(std::function<void(const std::string&)>&& func) override;
61     void SetOnPaste(std::function<void(const std::string&)>&& func) override;
SetOnChangeEvent(std::function<void (const std::string &)> && onChangeEvent)62     void SetOnChangeEvent(std::function<void(const std::string&)>&& onChangeEvent) override {};
SetSelectionMenuHidden(bool selectionMenuHidden)63     void SetSelectionMenuHidden(bool selectionMenuHidden) override {};
SetCustomKeyboard(const std::function<void ()> && buildFunc)64     void SetCustomKeyboard(const std::function<void ()> &&buildFunc) override {};
65 
66 private:
67     void InitializeDefaultValue(const RefPtr<BoxComponent>& boxComponent, const RefPtr<TextFieldComponent>& component,
68         const RefPtr<TextFieldTheme>& theme);
69     void UpdateDecorationStyle(const RefPtr<BoxComponent>& boxComponent, const RefPtr<TextFieldComponent>& component,
70         const Border& boxBorder, bool hasBoxRadius);
71     void InitializeComponent(OHOS::Ace::RefPtr<OHOS::Ace::SearchComponent>& searchComponent,
72         OHOS::Ace::RefPtr<OHOS::Ace::TextFieldComponent>& textFieldComponent,
73         const OHOS::Ace::RefPtr<OHOS::Ace::SearchTheme>& searchTheme,
74         const OHOS::Ace::RefPtr<OHOS::Ace::TextFieldTheme>& textFieldTheme);
75     void PrepareSpecializedComponent(OHOS::Ace::RefPtr<OHOS::Ace::SearchComponent>& searchComponent,
76         OHOS::Ace::RefPtr<OHOS::Ace::TextFieldComponent>& textFieldComponent);
77 };
78 
79 } // namespace OHOS::Ace::Framework
80 
81 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_MODELS_SEARCH_MODEL_IMPL_H
82