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 #include "bridge/declarative_frontend/jsview/models/qrcode_model_impl.h" 17 18 #include "bridge/declarative_frontend/view_stack_processor.h" 19 #include "core/components/qrcode/qrcode_component.h" 20 21 namespace OHOS::Ace::Framework { Create(const std::string & value)22void QRCodeModelImpl::Create(const std::string& value) 23 { 24 RefPtr<QrcodeComponent> qrcode = AceType::MakeRefPtr<OHOS::Ace::QrcodeComponent>(); 25 qrcode->SetValue(value); 26 qrcode->SetQrcodeColor(Color::BLACK); 27 qrcode->SetBackgroundColor(Color::WHITE); 28 ViewStackProcessor::GetInstance()->ClaimElementId(qrcode); 29 ViewStackProcessor::GetInstance()->Push(qrcode); 30 } 31 SetQRCodeColor(const Color & color)32void QRCodeModelImpl::SetQRCodeColor(const Color& color) 33 { 34 auto qrcode = AceType::DynamicCast<QrcodeComponent>(ViewStackProcessor::GetInstance()->GetMainComponent()); 35 if (qrcode) { 36 qrcode->SetQrcodeColor(color); 37 } 38 } 39 SetQRBackgroundColor(const Color & color)40void QRCodeModelImpl::SetQRBackgroundColor(const Color& color) 41 { 42 auto qrcode = AceType::DynamicCast<QrcodeComponent>(ViewStackProcessor::GetInstance()->GetMainComponent()); 43 if (qrcode) { 44 qrcode->SetBackgroundColor(color); 45 } 46 } 47 } // namespace OHOS::Ace::Framework