Sencha Touch 2: loading view from button tap doesn't have bottom Tab bar and back button at the title bar

StackOverflow https://stackoverflow.com/questions/18362967

  •  26-06-2022
  •  | 
  •  

Question

I'm new to sencha and having a problem with tab bar. My first view has 2 buttons and a list below it. tapping any item list navigates to detail view and that view shows the bottom tab bar which has 4 icon and it has a back button that goes back to the homeContent view.

Now when I tap on readyButton in homeContent.js , I want to navigate to ReadyScreenView.js. It is doing that now, however I don't have the back button at the top of this screen, and it doesn't have a tab bar.

How can I make sure all the views has a tab bar and a back button that goes back to the previous screen. If I select the bottom bar icons, it navigates fine and tab bar remains. Only if the navigation is done by a button click, I don't see the bottom tab bar and back button. Any help would be highly appreciated.

main.js

Ext.define('COSD.view.Main', {
extend: 'Ext.tab.Panel',
requires: [
    'Ext.TitleBar',
],
config: {
    tabBarPosition: 'bottom',
    layout:'card',

    items: [

       {
        xtype:'homeContainer'
       },
       {
        xtype:'readyscreenview'
       },
       {
        xtype:'emergencyscreenview'
       },
       {
        xtype:'allnews'
       }

    ]
}
});

homeContainer.js

Ext.define('COSD.view.HomeContainer',{
extend:'Ext.NavigationView',
xtype:'homeContainer',
config:{
    title:'Home',
    iconCls:'home',


    scrollable:true,
    styleHtmlContent:true,
    styleHTMLCls:'home',
    html:[].join(""),

    items:[


        {
            xtype:'newsContent'
        }
    ]

}

})

homeContent.js

Ext.define('COSD.view.HomeContent',{
extend:'Ext.Panel',
xtype:'newsContent',
config:{
    title:'San Diego County Emergency ',
    iconCls:'home',
    cls:'toolbar',
    layout:'vbox',

    items:[

            {

                xtype: 'button',
                id:'readyButton',
                  style:'border-radius:0',
                  cls:'ReadyImageButton',
                pressedCls:'ReadyImageButtonSelected',


    html:'<div class="mainbutton-container-green"> <div class="mainbutton-thumb"><img src="resources/images/AppHome_ReadyIcon-Default Platform.png" /></div><div class="mainbutton-content"><i> <h3 class="mainbutton-title">ReadySanDiego</h3><p>Plan, Prepare </p></i></div></div>',

           },
           {

                xtype: 'button',
                id:'emergencyButton',
                  style:'border-radius:0',
                  cls:'EmergencyImageButton',
               pressedCls:'EmergencyImageButtonSelected',

                html:'<div class="mainbutton-container-red"> <div class="mainbutton-thumb"><img src="resources/images/AppHome_EmergencyIcon-Default Platform.png" /></div><div class="mainbutton-content"><i> <h3 class="mainbutton-title">Emergency</h3><p>News, Maps, Shelters </p></i></div></div>',


           },
           { 

                xtype: 'label',
                cls:'NewsUpdate',
                html: 'News Updates'
            }, 
            { 

                xtype: 'label',
                cls:'LatestNews',
                //autoEl:{id:'timediv'}
                html: '<div id="timediv">Latest News | Refreshed: 8/2/2013 10:36:26 AM</div>'
            }, 

        {
                xtype:'list',
                id:'newslistContent',
                loadingText: "loading...",
                emptyText: '<div>No notes found.</div>',
                store:'HomeStore',
                itemTpl:'<div><p>{title}</p><p class="newsItemTitle">{publishedDate}</p></div>',
                 flex: 1,
            plugins: [
        {
            xclass: 'Ext.plugin.PullRefresh',
            pullRefreshText: 'Pull to refresh...',


        },
        {
            xclass: 'Ext.plugin.ListPaging',
            autoPaging: true,

        }
    ],
        }
    ]
}
})

ReadyButtonController.js

Ext.define('COSD.controller.ReadyButtonController', {
extend: 'Ext.app.Controller',

config: {
    control: {
        '#readyButton': {
            // On the tap event, call onNewTap
            tap: 'onNewTap'
        }
    },

},

launch: function() {
  },

onNewTap: function() {


                        Ext.Viewport.animateActiveItem({xtype: 'readyscreenview'},{type: 'slide',direction: 'left'});


}
});

ReadyScreenView.js

Ext.define('COSD.view.ReadyScreenView', {
extend: 'Ext.Container',
xtype:'readyscreenview',

config: {
    title:'Ready',
    iconCls:'home',
    layout: 'vbox',
    scrollable:true,
    styleHtmlContent:true,
    styleHTMLCls:'home',
    html:[].join(""),

    items:[

           {

                xtype:'titlebar',
                cls:'toolbarReady',
                title:'Ready',
                docked:'top',
                ui:'plain',
                style: {
                    color:'#FFFFFF',
                    fontSize:'12pt'
                    }
           }
           ,
            {

                xtype: 'button',
                id:'prepareDisaster',
                  style:'border-radius:0',
                  cls:'NavButtonListing',
                 pressedCls:'NavButtonListingSelected', 
                  //                    html:'<div class="listbutton-container"> <div class="listbutton-thumb"><img src="resources/images/CoSD_PrepareIcon-Default Platform.png"/></img></div><div class="listbutton-content"> <h3 class="listbutton-title">Prepare for Disasters</h3></div></div>',

                html:'<div class="ButtonListings-container"> <div class="ButtonListings-thumb"><img src="resources/images/CoSD_PrepareIcon-Default Platform.png" /></div><div class="ButtonListings-content"><h3 class="listbutton-title">Prepare for Disasters</h3></div></div>',

           },
           {

                xtype: 'button',
                id:'makeAPlan',
                style:'border-radius:0',
                cls:'NavButtonListing',
                pressedCls:'NavButtonListingSelected', 
                html:'<div class="ButtonListings-container"> <div class="ButtonListings-thumb"><img src="resources/images/CoSD_MakeAPlanIcon-Default Platform.png" /></div><div class="ButtonListings-content"><h3 class="listbutton-title">Make a Plan</h3></div></div>',

           },
           {

                xtype: 'button',
                id:'buildAKit',
                style:'border-radius:0',
                cls:'NavButtonListing',
                pressedCls:'NavButtonListingSelected',
                html:'<div class="ButtonListings-container"> <div class="ButtonListings-thumb"><img src="resources/images/CoSD_BuildAKitIcon-Default Platform.png" /></div><div class="ButtonListings-content"><h3 class="listbutton-title">Build a Kit</h3></div></div>',

           },
            {

                xtype: 'button',
                id:'stayInformed',
                style:'border-radius:0',
                cls:'NavButtonListing',
                pressedCls:'NavButtonListingSelected',
                html:'<div class="ButtonListings-container"> <div class="ButtonListings-thumb"><img src="resources/images/CoSD_StayInformedIcon-Default Platform.png" /></div><div class="ButtonListings-content"><h3 class="listbutton-title">Stay Informed</h3></div></div>',

           },
              {

                xtype: 'button',
                id:'getInvolved',
                style:'border-radius:0',
                cls:'NavButtonListing',
                pressedCls:'NavButtonListingSelected',
                html:'<div class="ButtonListings-container"> <div class="ButtonListings-thumb"><img src="resources/images/CoSD_GetInvolvedIcon-Default Platform.png" /></div><div class="ButtonListings-content"><h3 class="listbutton-title">Get Involved</h3></div></div>',

           },
            {

                xtype: 'button',
                id:'communityReadiness',
                style:'border-radius:0',
                cls:'NavButtonListing',
                pressedCls:'NavButtonListingSelected',
                html:'<div class="ButtonListings-container"> <div class="ButtonListings-thumb"><img src="resources/images/CoSD_CommReadiness-Default Platform.png" /></div><div class="ButtonListings-content"><h3 class="listbutton-title">Community Readiness</h3></div></div>',

           },
           ]
   }

});
Was it helpful?

Solution

Your onNewTap should push your new view onto homeContainer:

Ext.define('COSD.controller.ReadyButtonController', {
    extend: 'Ext.app.Controller',

    config: {
        control: {
            '#readyButton': {
                // On the tap event, call onNewTap
                tap: 'onNewTap'
            }
        },
        refs: {
            homeContainer: 'homeContainer'
        }
    },

    launch: function() {
    },

    onNewTap: function() {
        this.getHomeContainer().push({xtype: 'readyscreenview'})
    }
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top