MOBILE-2704 siteplugins: Don't show them in bottom tabs

main
dpalou 2018-11-09 14:51:05 +01:00
parent a5688bd1db
commit e74b87f076
4 changed files with 26 additions and 4 deletions

View File

@ -56,6 +56,10 @@ export class CoreMainMenuPage implements OnDestroy {
this.showTabs = true; this.showTabs = true;
this.subscription = this.menuDelegate.getHandlers().subscribe((handlers) => { this.subscription = this.menuDelegate.getHandlers().subscribe((handlers) => {
// Remove the handlers that should only appear in the More menu.
handlers = handlers.filter((handler) => {
return !handler.onlyInMore;
});
handlers = handlers.slice(0, CoreMainMenuProvider.NUM_MAIN_HANDLERS); // Get main handlers. handlers = handlers.slice(0, CoreMainMenuProvider.NUM_MAIN_HANDLERS); // Get main handlers.
// Re-build the list of tabs. If a handler is already in the list, use existing object to prevent re-creating the tab. // Re-build the list of tabs. If a handler is already in the list, use existing object to prevent re-creating the tab.

View File

@ -57,7 +57,19 @@ export class CoreMainMenuMorePage implements OnDestroy {
ionViewDidLoad(): void { ionViewDidLoad(): void {
// Load the handlers. // Load the handlers.
this.subscription = this.menuDelegate.getHandlers().subscribe((handlers) => { this.subscription = this.menuDelegate.getHandlers().subscribe((handlers) => {
this.handlers = handlers.slice(CoreMainMenuProvider.NUM_MAIN_HANDLERS); // Remove the main handlers. // Calculate the main handlers to not display them in this view.
const mainHandlers = handlers.filter((handler) => {
return !handler.onlyInMore;
}).slice(0, CoreMainMenuProvider.NUM_MAIN_HANDLERS);
// Get only the handlers that don't appear in the main view.
this.handlers = [];
handlers.forEach((handler) => {
if (mainHandlers.indexOf(handler) == -1) {
this.handlers.push(handler);
}
});
this.handlersLoaded = this.menuDelegate.areHandlersLoaded(); this.handlersLoaded = this.menuDelegate.areHandlersLoaded();
}); });
} }

View File

@ -88,6 +88,12 @@ export interface CoreMainMenuHandlerData {
* @type {any} * @type {any}
*/ */
pageParams?: any; pageParams?: any;
/**
* Whether the handler should only appear in More menu.
* @type {boolean}
*/
onlyInMore?: boolean;
} }
/** /**

View File

@ -25,8 +25,7 @@ export class CoreSitePluginsMainMenuHandler extends CoreSitePluginsBaseHandler i
protected initResult: any) { protected initResult: any) {
super(name); super(name);
// Set 699 as max priority so site plugins are always shown in the More tab (700 is Notifications tab). this.priority = handlerSchema.priority;
this.priority = Math.min(handlerSchema.priority, 699);
} }
/** /**
@ -45,7 +44,8 @@ export class CoreSitePluginsMainMenuHandler extends CoreSitePluginsBaseHandler i
component: this.plugin.component, component: this.plugin.component,
method: this.handlerSchema.method, method: this.handlerSchema.method,
initResult: this.initResult initResult: this.initResult
} },
onlyInMore: true
}; };
} }
} }