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 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_V2_PATTERN_LOCK_PATTERN_LOCK_COMPONENT_H 16 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_V2_PATTERN_LOCK_PATTERN_LOCK_COMPONENT_H 17 #include "base/geometry/dimension.h" 18 #include "base/log/log.h" 19 #include "core/components/common/properties/color.h" 20 #include "core/components/common/properties/edge.h" 21 #include "core/components_v2/pattern_lock/pattern_lock_controller.h" 22 #include "core/pipeline/base/render_component.h" 23 #include "frameworks/core/components/common/properties/svg_paint_state.h" 24 25 namespace OHOS::Ace::V2 { 26 constexpr int32_t DEFAULT_SIDE_LENGTH = 300; 27 constexpr int32_t DEFAULT_CIRCLE_RADIUS = 14; 28 constexpr int32_t DEFAULT_STROKE_WIDTH = 34; 29 30 class PatternCompleteEvent : public BaseEventInfo { 31 DECLARE_RELATIONSHIP_OF_CLASSES(PatternCompleteEvent, BaseEventInfo); 32 33 public: PatternCompleteEvent(std::vector<int> input)34 explicit PatternCompleteEvent(std::vector<int> input) : BaseEventInfo("patternCompleteEvent"), input_(input) {} 35 ~PatternCompleteEvent() = default; GetInput()36 std::vector<int> GetInput() const 37 { 38 return input_; 39 } 40 41 private: 42 std::vector<int> input_; 43 }; 44 class ACE_EXPORT PatternLockComponent : public RenderComponent { 45 DECLARE_ACE_TYPE(PatternLockComponent, RenderComponent); 46 47 public: 48 PatternLockComponent(); 49 ~PatternLockComponent() override = default; 50 RefPtr<RenderNode> CreateRenderNode() override; 51 RefPtr<Element> CreateElement() override; 52 void SetCircleRadius(const Dimension& circleRadius); 53 void SetSideLength(const Dimension& sideLength); 54 void SetRegularColor(const Color& regularColor); 55 void SetSelectedColor(const Color& selectedColor); 56 void SetActiveColor(const Color& regularColor); 57 void SetPathColor(const Color& regularColor); 58 void SetStrokeWidth(const Dimension& lineWidth); 59 void SetAutoReset(bool isAutoReset); 60 const Dimension& GetCircleRadius() const; 61 const Dimension& GetSideLength() const; 62 const Dimension& GetStrokeWidth() const; 63 const Color& GetRegularColor() const; 64 const Color& GetSelectedColor() const; 65 const Color& GetActiveColor() const; 66 const Color& GetPathColor() const; 67 bool GetAutoReset() const; SetPatternCompleteEvent(const EventMarker & event)68 void SetPatternCompleteEvent(const EventMarker& event) 69 { 70 patternCompleteEvent_ = event; 71 } GetPatternCompleteEvent()72 const EventMarker& GetPatternCompleteEvent() const 73 { 74 return patternCompleteEvent_; 75 } 76 RefPtr<V2::PatternLockController> GetPatternLockController() const; 77 78 private: 79 Dimension circleRadius_ { DEFAULT_CIRCLE_RADIUS, DimensionUnit::VP }; 80 Dimension sideLength_ { DEFAULT_SIDE_LENGTH, DimensionUnit::VP }; 81 Color regularColor_; 82 Color selectedColor_; 83 Color pathColor_; 84 Color activeColor_; 85 EventMarker patternCompleteEvent_; 86 RefPtr<V2::PatternLockController> patternLockController_; 87 Dimension strokeWidth_ { DEFAULT_STROKE_WIDTH, DimensionUnit::VP }; 88 bool autoReset_ = true; 89 }; 90 } // namespace OHOS::Ace::V2 91 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_V2_PATTERN_LOCK_PATTERN_LOCK_COMPONENT_H