diff --git a/src/core/features/mainmenu/services/mainmenu.ts b/src/core/features/mainmenu/services/mainmenu.ts index f1c09fef0..a27b4e943 100644 --- a/src/core/features/mainmenu/services/mainmenu.ts +++ b/src/core/features/mainmenu/services/mainmenu.ts @@ -22,6 +22,7 @@ import { CoreMainMenuDelegate, CoreMainMenuHandlerToDisplay } from './mainmenu-d import { Device, makeSingleton } from '@singletons'; import { CoreArray } from '@singletons/array'; import { CoreTextUtils } from '@services/utils/text'; +import { CoreScreen } from '@services/screen'; declare module '@singletons/events' { @@ -47,12 +48,6 @@ export class CoreMainMenuProvider { static readonly MORE_PAGE_NAME = 'more'; static readonly MAIN_MENU_HANDLER_BADGE_UPDATED = 'main_menu_handler_badge_updated'; - protected tablet = false; - - constructor() { - this.tablet = !!(window?.innerWidth && window.innerWidth >= 576 && window.innerHeight >= 576); - } - /** * Get the current main menu handlers. * @@ -227,7 +222,7 @@ export class CoreMainMenuProvider { if (!this.isResponsiveMainMenuItemsDisabledInCurrentSite() && window && window.innerWidth) { let numElements: number; - if (this.tablet) { + if (CoreScreen.isTablet) { // Tablet, menu will be displayed vertically. numElements = Math.floor(window.innerHeight / CoreMainMenuProvider.ITEM_MIN_WIDTH); } else { @@ -250,20 +245,13 @@ export class CoreMainMenuProvider { * @return Tabs placement including side value. */ getTabPlacement(): 'bottom' | 'side' { - const tablet = !!(window.innerWidth && window.innerWidth >= 576 && (window.innerHeight >= 576 || - ((CoreApp.isKeyboardVisible() || CoreApp.isKeyboardOpening()) && window.innerHeight >= 200))); - - if (tablet != this.tablet) { - this.tablet = tablet; - } - - return tablet ? 'side' : 'bottom'; + return CoreScreen.isTablet ? 'side' : 'bottom'; } /** * Check if a certain page is the root of a main menu tab. * - * @param page Name of the page. + * @param pageName Name of the page. * @return Promise resolved with boolean: whether it's the root of a main menu tab. */ async isMainMenuTab(pageName: string): Promise { @@ -277,7 +265,7 @@ export class CoreMainMenuProvider { /** * Check if a certain page is the root of a main menu handler currently displayed. * - * @param page Name of the page. + * @param pageName Name of the page. * @return Promise resolved with boolean: whether it's the root of a main menu handler. */ async isCurrentMainMenuHandler(pageName: string): Promise { diff --git a/src/core/services/app.ts b/src/core/services/app.ts index 4ab97df7f..cedb147db 100644 --- a/src/core/services/app.ts +++ b/src/core/services/app.ts @@ -437,7 +437,7 @@ export class CoreAppProvider { /** * Set keyboard shown or hidden. * - * @param Whether the keyboard is shown or hidden. + * @param shown Whether the keyboard is shown or hidden. */ protected setKeyboardShown(shown: boolean): void { this.isKeyboardShown = shown;