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_PATTERNS_DATE_PICKER_DATE_TIME_ANIMATION_CONTROLLER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_DATE_PICKER_DATE_TIME_ANIMATION_CONTROLLER_H 18 19 #include "core/animation/animator.h" 20 #include "core/components/display/render_display.h" 21 #include "core/components/picker/picker_animation.h" 22 #include "core/components/picker/render_picker_column.h" 23 #include "core/components/triangle/render_triangle.h" 24 #include "core/components_ng/pattern/picker/datepicker_pattern.h" 25 #include "core/pipeline/pipeline_context.h" 26 27 namespace OHOS::Ace::NG { 28 class DateTimeAnimationController : public virtual AceType { 29 DECLARE_ACE_TYPE(DateTimeAnimationController, AceType); 30 31 public: 32 ~DateTimeAnimationController() = default; 33 SetButtonIcon(const RefPtr<FrameNode> & value)34 void SetButtonIcon(const RefPtr<FrameNode>& value) 35 { 36 buttonIcon_ = value; 37 } 38 SetMonthDays(const RefPtr<FrameNode> & value)39 void SetMonthDays(const RefPtr<FrameNode>& value) 40 { 41 monthDays_ = value; 42 } 43 SetTimePicker(const RefPtr<FrameNode> & value)44 void SetTimePicker(const RefPtr<FrameNode>& value) 45 { 46 timePicker_ = value; 47 } 48 49 void SetDatePicker(const RefPtr<FrameNode>& value); 50 SetButtonRow(const RefPtr<FrameNode> & value)51 void SetButtonRow(const RefPtr<FrameNode>& value) 52 { 53 buttonRow_ = value; 54 } 55 SetDatePickerButtonHide(bool value)56 void SetDatePickerButtonHide(bool value) 57 { 58 isDatePickerButtonHade_ = value; 59 } 60 61 void Play(bool isIn); 62 63 private: 64 // triangle animation 65 void PlayTitleInAnimation(); 66 void PlayTitleOutAnimation(); 67 // opacity animation 68 void PlayOldColumnOpacityInAnimation(); 69 void PlayOldColumnOpacityOutAnimation(); 70 void PlayNewColumnOpacityInAnimation(); 71 void PlayYearColumnOpacityInAnimation(); 72 void PlayButtonOpacityInAnimation(); 73 void PlayNewColumnOpacityOutAnimation(); 74 void PlayYearColumnOpacityOutAnimation(); 75 void PlayButtonOpacityOutAnimation(); 76 // moving animation 77 void PlayMovingInAnimation(); 78 void PlayMovingOutAnimation(); 79 void InitMoveRange(); 80 // play or stop animation 81 82 void StopOldColumnOpacityInAnimation(); 83 void StopOldColumnOpacityOutAnimation(); 84 85 void PlayInAnimation(); 86 void PlayOutAnimation(); 87 88 WeakPtr<FrameNode> buttonIcon_; 89 WeakPtr<FrameNode> datePicker_; 90 WeakPtr<FrameNode> monthDays_; 91 WeakPtr<FrameNode> timePicker_; 92 WeakPtr<FrameNode> year_; 93 WeakPtr<FrameNode> month_; 94 WeakPtr<FrameNode> day_; 95 WeakPtr<FrameNode> buttonRow_; 96 // move range of date 97 double yearStart_ = 0.0; 98 double yearEnd_ = 0.0; 99 double monthStart_ = 0.0; 100 double monthEnd_ = 0.0; 101 double dayStart_ = 0.0; 102 double dayEnd_ = 0.0; 103 // others 104 std::shared_ptr<AnimationUtils::Animation> oldColumnOpacityInAnimation_; 105 std::shared_ptr<AnimationUtils::Animation> oldColumnOpacityOutAnimation_; 106 bool created_ = false; 107 bool isInAnimationPlaying_ = false; 108 bool isOutAnimationPlaying_ = false; 109 bool isDatePickerButtonHade_ = false; 110 }; 111 } // namespace OHOS::Ace 112 113 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_DATE_PICKER_DATE_TIME_ANIMATION_CONTROLLER_H 114