MOBILE-3814 menu: Check only width on menu to show menu on side

main
Pau Ferrer Ocaña 2022-03-15 11:18:48 +01:00
parent df1dba532f
commit 98018138b1
2 changed files with 6 additions and 18 deletions

View File

@ -22,6 +22,7 @@ import { CoreMainMenuDelegate, CoreMainMenuHandlerToDisplay } from './mainmenu-d
import { Device, makeSingleton } from '@singletons'; import { Device, makeSingleton } from '@singletons';
import { CoreArray } from '@singletons/array'; import { CoreArray } from '@singletons/array';
import { CoreTextUtils } from '@services/utils/text'; import { CoreTextUtils } from '@services/utils/text';
import { CoreScreen } from '@services/screen';
declare module '@singletons/events' { declare module '@singletons/events' {
@ -47,12 +48,6 @@ export class CoreMainMenuProvider {
static readonly MORE_PAGE_NAME = 'more'; static readonly MORE_PAGE_NAME = 'more';
static readonly MAIN_MENU_HANDLER_BADGE_UPDATED = 'main_menu_handler_badge_updated'; 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. * Get the current main menu handlers.
* *
@ -227,7 +222,7 @@ export class CoreMainMenuProvider {
if (!this.isResponsiveMainMenuItemsDisabledInCurrentSite() && window && window.innerWidth) { if (!this.isResponsiveMainMenuItemsDisabledInCurrentSite() && window && window.innerWidth) {
let numElements: number; let numElements: number;
if (this.tablet) { if (CoreScreen.isTablet) {
// Tablet, menu will be displayed vertically. // Tablet, menu will be displayed vertically.
numElements = Math.floor(window.innerHeight / CoreMainMenuProvider.ITEM_MIN_WIDTH); numElements = Math.floor(window.innerHeight / CoreMainMenuProvider.ITEM_MIN_WIDTH);
} else { } else {
@ -250,20 +245,13 @@ export class CoreMainMenuProvider {
* @return Tabs placement including side value. * @return Tabs placement including side value.
*/ */
getTabPlacement(): 'bottom' | 'side' { getTabPlacement(): 'bottom' | 'side' {
const tablet = !!(window.innerWidth && window.innerWidth >= 576 && (window.innerHeight >= 576 || return CoreScreen.isTablet ? 'side' : 'bottom';
((CoreApp.isKeyboardVisible() || CoreApp.isKeyboardOpening()) && window.innerHeight >= 200)));
if (tablet != this.tablet) {
this.tablet = tablet;
}
return tablet ? 'side' : 'bottom';
} }
/** /**
* Check if a certain page is the root of a main menu tab. * 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. * @return Promise resolved with boolean: whether it's the root of a main menu tab.
*/ */
async isMainMenuTab(pageName: string): Promise<boolean> { async isMainMenuTab(pageName: string): Promise<boolean> {
@ -277,7 +265,7 @@ export class CoreMainMenuProvider {
/** /**
* Check if a certain page is the root of a main menu handler currently displayed. * 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. * @return Promise resolved with boolean: whether it's the root of a main menu handler.
*/ */
async isCurrentMainMenuHandler(pageName: string): Promise<boolean> { async isCurrentMainMenuHandler(pageName: string): Promise<boolean> {

View File

@ -437,7 +437,7 @@ export class CoreAppProvider {
/** /**
* Set keyboard shown or hidden. * 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 { protected setKeyboardShown(shown: boolean): void {
this.isKeyboardShown = shown; this.isKeyboardShown = shown;