1 /*
2  * Copyright (c) 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_PATTERN_CALENDAR_PICKER_CALENDAR_PICKER_MODEL_NG_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_CALENDAR_PICKER_CALENDAR_PICKER_MODEL_NG_H
18 
19 #include "core/components/calendar/calendar_theme.h"
20 #include "core/components_ng/pattern/calendar_picker/calendar_picker_model.h"
21 #include "core/components_ng/pattern/calendar_picker/calendar_picker_pattern.h"
22 
23 namespace OHOS::Ace::NG {
24 class ACE_EXPORT CalendarPickerModelNG : public CalendarPickerModel {
25 public:
26     void Create(const CalendarSettingData& settingData) override;
27     void SetEdgeAlign(const CalendarEdgeAlign& alignType, const DimensionOffset& offset) override;
28     void SetTextStyle(const PickerTextStyle& textStyle) override;
29     void SetOnChange(SelectedChangeEvent&& onChange) override;
30     void SetChangeEvent(SelectedChangeEvent&& onChange) override;
31     void SetPadding(const PaddingProperty& padding) override;
32     void ClearBorderColor() override;
33     void ClearBorderRadius() override;
34     void ClearHeight() override;
35     void ClearBorder() override;
36     void ClearBorderWidth() override;
37     void ClearPadding() override;
38     static RefPtr<FrameNode> CreateNode(int32_t nodeId, const CalendarSettingData& settingData);
39     static RefPtr<FrameNode> CreateFrameNode(int32_t nodeId);
40     static void SetTextStyle(FrameNode* frameNode, const PickerTextStyle& textStyle);
41     static void SetEdgeAlign(FrameNode* frameNode, const CalendarEdgeAlign& alignType, const DimensionOffset& offset);
42     static void SetPadding(FrameNode* frameNode, const PaddingProperty& padding);
43     static void ClearPadding(FrameNode* frameNode);
44     static void ClearHeight(FrameNode* frameNode);
45     static void ClearBorderColor(FrameNode* frameNode);
46     static void ClearBorderRadius(FrameNode* frameNode);
47     static void ClearBorderWidth(FrameNode* frameNode);
48     static void LayoutPicker(const RefPtr<CalendarPickerPattern>& pickerPattern, RefPtr<FrameNode>& pickerNode,
49         const CalendarSettingData& settingData, const RefPtr<CalendarTheme>& theme);
50     static RefPtr<FrameNode> CreateButtonChild(
51         int32_t id, bool isAdd, const RefPtr<CalendarTheme>& theme, TextDirection textDirection);
52     static RefPtr<FrameNode> CreateButtonImageChild(bool isAdd, const RefPtr<CalendarTheme>& theme);
53     static RefPtr<FrameNode> CreateCalendarNodeChild(int32_t contentId,
54         const CalendarSettingData& settingData, const RefPtr<CalendarTheme>& theme, TextDirection textDirection);
55     static RefPtr<FrameNode> CreateButtonFlexChild(int32_t buttonFlexId, const RefPtr<CalendarTheme>& theme);
56     static void CreateDateNode(int32_t contentId, const CalendarSettingData& settingData);
57     static RefPtr<FrameNode> CreateDateTextNode(const std::string& textContent);
58     static void SetHintRadiusWithNode(FrameNode* frameNode, Dimension& radius);
59     static void SetSelectDateWithNode(FrameNode* frameNode, uint32_t year, uint32_t month, uint32_t day);
60     static Dimension GetHintRadius(FrameNode* frameNode);
61     static PickerDate GetSelectDateWithNode(FrameNode* frameNode);
62     static RefPtr<FrameNode> GetYearNode(FrameNode* calendarPickerNode);
63     static RefPtr<FrameNode> GetMonthNode(FrameNode* calendarPickerNode);
64     static RefPtr<FrameNode> GetDayNode(FrameNode* calendarPickerNode);
65     static PickerTextStyle GetTextStyle(FrameNode* frameNode);
66     static CalendarEdgeAlign GetEdgeAlignType(FrameNode* frameNode);
67     static DimensionOffset GetEdgeOffset(FrameNode* frameNode);
68     static void SetOnChangeWithNode(FrameNode* frameNode, SelectedChangeEvent&& onChange);
69     static std::map<std::size_t, std::string> GetDateNodeOrder(const CalendarSettingData& settingData);
70 };
71 } // namespace OHOS::Ace::NG
72 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_CALENDAR_PICKER_CALENDAR_PICKER_MODEL_NG_H
73