1/* 2 * Copyright (c) 2021-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 16import Log from '../../../../../../../../common/src/main/ets/default/Log'; 17import { TintContentInfo } from '../../../../../../../../common/src/main/ets/default/TintStateManager'; 18import { PluginComponentData } from "../../../../../../../../common/src/main/ets/plugindatasource/common/Constants"; 19import ViewModel from '../viewmodel/ControlCenterVM'; 20import StyleConfiguration from '../../../../../../../../common/src/main/ets/template/common/StyleConfiguration'; 21 22const TAG = 'PluginIconItemComponent'; 23 24@Component 25export default struct PluginIconItemComponent { 26 private keyId: string = ''; 27 private mEditMode: boolean = false; 28 private mDragMode: boolean = false; 29 @State @Watch('onPluginDataChange') mPluginData: PluginComponentData = new PluginComponentData(); 30 31 aboutToAppear() { 32 Log.showInfo(TAG, `aboutToAppear Start, keyId: ${this.keyId}`); 33 this.linkItemData(); 34 35 } 36 37 aboutToDisappear() { 38 Log.showInfo(TAG, `aboutToDisappear`); 39 } 40 41 linkItemData() { 42 Log.showInfo(TAG, `linkItemData, keyId: ${this.keyId}`); 43 this.mPluginData = ViewModel.getPluginData(this.keyId); 44 } 45 46 onPluginDataChange(propName: string): void { 47 Log.showInfo(TAG, `onPluginDataChange, propName: ${propName} template: ${JSON.stringify(this.mPluginData.template)} data: ${JSON.stringify(this.mPluginData.data)}`); 48 } 49 50 build() { 51 Row() { 52 if (this.mPluginData.template && this.mPluginData.data && Object.keys(this.mPluginData.data).length > 0) { 53 PluginComponent({ 54 template: this.mPluginData.template, 55 data: this.mPluginData.data 56 }).onComplete(() => { 57 Log.showInfo(TAG, `PluginComponent.Complete`) 58 }).onError((error) => { 59 Log.showInfo(TAG, `PluginComponent.Error code:${error.errcode} message:${error.msg}`) 60 }) 61 .size({ width: '100%', height: '100%' }) 62 } 63 }.height('100%') 64 } 65}