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_DATE_PICKER_DATE_PICKER_DIALOG_VIEW_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_DATE_PICKER_DATE_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/picker/datepicker_event_hub.h" 23 #include "core/components_ng/pattern/picker/datepicker_layout_property.h" 24 #include "core/components_ng/pattern/picker/datepicker_pattern.h" 25 #include "core/components_ng/pattern/picker/picker_type_define.h" 26 #include "core/components_ng/pattern/time_picker/timepicker_row_pattern.h" 27 28 namespace OHOS::Ace::NG { 29 class ACE_EXPORT DatePickerDialogView { 30 public: 31 static RefPtr<FrameNode> Show(const DialogProperties& dialogProps, const DatePickerSettingData& settingData, 32 std::map<std::string, NG::DialogEvent> dialogEvent, 33 std::map<std::string, NG::DialogGestureEvent> dialogCancelEvent); 34 static void SetStartDate(const RefPtr<FrameNode>& frameNode, const PickerDate& value); 35 static void SetEndDate(const RefPtr<FrameNode>& frameNode, const PickerDate& value); 36 static void SetSelectedDate(const RefPtr<FrameNode>& frameNode, const PickerDate& value); 37 static void SetShowLunar(const RefPtr<FrameNode>& frameNode, bool lunar = false); 38 static void SetDateTextProperties(const RefPtr<FrameNode>& frameNode, const PickerTextProperties& properties); 39 static void SetTimeTextProperties(const RefPtr<FrameNode>& frameNode, const PickerTextProperties& properties); 40 static void SetDialogChange(const RefPtr<FrameNode>& frameNode, DialogEvent&& onChange); 41 static void SetDialogDateChange(const RefPtr<FrameNode>& frameNode, DialogEvent&& onChange); 42 static void SetDialogAcceptEvent(const RefPtr<FrameNode>& frameNode, DialogEvent&& onChange); 43 static void SetDialogDateAcceptEvent(const RefPtr<FrameNode>& frameNode, DialogEvent&& onChange); 44 static void SetDialogSwitchEvent(std::function<bool()> switchEvent); 45 static RefPtr<FrameNode> CreateButtonNode(const RefPtr<FrameNode>& frameNode, 46 const RefPtr<FrameNode>& datePickerNode, 47 std::map<std::string, NG::DialogEvent> dialogEvent, 48 std::map<std::string, NG::DialogGestureEvent> dialogCancelEvent); 49 static RefPtr<FrameNode> CreateTitleButtonNode(const RefPtr<FrameNode>& dateNode); 50 static RefPtr<FrameNode> CreateTitleButtonRowNode(); 51 static void CreateTitleIconNode(const RefPtr<FrameNode>& titleNode); 52 static RefPtr<FrameNode> CreateDividerNode(const RefPtr<FrameNode>& dateNode); 53 static RefPtr<FrameNode> CreateConfirmNode(const RefPtr<FrameNode>& dateNode, 54 const RefPtr<FrameNode>& datePickerNode, DialogEvent& acceptEvent); 55 static RefPtr<FrameNode> CreateCancelNode(NG::DialogGestureEvent& cancelEvent, 56 const RefPtr<FrameNode>& datePickerNode); 57 static RefPtr<FrameNode> CreateDateNode(int32_t dateNodeId, std::map<std::string, PickerDate> datePickerProperty, 58 const PickerTextProperties& properties, bool isLunar, bool hasTime); 59 static RefPtr<FrameNode> CreateColumnNode(int32_t nodeId, uint32_t showCount, bool isDate = true); 60 static void CreateNormalDateNode(const RefPtr<FrameNode>& dateNode, uint32_t showCount); 61 static void CreateSingleDateNode(const RefPtr<FrameNode>& dateNode, uint32_t showCount); 62 static RefPtr<FrameNode> CreateTimeNode(std::map<std::string, PickerTime> timePickerProperty, 63 const PickerTextProperties& properties, bool useMilitaryTime); 64 65 static bool switchFlag_; 66 67 private: 68 static RefPtr<FrameNode> CreateStackNode(); 69 static RefPtr<FrameNode> CreateButtonNode(); 70 static void CreateLunarswitchNode( 71 const RefPtr<FrameNode>& contentColumn, std::function<void(const bool)>&& changeEvent, bool isLunar); 72 static void SetTitleMouseHoverEvent(const RefPtr<FrameNode>& titleRow); 73 static void HandleMouseEvent(const RefPtr<FrameNode>& titleButton, bool isHover); 74 static void PlayHoverAnimation(const RefPtr<FrameNode>& titleButton, const Color& color); 75 }; 76 } // namespace OHOS::Ace::NG 77 78 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_DATE_PICKER_DATE_PICKER_DIALOG_VIEW_H 79