• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
56     void Play(bool isIn);
57 
58 private:
59     // triangle animation
60     void PlayTitleInAnimation();
61     void PlayTitleOutAnimation();
62     // opacity animation
63     void PlayOldColumnOpacityInAnimation();
64     void PlayOldColumnOpacityOutAnimation();
65     void PlayNewColumnOpacityInAnimation();
66     void PlayYearColumnOpacityInAnimation();
67     void PlayButtonOpacityInAnimation();
68     void PlayNewColumnOpacityOutAnimation();
69     void PlayYearColumnOpacityOutAnimation();
70     void PlayButtonOpacityOutAnimation();
71     // moving animation
72     void PlayMovingInAnimation();
73     void PlayMovingOutAnimation();
74     void InitMoveRange();
75     // play or stop animation
76 
77     void StopOldColumnOpacityInAnimation();
78     void StopOldColumnOpacityOutAnimation();
79 
80     void PlayInAnimation();
81     void PlayOutAnimation();
82 
83     RefPtr<FrameNode> buttonIcon_;
84     RefPtr<FrameNode> datePicker_;
85     RefPtr<FrameNode> monthDays_;
86     RefPtr<FrameNode> timePicker_;
87     RefPtr<FrameNode> year_;
88     RefPtr<FrameNode> month_;
89     RefPtr<FrameNode> day_;
90     RefPtr<FrameNode> buttonRow_;
91     // move range of date
92     double yearStart_ = 0.0;
93     double yearEnd_ = 0.0;
94     double monthStart_ = 0.0;
95     double monthEnd_ = 0.0;
96     double dayStart_ = 0.0;
97     double dayEnd_ = 0.0;
98     // others
99     std::shared_ptr<AnimationUtils::Animation> oldColumnOpacityInAnimation_;
100     std::shared_ptr<AnimationUtils::Animation> oldColumnOpacityOutAnimation_;
101     bool created_ = false;
102     bool isInAnimationPlaying_ = false;
103     bool isOutAnimationPlaying_ = false;
104 };
105 } // namespace OHOS::Ace
106 
107 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_DATE_PICKER_DATE_TIME_ANIMATION_CONTROLLER_H