• 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, { StartsBarLocationComponentStyle } from '../common/StyleConfiguration';
21import Constants from '../common/Constants';
22import ViewModel from '../viewmodel/LocationVM';
23
24const TAG = 'location-StatusBarIconItemLocationComponent';
25
26@Component
27export default struct StatusBarIconItemLocationComponent {
28  @StorageLink('LocationVM_LocationData') LocationServiceUseStatus: boolean = false;
29  @State mTintContentInfo: TintContentInfo = ViewModel.getTintContentInfo();
30  @State style: StartsBarLocationComponentStyle = StyleConfiguration.getStartsBarLocationComponentStyle();
31  @State styleCommon: CommonStyle = StyleConfigurationCommon.getCommonStyle();
32
33  aboutToAppear() {
34    Log.showInfo(TAG, 'aboutToAppear');
35    ViewModel.initViewModel();
36  }
37
38  aboutToDisappear() {
39    Log.showInfo(TAG, 'aboutToDisappear');
40  }
41
42  build() {
43    Row() {
44      if (this.LocationServiceUseStatus) {
45        Row().width(this.styleCommon.statusBarMarginLeftRight).height('100%')
46        Image($r("app.media.ic_statusbar_gps"))
47          .objectFit(ImageFit.Contain)
48          .width(this.style.statusBarLocationWidth)
49          .height(this.style.statusBarLocationHeight)
50          .fillColor(this.mTintContentInfo.contentColor)
51        Row().width(this.styleCommon.statusBarMarginLeftRight).height('100%')
52      }
53    }
54    .height('100%')
55    .opacity($r("app.float.icon_component_opacity"))
56  }
57}