1 /* 2 * Copyright (c) 2025 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 "bridge/declarative_frontend/ark_theme/theme_apply/js_theme.h" 17 18 #include "bridge/declarative_frontend/jsview/js_view_abstract.h" 19 20 namespace OHOS::Ace::Framework { SetColors(const JSRef<JSArray> & colors)21void JSThemeColors::SetColors(const JSRef<JSArray>& colors) 22 { 23 for (int i = 0; i < COLORS_NUMBER; i++) { 24 RefPtr<ResourceObject> resObj; 25 Color value; 26 JSViewAbstract::ParseJsColor(colors->GetValueAt(i), value, resObj); 27 if (resObj && colors->GetValueAt(i)->IsObject()) { 28 JSRef<JSObject> jsObj = JSRef<JSObject>::Cast(colors->GetValueAt(i)); 29 JSViewAbstract::CompleteResourceObject(jsObj); 30 resObj = JSViewAbstract::GetResourceObject(jsObj); 31 } 32 ResourceValue resValue = { resObj, value }; 33 colors_.push_back(resValue); 34 } 35 } 36 37 } // namespace OHOS::Ace::Framework 38