• 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 {ScreenLockStatus} from '../../../../../../../../../common/src/main/ets/default/ScreenLockCommon'
18import ViewModel from '../../vm/lockIconViewModel'
19import Constants from '../../common/constants'
20
21const TAG = 'ScreenLock-LockIcon'
22
23@Component
24export default struct LockIcon {
25  @StorageLink('lockStatus') @Watch("onStatusChange") lockStatus: ScreenLockStatus = ScreenLockStatus.Locking
26  @State mViewModel: ViewModel = new ViewModel()
27
28  aboutToAppear() {
29    Log.showInfo(TAG, `aboutToAppear`)
30    this.mViewModel.ViewModelInit()
31  }
32
33  build() {
34    Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
35      Image(this.mViewModel.iconPath)
36        .margin({ top: $r('app.float.lockicon_top_margin'), bottom: $r('app.float.lockicon_bottom_margin') })
37        .objectFit(ImageFit.Contain)
38        .width($r('app.float.lockicon_width'))
39        .height($r('app.float.lockicon_height'))
40        .fillColor($r('app.color.lock_ic_color'))
41      Text(this.mViewModel.cutMessage).fontSize($r('app.float.lock_prompt_fontsize'))
42        .fontColor($r('app.color.lock_prompt_color'))
43        .margin({ top: $r("app.float.lock_Text_top_margin") })
44    }
45    .width(Constants.FULL_CONTAINER_WIDTH)
46    .gesture(GestureGroup(GestureMode.Exclusive, TapGesture({ count: 2 })
47      .onAction((event: GestureEvent) => {
48        Log.showInfo(TAG, 'double click');
49        this.mViewModel.onRecognizeFace(this.lockStatus);
50      })
51    ))
52  }
53
54  onStatusChange(propName: string): void {
55    Log.showInfo(TAG, `lockStatus:${this.lockStatus}`);
56    this.mViewModel.onStatusChange(this.lockStatus)
57  }
58}