@shopgate/pwa-common
Version:
Common library for the Shopgate Connect PWA.
19 lines • 1.42 kB
JavaScript
import hideMenuBar from'@shopgate/pwa-core/commands/hideMenuBar';import broadcastEvent from'@shopgate/pwa-core/commands/broadcastEvent';import showTab from'@shopgate/pwa-core/commands/showTab';/**
* Page context that comes from the app.
* @type {Object}
*/var currentPageContext={};/**
* Get Page context if available.
* @returns {Object}
*/export var getPageContext=function getPageContext(){return currentPageContext;};/**
* Prepares the NavigationBar and the MenuBar of the app legacy part for the PWA.
*/export var prepareLegacyNavigation=function prepareLegacyNavigation(){/**
* Broadcasts an event to the pwa_navigation_bar webview and updates the navigation bar with
* type "none". Event parameters are defined accordingly to the specification of the native
* updateNavigationBar event.
*/broadcastEvent({event:'updateNavigationBar',parameters:['','none',{type:'none'}]});hideMenuBar({animation:null});};/**
* Shows the main tab when legacy system requests the previous tab.
* @param {Object} context The page context from the app.
* @param {string} context.tab The tab where the page is opened.
*/export var pageContext=function pageContext(context){currentPageContext=context;};/**
* Shows the main tab when legacy system requests the previous tab.
*/export var showPreviousTab=function showPreviousTab(){showTab({targetTab:currentPageContext.tab?currentPageContext.tab:'main'});};