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 Accounts from '../../../../../../features/screenlock/src/main/ets/com/ohos/view/component/accounts' 18import DateTime from '../../../../../../features/datetimecomponent/src/main/ets/com/ohos/view/component/dateTime' 19import BatterySoc from '../../../../../../features/screenlock/src/main/ets/com/ohos/view/component/batterySoc' 20import LockIcon from '../../../../../../features/screenlock/src/main/ets/com/ohos/view/component/lockIcon' 21import Wallpaper from '../../../../../../features/wallpapercomponent/src/main/ets/com/ohos/view/component/wallpaper' 22import NotificationListComponent from '../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/view/NotificationListComponent' 23import StatusBar from '../../../../../../features/screenlock/src/main/ets/com/ohos/view/component/statusBar' 24import Shortcut from '../../../../../../features/shortcutcomponent/src/main/ets/com/ohos/view/component/shortcut' 25import Constants from '../common/constants' 26import ViewModel from '../vm/slideScreenLockViewModel' 27 28const TAG = 'ScreenLock-SlideScreenlock' 29 30@Component 31export default struct SlideScreenlock { 32 @State mViewModel: ViewModel = new ViewModel() 33 @StorageLink('batteryCharging') @Watch('onCharging') batteryCharging: boolean = false 34 @Prop @Watch("onStatusChange") pageStatus: number 35 @StorageLink('deviceStatus') @Watch('onDeviceStatusChange') deviceStatus: string = "" 36 @StorageLink('isWallpaperShow') isWallpaperShow: boolean = true 37 @StorageLink('screenlockdirection') screenlockdirection: number = 1 38 private mHeightPx : number = 44 39 40 aboutToAppear() { 41 Log.showInfo(TAG, `aboutToAppear`) 42 this.mViewModel.ViewModelInit() 43 } 44 45 aboutToDisappear() { 46 Log.showInfo(TAG, `aboutToDisAppear`) 47 } 48 49 onPageShow() { 50 Log.showInfo(TAG, `onPageShow`) 51 } 52 53 onPageHide() { 54 Log.showInfo(TAG, `onPageHide`) 55 } 56 57 build() { 58 Stack({ alignContent: Alignment.Bottom }) { 59 Column() { 60 Wallpaper() 61 } 62 .backgroundColor($r('app.color.screenlock_backgroundcolor')) 63 .width(Constants.FULL_CONTAINER_WIDTH) 64 .height(Constants.FULL_CONTAINER_HEIGHT) 65 .scale({ 66 x: this.mViewModel.backgroundScale, 67 y: this.mViewModel.backgroundScale 68 }) 69 .animation({ 70 duration: this.mViewModel.duration, // animation duration 71 curve: Curve.Linear, // animation curve 72 delay: 0, // animation delay 73 iterations: 1, // times of play 74 playMode: PlayMode.Normal // animation mode 75 }) 76 77 Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start }) { 78 Column() { 79 StatusBar() 80 } 81 .height(this.mHeightPx + 'px' ) 82 } 83 84 Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start }) { 85 Column() { 86 } 87 .height($r('app.float.status_bar_height')) 88 89 Column() { 90 Row() { 91 Shortcut() 92 Blank() 93 Accounts() 94 } 95 .width(Constants.NOTIFICATION_AREA_WIDTH) 96 .height(this.screenlockdirection == 1 ? $r('app.float.shortcut_area_height'):$r('app.float.shortcut_area_height_portrait')) 97 } 98 .margin({ top: $r('app.float.shortcut_area_margin_top') }) 99 100 Column() { 101 LockIcon() 102 }.height($r('app.float.lockicon_area_height')) 103 104 Column() { 105 DateTime({ isShowDate: !this.mViewModel.toggleShow }) 106 if (this.mViewModel.toggleShow) { 107 Column() { 108 BatterySoc() 109 }.height($r('app.float.batterysoc_area_height')) 110 } 111 }.height($r('app.float.datetime_area_height')) 112 .margin({ top: $r('app.float.datetime_margin_top') }) 113 114 Column() { 115 NotificationListComponent() 116 } 117 .alignItems(HorizontalAlign.Center) 118 .width(Constants.NOTIFICATION_LIST_AREA_WIDTH) 119 .height(Constants.NOTIFICATION_LIST_AREA_HEIGHT) 120 .margin({ top: $r('app.float.notificationList_margin_top') }) 121 } 122 .width(Constants.FULL_CONTAINER_WIDTH) 123 .height(Constants.FULL_CONTAINER_HEIGHT) 124 .opacity(this.mViewModel.elementAlpha) 125 .scale({ 126 x: this.mViewModel.elementScale, 127 y: this.mViewModel.elementScale 128 }) 129 .animation({ 130 duration: this.mViewModel.duration, // animation duration 131 curve: Curve.Linear, // animation curve 132 delay: 0, // animation delay 133 iterations: 1, // times of play 134 playMode: PlayMode.Normal // animation mode 135 }) 136 .onTouch((event) => { 137 this.mViewModel.touchEvent(event) 138 }) 139 } 140 } 141 142 onCharging(propName: string): void { 143 Log.showInfo(TAG, `onCharging ${this.batteryCharging}`) 144 this.mViewModel.toggleDisplay(this.batteryCharging); 145 } 146 147 onStatusChange(propName: string): void { 148 Log.showInfo(TAG, `onStatusChange ${this.pageStatus}`) 149 switch (this.pageStatus) { 150 case Constants.STATUS_ON_PAGE_SHOW: 151 this.mViewModel.onPageShow(); 152 break; 153 default: 154 } 155 } 156 157 onDeviceStatusChange(propName: string): void{ 158 Log.showInfo(TAG, `onDeviceStatusChange ${this.deviceStatus}`) 159 if (this.deviceStatus == "endScreenOn") { 160 if (this.batteryCharging) { 161 this.mViewModel.toggleDisplay(this.batteryCharging); 162 } 163 } 164 } 165}