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 OHOS_ACELITE_QRCODE_COMPONENT_H 17 #define OHOS_ACELITE_QRCODE_COMPONENT_H 18 19 #include "acelite_config.h" 20 21 #if (FEATURE_COMPONENT_QRCODE == 1) 22 #include "component.h" 23 #include "key_parser.h" 24 #include "non_copyable.h" 25 #include "ui_qrcode.h" 26 27 namespace OHOS { 28 namespace ACELite { 29 class QrcodeComponent final : public Component { 30 public: 31 ACE_DISALLOW_COPY_AND_MOVE(QrcodeComponent); 32 QrcodeComponent() = delete; 33 QrcodeComponent(jerry_value_t options, jerry_value_t children, AppStyleManager *manager); ~QrcodeComponent()34 ~QrcodeComponent() override {} 35 void ReleaseNativeViews() override; 36 37 protected: GetComponentRootView()38 UIView *GetComponentRootView() const override 39 { 40 return (const_cast<UIQrcode *>(&qrcode_)); 41 } 42 bool ApplyPrivateStyle(const AppStyleItem *style) override; 43 void OnViewAttached() override; 44 void PostUpdate(uint16_t attrKeyId) override; 45 bool SetPrivateAttribute(uint16_t attrKeyId, jerry_value_t attrValue) override; 46 47 private: 48 bool SetColor(const AppStyleItem &style, ColorType &colortype); 49 void DrawQrcode(); 50 51 UIQrcode qrcode_; 52 char *qrcodeValue_; 53 ColorType qrcodeBackGroundColor_; 54 ColorType qrcodeColor_; 55 56 static constexpr uint16_t QRCODE_VAL_MAX = 256; 57 }; 58 } // namespace ACELite 59 } // namespace OHOS 60 #endif // #ifdef FEATURE_COMPONENT_QRCODE 61 #endif // OHOS_ACELITE_QRCODE_COMPONENT_H 62