1 /* 2 * Copyright (c) 2022 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_TOSS_ANIMATION_CONTROLLER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_DATE_PICKER_TOSS_ANIMATION_CONTROLLER_H 18 19 #include "core/components/picker/picker_animation.h" 20 #include "core/pipeline_ng/pipeline_context.h" 21 #include "frameworks/base/memory/ace_type.h" 22 23 namespace OHOS::Ace::NG { 24 class DatePickerColumnPattern; 25 26 class TossAnimationController : public virtual AceType { 27 DECLARE_ACE_TYPE(TossAnimationController, AceType); 28 29 public: 30 TossAnimationController() = default; 31 ~TossAnimationController() = default; 32 SetColumn(const WeakPtr<DatePickerColumnPattern> & value)33 void SetColumn(const WeakPtr<DatePickerColumnPattern>& value) 34 { 35 column_ = value; 36 } 37 SetPipelineContext(const WeakPtr<PipelineContext> & pipeline)38 void SetPipelineContext(const WeakPtr<PipelineContext>& pipeline) 39 { 40 pipeline_ = pipeline; 41 } 42 43 void SetStart(double y); 44 45 void SetEnd(double y); 46 47 bool Play(); 48 49 private: 50 double GetCurrentTime() const; 51 52 double yStart_ = 0.0; 53 double yEnd_ = 0.0; 54 double timeStart_ = 0.0; 55 double timeEnd_ = 0.0; 56 double speed_ = 0.0; 57 58 RefPtr<PickerAnimation> toss_; 59 WeakPtr<DatePickerColumnPattern> column_; 60 WeakPtr<PipelineContext> pipeline_; 61 }; 62 } // namespace OHOS::Ace::NG 63 64 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_DATE_PICKER_TOSS_ANIMATION_CONTROLLER_H 65