• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2023 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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TEXT_PICKER_TEXT_PICKER_DIALOG_VIEW_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TEXT_PICKER_TEXT_PICKER_DIALOG_VIEW_H
18 
19 #include "base/utils/macros.h"
20 #include "core/components/common/layout/constants.h"
21 #include "core/components/picker/picker_base_component.h"
22 #include "core/components_ng/pattern/text_picker/textpicker_event_hub.h"
23 #include "core/components_ng/pattern/text_picker/textpicker_pattern.h"
24 
25 namespace OHOS::Ace::NG {
26 
27 class ACE_EXPORT TextPickerDialogView {
28 public:
29     static RefPtr<FrameNode> Show(const DialogProperties& dialogProperties, const TextPickerSettingData& settingData,
30         std::map<std::string, NG::DialogTextEvent> dialogEvent,
31         std::map<std::string, NG::DialogGestureEvent> dialogCancelEvent);
32     static RefPtr<FrameNode> RangeShow(const DialogProperties& dialogProperties,
33         const TextPickerSettingData& settingData, std::map<std::string, NG::DialogTextEvent>& dialogEvent,
34         std::map<std::string, NG::DialogGestureEvent>& dialogCancelEvent);
35     static RefPtr<FrameNode> OptionsShow(const DialogProperties& dialogProperties,
36         const TextPickerSettingData& settingData, std::map<std::string, NG::DialogTextEvent>& dialogEvent,
37         std::map<std::string, NG::DialogGestureEvent>& dialogCancelEvent);
38     static void SetSelected(const RefPtr<TextPickerPattern>& textPickerPattern, uint32_t value = 0);
39     static void SetSelectedValues(const RefPtr<TextPickerPattern>& textPickerPattern,
40         const std::vector<uint32_t>& values);
41     static void SetValues(const RefPtr<TextPickerPattern>& textPickerPattern,
42         const std::vector<std::string>& values);
43     static void SetRange(const RefPtr<TextPickerPattern>& textPickerPattern,
44         const std::vector<NG::RangeContent>& value);
45     static void SetDialogChange(const RefPtr<FrameNode>& frameNode, DialogTextEvent&& onChange);
46     static void SetDefaultPickerItemHeight(const Dimension& value);
47     static void SetDialogAcceptEvent(const RefPtr<FrameNode>& frameNode, DialogTextEvent&& onChange);
48     static RefPtr<FrameNode> CreateButtonNode(const RefPtr<FrameNode>& frameNode,
49         std::map<std::string, NG::DialogTextEvent> dialogEvent,
50         std::map<std::string, NG::DialogGestureEvent> dialogCancelEvent,
51         GestureEventFunc callback);
52     static RefPtr<FrameNode> CreateDividerNode(const RefPtr<FrameNode>& dateNode);
53     static RefPtr<FrameNode> CreateConfirmNode(const RefPtr<FrameNode>& dateNode,
54         const RefPtr<FrameNode>& textPickerNode,
55         DialogEvent& acceptEvent);
56     static RefPtr<FrameNode> CreateCancelNode(NG::DialogGestureEvent& cancelEvent,
57         const RefPtr<FrameNode>& textPickerNode);
58 
59 private:
60     static RefPtr<FrameNode> CreateStackNode();
61     static RefPtr<FrameNode> CreateButtonNode();
62     static RefPtr<FrameNode> CreateColumnNode(uint32_t columnKind,
63         uint32_t showCount, RefPtr<PickerTheme> pickerTheme);
64     static RefPtr<FrameNode> CreateIconItemNode(RefPtr<PickerTheme> pickerTheme);
65     static RefPtr<FrameNode> CreateTextItemNode(RefPtr<PickerTheme> pickerTheme);
66     static RefPtr<FrameNode> CreateMixtureItemNode(RefPtr<PickerTheme> pickerTheme);
67     static void SetTextProperties(const RefPtr<PickerTheme>& pickerTheme,
68         const PickerTextProperties& properties);
69     static void OptionsCreateNode(const RefPtr<TextPickerPattern>& textPickerPattern,
70         const TextPickerSettingData& settingData, const RefPtr<FrameNode>& textPickerNode,
71         uint32_t showCount, uint32_t columnCount, RefPtr<PickerTheme> pickerTheme);
72     static void OptionsShowInternal(const RefPtr<TextPickerPattern>& textPickerPattern,
73         const TextPickerSettingData& settingData, const RefPtr<FrameNode>& textPickerNode,
74         uint32_t showCount, RefPtr<PickerTheme> pickerTheme);
75     static void InitOnKeyEvent(const RefPtr<FocusHub>& focusHub);
76     static bool OnKeyEvent(const KeyEvent& event);
77     static void UpdateButtonConfirmLayoutProperty(const RefPtr<FrameNode>& buttonConfirmNode,
78         RefPtr<PickerTheme> pickerTheme);
79     static RefPtr<FrameNode> dialogNode_;
80 };
81 } // namespace OHOS::Ace::NG
82 
83 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TEXT_PICKER_TEXT_PICKER_DIALOG_VIEW_H
84