• 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,const std::string & bundleName,const std::string & moduleName)37     void SetSearchSrcPath(
38         const std::string& src, const std::string& bundleName, const std::string& moduleName) override {}
SetRightIconSrcPath(const std::string & src)39     void SetRightIconSrcPath(const std::string& src) override {}
SetCancelButtonStyle(OHOS::Ace::CancelButtonStyle cancelButtonStyle)40     void SetCancelButtonStyle(OHOS::Ace::CancelButtonStyle cancelButtonStyle) override {}
SetCancelIconSize(const Dimension & value)41     void SetCancelIconSize(const Dimension& value) override {}
SetCancelIconColor(const Color & color)42     void SetCancelIconColor(const Color& color) override {}
SetSearchButtonFontSize(const Dimension & value)43     void SetSearchButtonFontSize(const Dimension& value) override {}
SetSearchButtonFontColor(const Color & color)44     void SetSearchButtonFontColor(const Color& color) override {}
45     void SetPlaceholderColor(const Color& color) override;
46     void SetPlaceholderFont(const Font& font) override;
47     void SetTextFont(const Font& font) override;
SetTextColor(const Color & color)48     void SetTextColor(const Color& color) override {}
49     void SetTextAlign(const TextAlign& textAlign) override;
50     void SetCopyOption(const CopyOptions& copyOptions) override;
51     void SetMenuOptionItems(std::vector<NG::MenuOptionsParam>&& menuOptionsItems) override;
52     void SetFocusable(bool focusable) override;
53     void SetFocusNode(bool isFocusNode) override;
54     void SetHeight(const Dimension& value) override;
55     void SetBackBorder() override;
56     void SetOnSubmit(std::function<void(const std::string&)>&& onSubmit) override;
57     void SetOnChange(std::function<void(const std::string&)>&& onChange) override;
SetOnTextSelectionChange(std::function<void (int32_t,int32_t)> && func)58     void SetOnTextSelectionChange(std::function<void(int32_t, int32_t)>&& func) override {};
SetOnScroll(std::function<void (float,float)> && func)59     void SetOnScroll(std::function<void(float, float)>&& func) override {};
60     void SetOnCopy(std::function<void(const std::string&)>&& func) override;
61     void SetOnCut(std::function<void(const std::string&)>&& func) override;
62     void SetOnPaste(std::function<void(const std::string&)>&& func) override;
SetOnPasteWithEvent(std::function<void (const std::string &,NG::TextCommonEvent &)> && func)63     void SetOnPasteWithEvent(std::function<void(const std::string&, NG::TextCommonEvent&)>&& func) override {};
SetOnChangeEvent(std::function<void (const std::string &)> && onChangeEvent)64     void SetOnChangeEvent(std::function<void(const std::string&)>&& onChangeEvent) override {};
SetSelectionMenuHidden(bool selectionMenuHidden)65     void SetSelectionMenuHidden(bool selectionMenuHidden) override {};
SetCustomKeyboard(const std::function<void ()> && buildFunc)66     void SetCustomKeyboard(const std::function<void ()> &&buildFunc) override {};
SetMaxLength(uint32_t value)67     void SetMaxLength(uint32_t value) override {};
ResetMaxLength()68     void ResetMaxLength() override {};
SetType(TextInputType type)69     void SetType(TextInputType type) override {};
70 
71 private:
72     void InitializeDefaultValue(const RefPtr<BoxComponent>& boxComponent, const RefPtr<TextFieldComponent>& component,
73         const RefPtr<TextFieldTheme>& theme);
74     void UpdateDecorationStyle(const RefPtr<BoxComponent>& boxComponent, const RefPtr<TextFieldComponent>& component,
75         const Border& boxBorder, bool hasBoxRadius);
76     void InitializeComponent(OHOS::Ace::RefPtr<OHOS::Ace::SearchComponent>& searchComponent,
77         OHOS::Ace::RefPtr<OHOS::Ace::TextFieldComponent>& textFieldComponent,
78         const OHOS::Ace::RefPtr<OHOS::Ace::SearchTheme>& searchTheme,
79         const OHOS::Ace::RefPtr<OHOS::Ace::TextFieldTheme>& textFieldTheme);
80     void PrepareSpecializedComponent(OHOS::Ace::RefPtr<OHOS::Ace::SearchComponent>& searchComponent,
81         OHOS::Ace::RefPtr<OHOS::Ace::TextFieldComponent>& textFieldComponent);
82 };
83 
84 } // namespace OHOS::Ace::Framework
85 
86 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_MODELS_SEARCH_MODEL_IMPL_H
87