Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Advice on application structure needed

I need a bit of advice on the structure of my application. I have tried different methods, but have not been able to find the correct way.

In essence, I am trying to make an application with three windows. Based on a validation in app.js when the application opens or resumes, it shows either of these three windows. I do not want to have a tabGroup in my app.

This example gives an idea of my app.js. The problem with this approach is that my windows does not get the title declared in the createWindow function. Am I going about this wrong, and is there a better way of constructing such an app?

Ti.include('common.js');

// Create application main window
var main = Ti.UI.createWindow();

// Contruct application windows
var win1 = Titanium.UI.createWindow({
    url:'win1.js',
    backgroundColor: "Red", 
    title: 'Window 1',
});

var win2 = Titanium.UI.createWindow({
    url:'win2.js',
    backgroundColor: "Green", 
    title: 'Window 2'
});

var win3 = Titanium.UI.createWindow({
    url:'win3.js',
    backgroundColor: "blue", 
    title: 'Window 3'
});

// Check login
if(Login()) {
    // Check status    
    if(Status()) {
        win1.open();
    } else {
        win2.open();
    }
} else {
    win3.open();
}

main.open();

Any help on this is much appreciated!

— asked November 16th 2010 by Michael Ladum
  • iphone
0 Comments

1 Answer

  • When we do our pro services apps, we find that most often we use a single execution context (instead of many windows with their own context). If it were me, I would use views instead of windows, and arrange them in a stack, swapping out which one is visible depending on login state:

    arrangement

    — answered November 16th 2010 by Kevin Whinnery
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.