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 #include "core/components/rating/rating_component.h" 17 18 #include "core/components/rating/rating_element.h" 19 20 namespace OHOS::Ace { 21 SetResIdFromTheme(const RefPtr<RatingTheme> & theme)22void RatingComponent::SetResIdFromTheme(const RefPtr<RatingTheme>& theme) 23 { 24 if (!theme) { 25 return; 26 } 27 foregroundResourceId_ = theme->GetForegroundResourceId(); 28 secondaryResourceId_ = theme->GetSecondaryResourceId(); 29 backgroundResourceId_ = theme->GetBackgroundResourceId(); 30 } 31 SetMiniResIdFromTheme(const RefPtr<RatingTheme> & theme)32void RatingComponent::SetMiniResIdFromTheme(const RefPtr<RatingTheme>& theme) 33 { 34 if (!theme) { 35 return; 36 } 37 foregroundResourceId_ = theme->GetForegroundMiniResourceId(); 38 secondaryResourceId_ = theme->GetSecondaryMiniResourceId(); 39 backgroundResourceId_ = theme->GetBackgroundMiniResourceId(); 40 } 41 CreateRenderNode()42RefPtr<RenderNode> RatingComponent::CreateRenderNode() 43 { 44 return RenderRating::Create(); 45 } 46 CreateElement()47RefPtr<Element> RatingComponent::CreateElement() 48 { 49 return AceType::MakeRefPtr<RatingElement>(); 50 } 51 SetThemeStyle(const RefPtr<RatingTheme> & theme)52void RatingComponent::SetThemeStyle(const RefPtr<RatingTheme>& theme) 53 { 54 if (!theme) { 55 return; 56 } 57 SetStarNum(theme->GetStarNum()); 58 SetStepSize(theme->GetStepSize()); 59 SetDefaultHeight(theme->GetRatingHeight()); 60 SetDesignedStarAspectRatio(theme->GetDesignedStarAspectRatio()); 61 SetFocusBorderWidth(theme->GetFocusBorderWidth()); 62 SetFocusBorderRadius(theme->GetFocusBorderRadius()); 63 SetHoverColor(theme->GetHoverColor()); 64 SetStarColorActive(theme->GetStarColorActive()); 65 SetStarColorInactive(theme->GetStarColorInactive()); 66 } 67 68 } // namespace OHOS::Ace 69