mirror of
https://gitee.com/openharmony/applications_screenlock
synced 2024-11-23 06:19:47 +00:00
support show/hide Wallpaper component when window show/hide
Signed-off-by: yangpeng85 <yangpeng85@huawei.com>
This commit is contained in:
parent
d26ed0c0c5
commit
b34b7c47dc
@ -67,6 +67,7 @@ export default class ScreenLockModel {
|
||||
}
|
||||
|
||||
showScreenLockWindow(callback: Callback<void>) {
|
||||
AppStorage.SetOrCreate('isWallpaperShow', true);
|
||||
windowManager.find(Constants.WIN_NAME).then((win) => {
|
||||
win.show().then(() => {
|
||||
Log.showInfo(TAG, `window show`);
|
||||
@ -82,6 +83,7 @@ export default class ScreenLockModel {
|
||||
win.hide().then(() => {
|
||||
Log.showInfo(TAG, `window hide`);
|
||||
callback();
|
||||
AppStorage.SetOrCreate('isWallpaperShow', false);
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -24,12 +24,17 @@ export default struct Wallpaper {
|
||||
@State mViewModel: ViewModel = new ViewModel()
|
||||
|
||||
aboutToAppear() {
|
||||
Log.showInfo(TAG, `aboutToAppear`)
|
||||
Log.showInfo(TAG, "aboutToAppear")
|
||||
this.mViewModel.ViewModelInit()
|
||||
}
|
||||
|
||||
aboutToDisappear() {
|
||||
Log.showInfo(TAG, "aboutToDisappear")
|
||||
this.mViewModel.ViewModelDestroy()
|
||||
}
|
||||
|
||||
build() {
|
||||
Image(this.mViewModel.screenlockWallpaper)
|
||||
Image(this.mViewModel.getWallpaperData())
|
||||
.width(Constants.FULL_CONTAINER_WIDTH)
|
||||
.height(Constants.FULL_CONTAINER_HEIGHT)
|
||||
.objectFit(ImageFit.Cover)
|
||||
|
@ -13,19 +13,29 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import image from '@ohos.multimedia.image';
|
||||
import WallpaperMar from '@ohos.wallpaper'
|
||||
import Log from '../../../../../../../../common/src/main/ets/default/Log'
|
||||
|
||||
const TAG = 'ScreenLock-WallpaperViewModel'
|
||||
|
||||
export default class WallpaperViewModel {
|
||||
screenlockWallpaper: string = ''
|
||||
private wallpaperData: image.PixelMap = undefined
|
||||
|
||||
ViewModelInit(): void{
|
||||
Log.showDebug(TAG, 'ViewModelInit');
|
||||
ViewModelInit(): void {
|
||||
Log.showDebug(TAG, "ViewModelInit");
|
||||
this.getScreenLockWallpaper()
|
||||
}
|
||||
|
||||
ViewModelDestroy(): void {
|
||||
Log.showDebug(TAG, "ViewModelDestroy");
|
||||
this.freeScreenLockWallpaper();
|
||||
}
|
||||
|
||||
getWallpaperData() {
|
||||
return this.wallpaperData;
|
||||
}
|
||||
|
||||
private getScreenLockWallpaper() {
|
||||
Log.showInfo(TAG, 'getScreenLockWallpaper');
|
||||
WallpaperMar.getPixelMap(WallpaperMar.WallpaperType.WALLPAPER_LOCKSCREEN, (error, data) => {
|
||||
@ -33,8 +43,20 @@ export default class WallpaperViewModel {
|
||||
Log.showError(TAG, 'getScreenLockWallpaper error:' + JSON.stringify(error));
|
||||
} else {
|
||||
Log.showDebug(TAG, 'getScreenLockWallpaper data:' + JSON.stringify(data));
|
||||
this.screenlockWallpaper = data
|
||||
this.wallpaperData = data
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private freeScreenLockWallpaper() {
|
||||
Log.showInfo(TAG, 'free ScreenLockWallpaper');
|
||||
if (typeof this.wallpaperData === 'undefined' || this.wallpaperData == null) {
|
||||
return;
|
||||
}
|
||||
this.wallpaperData.release().then(() => {
|
||||
Log.showDebug(TAG, 'release succeed');
|
||||
}).catch((err) => {
|
||||
Log.showDebug(TAG, `release failed ${err}`);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import Trace from '../../../../../../common/src/main/ets/default/Trace'
|
||||
import Log from '../../../../../../common/src/main/ets/default/Log'
|
||||
import Accounts from '../../../../../../features/screenlock/src/main/ets/com/ohos/view/component/accounts'
|
||||
import DateTime from '../../../../../../features/datetimecomponent/src/main/ets/com/ohos/view/component/dateTime'
|
||||
@ -34,6 +33,7 @@ export default struct SlideScreenlock {
|
||||
@StorageLink('batteryCharging') @Watch('onCharging') batteryCharging: boolean = false
|
||||
@Prop @Watch("onStatusChange") pageStatus: number
|
||||
@StorageLink('deviceStatus') @Watch('onDeviceStatusChange') deviceStatus: string = ""
|
||||
@StorageLink('isWallpaperShow') isWallpaperShow: boolean = true
|
||||
private mHeightPx : number = 44
|
||||
|
||||
aboutToAppear() {
|
||||
@ -56,7 +56,9 @@ export default struct SlideScreenlock {
|
||||
build() {
|
||||
Stack({ alignContent: Alignment.Bottom }) {
|
||||
Column() {
|
||||
Wallpaper()
|
||||
if (this.isWallpaperShow === true) {
|
||||
Wallpaper()
|
||||
}
|
||||
}
|
||||
.width(Constants.FULL_CONTAINER_WIDTH)
|
||||
.height(Constants.FULL_CONTAINER_HEIGHT)
|
||||
|
Loading…
Reference in New Issue
Block a user