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 StyleConfigurationCommon, { CommonStyle 19} from '../../../../../../../../common/src/main/ets/default/StyleConfiguration'; 20import StyleConfiguration, { StatusRingModeComponentStyle } from '../common/StyleConfiguration'; 21import NfcController from '@ohos.nfc.controller'; 22import ViewModel from '../viewmodel/NFCModeVM'; 23 24const TAG = 'nfcmode-StatusBarIconItemNFCModeComponent'; 25 26@Component 27export default struct StatusBarIconItemNFCModeComponent { 28 @StorageLink('NFCModeComponentMode') NFCModeComponentMode: NfcController.NfcState = NfcController.NfcState.STATE_OFF; 29 @State mTintContentInfo: TintContentInfo = ViewModel.getTintContentInfo(); 30 @State styleCommon: CommonStyle = StyleConfigurationCommon.getCommonStyle(); 31 @State style: StatusRingModeComponentStyle = StyleConfiguration.getStatusRingModeComponentStyle(); 32 private ringModeIcons: any; 33 34 aboutToAppear() { 35 Log.showInfo(TAG, 'aboutToAppear'); 36 this.ringModeIcons = {}; 37 this.ringModeIcons['0'] = $r("app.media.ic_statusbar_nfc"); 38 ViewModel.initViewModel(); 39 } 40 41 aboutToDisappear() { 42 Log.showInfo(TAG, 'aboutToDisappear'); 43 } 44 45 build() { 46 Row() { 47 if (this.NFCModeComponentMode != NfcController.NfcState.STATE_OFF) { 48 Row().width(this.styleCommon.statusBarMarginLeftRight).height('100%') 49 Image(this.ringModeIcons['0']) 50 .objectFit(ImageFit.Contain) 51 .width(this.style.statusBarRingModeWidth) 52 .height(this.style.statusBarRingModeHeight) 53 .fillColor(this.mTintContentInfo.contentColor) 54 Row().width(this.styleCommon.statusBarMarginLeftRight).height('100%') 55 } 56 } 57 .height('100%') 58 .opacity($r("app.float.icon_component_opacity")) 59 } 60}