1 /* 2 * Copyright (c) 2021 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_SHARED_TRANSITION_SHARED_TRANSITION_COMPONENT_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SHARED_TRANSITION_SHARED_TRANSITION_COMPONENT_H 18 19 #include "core/animation/shared_transition_effect.h" 20 #include "core/components/common/properties/tween_option.h" 21 #include "core/pipeline/base/composed_component.h" 22 23 namespace OHOS::Ace { 24 25 class SharedTransitionEffect; 26 27 class ACE_EXPORT SharedTransitionComponent : public ComposedComponent { 28 DECLARE_ACE_TYPE(SharedTransitionComponent, ComposedComponent); 29 30 public: 31 SharedTransitionComponent(const ComposeId& id, const std::string& name, ShareId shareId); 32 ~SharedTransitionComponent() override = default; 33 34 void SetOption(const TweenOption& option); 35 36 const TweenOption& GetOption() const; 37 const ShareId& GetShareId() const; 38 const RefPtr<SharedTransitionEffect>& GetEffect() const; 39 void SetEffect(RefPtr<SharedTransitionEffect>& effect); 40 RefPtr<Element> CreateElement() override; 41 bool IsEnablePopEnter() const; 42 void SetEnablePopEnter(bool enablePopEnter); 43 bool IsEnablePushEnter() const; 44 void SetEnablePushEnter(bool enablePushEnter); 45 bool IsEnablePopExit() const; 46 void SetEnablePopExit(bool enablePopExit); 47 bool IsEnablePushExit() const; 48 void SetEnablePushExit(bool enablePushExit); 49 void SetShareId(const ShareId& shareId); 50 void SetOpacity(float opacity); 51 float GetOpacity() const; 52 void SetZIndex(int32_t index); 53 int32_t GetZIndex() const; 54 55 private: 56 void InitEnableStatus(); 57 58 ShareId shareId_; 59 TweenOption option_; 60 RefPtr<SharedTransitionEffect> effect_; 61 bool enablePopEnter_ = true; // enable shared transition when page in pop enter scene. 62 bool enablePopExit_ = true; 63 bool enablePushEnter_ = true; 64 bool enablePushExit_ = true; 65 float opacity_ = 1.0; 66 int32_t zIndex_ = 0; 67 }; 68 69 } // namespace OHOS::Ace 70 71 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SHARED_TRANSITION_SHARED_TRANSITION_COMPONENT_H 72