• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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: Resource[] = [];
33
34  aboutToAppear() {
35    Log.showInfo(TAG, 'aboutToAppear');
36    this.ringModeIcons[0] = $r("app.media.ic_statusbar_nfc");
37    ViewModel.initViewModel();
38  }
39
40  aboutToDisappear() {
41    Log.showInfo(TAG, 'aboutToDisappear');
42  }
43
44  build() {
45    Row() {
46      if (this.NFCModeComponentMode != NfcController.NfcState.STATE_OFF) {
47        Row().width(this.styleCommon.statusBarMarginLeftRight).height('100%')
48        Image(this.ringModeIcons[0])
49          .objectFit(ImageFit.Contain)
50          .width(this.style.statusBarRingModeWidth)
51          .height(this.style.statusBarRingModeHeight)
52          .fillColor(this.mTintContentInfo.contentColor)
53        Row().width(this.styleCommon.statusBarMarginLeftRight).height('100%')
54      }
55    }
56    .height('100%')
57    .opacity($r("app.float.icon_component_opacity"))
58  }
59}