How to create Splash screen for Sencha touch application?

Hello,

This is blog post is all about creating splash screen for sencha touch application. We all know that Sencha touch displays startup image while app is busy in loading necessary JavaScript files. However this image will only be displayed for few seconds. What if you want to display splash screen for users to have a feel that application is loading necessary data and will start in some time.

Following is the code to accomplish this. You have to write this code in app.js file

launch: function () {
        Ext.Viewport.setMasked({
            xtype: ‘loadmask’,
            message: ‘My Message’
        });
        new Ext.util.DelayedTask(function () {
            Ext.Viewport.setMasked(false);
            Ext.Viewport.add({
                xclass: ‘MyApp.view.Main’
            });

        }).delay(5000);
    }

Above code will display load mask for 5 seconds and than it will add your main view to viewport. You can also override Ext.LoadMask if you want to display your brand logo or images etc. See the following code

Ext.override(Ext.LoadMask, {
getTemplate: function() {
        var prefix = Ext.baseCSSPrefix;

        return [
            {
                //it needs an inner so it can be centered within the mask, and have a background
                reference: ‘innerElement’,
                cls: prefix + ‘mask-inner’,
                children: [
                //the elements required for the CSS loading {@link #indicator}
                    {
                        html: ‘<img src=”images/MyLogo.png”/>’
                    },
                    {
                        reference: ‘indicatorElement’,
                        cls: prefix + ‘loading-spinner-outer’,
                        children: [
                            {
                                cls: prefix + ‘loading-spinner’,
                                children: [
                                    { tag: ‘span’, cls: prefix + ‘loading-top’ },
                                    { tag: ‘span’, cls: prefix + ‘loading-right’ },
                                    { tag: ‘span’, cls: prefix + ‘loading-bottom’ },
                                    { tag: ‘span’, cls: prefix + ‘loading-left’ }
                                ]
                            }
                        ]
                    },
                    //the element used to display the {@link #message}
                    {
                        reference: ‘messageElement’
                    }
                ]
            }
        ];
    }
});

Check this code

{
      html: ‘<img src=”images/MyLogo.png”/>’
}

This will add an extra logo to your loading screen. This is how you can add any other extra content to your splash screen.

Hope this helps you.

This entry was posted in Sencha Touch 2, Splash Screen on by .

About Hiren Dave

Hiren Dave is a software engineer, blogger and consultant with over 9 years of professional experience. He writes code in number of languages. Hiren has a passion for developing web apps, mobile apps and writing books and blog articles about programming. He has a solid experience of startups as he manages products for few startups. He is also passionate about researching and learning new technologies and trends. He has also authored a book Instant Sencha Touch, published by Packt and creator of Video Course "Beginning Laravel" for Packt

6 thoughts on “How to create Splash screen for Sencha touch application?”

  1. Anonymous

    I'm getting the following error for 'Ext.util.DelayedTask':
    Uncaught TypeError: undefined is not a function

    ST v2.1.1

    Reply ↓
  2. Anonymous

    Can you please post screenshots too so we can know how it looked and if possible then source code too.

    Reply ↓

Leave a Reply

Your email address will not be published. Required fields are marked *