MOBILE-3320 core: Fix hide tabs issues in SCORM and H5P

main
Dani Palou 2021-06-16 12:09:05 +02:00
parent d67fd93b92
commit cbb69db301
4 changed files with 78 additions and 8 deletions

View File

@ -80,6 +80,7 @@ export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActiv
hasOffline = false;
isOpeningPage = false;
protected listeningResize = false;
protected fetchContentDefaultError = 'addon.mod_h5pactivity.errorgetactivity';
protected syncEventName = AddonModH5PActivitySyncProvider.AUTO_SYNCED;
protected site: CoreSite;
@ -372,8 +373,7 @@ export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActiv
CoreCourse.checkModuleCompletion(this.courseId, this.module.completiondata);
window.addEventListener('resize', this.contentResized.bind(this));
this.contentResized();
this.setResizeListener();
}
/**
@ -488,6 +488,19 @@ export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActiv
}
}
/**
* Set the resize listener if needed.
*/
setResizeListener(): void {
if (!this.playing || this.listeningResize) {
return;
}
this.listeningResize = true;
window.addEventListener('resize', this.contentResized.bind(this));
this.contentResized();
}
/**
* On content resize, change visibility of the main menu: show on portrait and hide on landscape.
*/
@ -495,6 +508,25 @@ export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActiv
this.mainMenuPage.changeVisibility(Platform.isPortrait());
}
/**
* @inheritdoc
*/
ionViewDidEnter(): void {
this.setResizeListener();
}
/**
* @inheritdoc
*/
ionViewWillLeave(): void {
this.mainMenuPage.changeVisibility(true);
if (this.listeningResize) {
this.listeningResize = false;
window.removeEventListener('resize', this.resizeFunction);
}
}
/**
* Component destroyed.
*/
@ -503,10 +535,6 @@ export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActiv
this.observer?.off();
window.removeEventListener('message', this.messageListenerFunction);
if (this.playing) {
window.removeEventListener('resize', this.resizeFunction);
}
}
}

View File

@ -533,6 +533,22 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy {
}));
}
/**
* @inheritdoc
*/
ionViewDidEnter(): void {
if (this.scorm && this.scorm.popup) {
this.mainMenuPage.changeVisibility(false);
}
}
/**
* @inheritdoc
*/
ionViewWillLeave(): void {
this.mainMenuPage.changeVisibility(true);
}
/**
* Component being destroyed.
*/
@ -549,8 +565,6 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy {
this.goOfflineObserver?.off();
}, 500);
this.mainMenuPage.changeVisibility(true);
// Unblock the SCORM so it can be synced.
CoreSync.unblockOperation(AddonModScormProvider.COMPONENT, this.scorm.id, 'player');
}

View File

@ -64,4 +64,18 @@ export class CoreCourseModuleMainActivityPage<ActivityType extends CoreCourseMod
this.activityComponent?.ionViewDidLeave();
}
/**
* User will enter the page.
*/
ionViewWillEnter(): void {
this.activityComponent?.ionViewWillEnter();
}
/**
* User will leave the page.
*/
ionViewWillLeave(): void {
this.activityComponent?.ionViewWillLeave();
}
}

View File

@ -452,4 +452,18 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy,
this.isCurrentView = false;
}
/**
* User will enter the page that contains the component. This function should be called by the page that contains the component.
*/
ionViewWillEnter(): void {
// To be overridden.
}
/**
* User will leave the page that contains the component. This function should be called by the page that contains the component.
*/
ionViewWillLeave(): void {
// To be overridden.
}
}