Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // All source code open Source Copyright 2011
- // Code submitted by thewarpedcoder .... [email protected]
- /* The purpose of the user cases is to define instances of issues / bugs
- * with the applications I code.
- *
- * This user case uses nameSpaces as this is how the main application works,
- * and also opens and closes windows as required. It does not have a window
- * stack.
- */
- Ti.UI.setBackgroundColor('#ffffff');
- // Define the NameSpaces
- var mainNS = {};
- mainNS.event = {};
- mainNS.view = {};
- mainNS.tool = {};
- mainNS.model = {};
- (function()
- {
- var mobWidth = Ti.Platform.displayCaps.platformWidth;
- var mobHeight = Ti.Platform.displayCaps.platformHeight;
- var mobDiv = 1;
- if (mobWidth < 480)
- {
- mobDiv = 2;
- }
- else if (mobWidth < 640)
- {
- mobDiv = 1.5;
- };
- if (Ti.Platform.osname == 'android')
- {
- androidPlatform = true;
- }
- // Global variable definitions.
- var globalCurrScreen = null;
- var globalPreviousScreen = null;
- var globalBackButt = [];
- var initiateFlag = true;
- var iPos = 0;
- // Functions
- function addBackScreen(inFunction)
- {
- var tmpBackIn = ({INFUNC: inFunction});
- globalBackButt.push(tmpBackIn);
- };
- function popGlobalBackButt()
- {
- globalBackButt.pop();
- };
- // Events ....
- mainNS.event.closeTheApp = function(evt)
- {
- if (Ti.Platform.osname == 'android')
- {
- var activity = Ti.Android.currentActivity;
- activity.stop();
- }
- };
- mainNS.event.loadBackScreenHandler = function(evt)
- {
- iPos = ((globalBackButt.length - 2) < 0) ? 0 : (globalBackButt.length - 2);
- if (globalBackButt.length <= 1)
- {
- mainNS.event.closeTheApp({});
- }
- else
- {
- if (iPos >= 0)
- {
- var tmp1 = globalBackButt[iPos].INFUNC;
- if (tmp1)
- {
- if(globalBackButt.length > 1)
- {
- popGlobalBackButt();
- };
- eval(tmp1 + '({BACK: ' + "true" + '});');
- }
- };
- };
- };
- mainNS.event.loadHomeScreen = function(evt)
- {
- globalPreviousScreen = globalCurrScreen;
- if (!evt.BACK)
- {
- addBackScreen("mainNS.event.loadHomeScreen");
- }
- mainNS.view.loadHomeScreenWindow().open();
- if (!initiateFlag)
- {
- globalPreviousScreen.close();
- initiateFlag = false;
- }
- };
- mainNS.event.loadCameraScreen = function(evt)
- {
- globalPreviousScreen = globalCurrScreen;
- if (!evt.BACK)
- {
- addBackScreen("mainNS.event.loadCameraScreen");
- }
- mainNS.view.loadCameraScreenWindow().open();
- globalPreviousScreen.close();
- initiateFlag = false;
- };
- // Screen Tools
- mainNS.tool.appNavigationBar = function(evt)
- {
- var navigationBar = Ti.UI.createView
- ({
- bottom: 0,
- height: 70 / mobDiv,
- right: 0,
- backgroundColor: "#000000",
- opacity: 0.75
- });
- var tmpHColor = (evt.SCREEN == 'HOME') ? "#FF0000" : "#FFFFFF";
- var tmpCColor = (evt.SCREEN == 'CAMERA') ? "#FF0000" : "#FFFFFF";
- var tmpBColor = (globalBackButt.length > 1) ? "#FFFFFF" : "#444444";
- var navBarHomeBtn = Ti.UI.createView
- ({
- left: 5,
- width: 90 / mobDiv,
- height: 70 / mobDiv,
- top: 0,
- backgroundColor: "#000000",
- borderColor: "#FFFFFF",
- borderWidth: 2
- });
- var navBarHomeBtnText = Ti.UI.createLabel
- ({
- width: 90 / mobDiv,
- text: "HOME",
- color: tmpHColor,
- textAlign: 'center',
- font: {fontSize: 10}
- });
- navBarHomeBtn.add(navBarHomeBtnText);
- navigationBar.add(navBarHomeBtn);
- var navBarCameraBtn = Ti.UI.createView
- ({
- left: 100 / mobDiv,
- width: 90 / mobDiv,
- height: 70 / mobDiv,
- top: 0,
- backgroundColor: "#000000",
- borderColor: "#FFFFFF",
- borderWidth: 2
- });
- var navBarCameraBtnText = Ti.UI.createLabel
- ({
- width: 90 / mobDiv,
- text: "CAMERA",
- color: tmpCColor,
- textAlign: 'center',
- font: {fontSize: 10}
- });
- navBarCameraBtn.add(navBarCameraBtnText);
- navigationBar.add(navBarCameraBtn);
- var navBarBackBtn = Ti.UI.createView
- ({
- left: 200 / mobDiv,
- width: 90 / mobDiv,
- height: 70 / mobDiv,
- top: 0,
- backgroundColor: "#000000",
- borderColor: "#FFFFFF",
- borderWidth: 2
- });
- var navBarBackBtnText = Ti.UI.createLabel
- ({
- width: 90 / mobDiv,
- text: "BACK",
- color: tmpBColor,
- textAlign: 'center',
- font: {fontSize: 10}
- });
- navBarBackBtn.add(navBarBackBtnText);
- navigationBar.add(navBarBackBtn);
- var navBarCloseBtn = Ti.UI.createView
- ({
- right: 10 / mobDiv,
- width: 90 / mobDiv,
- height: 70 / mobDiv,
- top: 0,
- backgroundColor: "#000000",
- borderColor: "#FFFFFF",
- borderWidth: 2
- });
- var navBarCloseBtnText = Ti.UI.createLabel
- ({
- width: 90 / mobDiv,
- text: "CLOSE",
- color: "#FFFFFF",
- textAlign: 'center',
- font: {fontSize: 10}
- });
- navBarCloseBtn.add(navBarCloseBtnText);
- navigationBar.add(navBarCloseBtn);
- if (evt.SCREEN != 'HOME') {navBarHomeBtn.addEventListener('click', function() {mainNS.event.loadHomeScreen({})} ); };
- if (evt.SCREEN != 'CAMERA') {navBarCameraBtn.addEventListener('click', function() {mainNS.event.loadCameraScreen({})} ); };
- if (globalBackButt.length > 1) {navBarBackBtn.addEventListener('click', function() {mainNS.event.loadBackScreenHandler({})} ); };
- navBarCloseBtn.addEventListener('click', function() {mainNS.event.closeTheApp({})} );
- return navigationBar;
- };
- // Screens ....
- mainNS.view.loadHomeScreenWindow = function()
- {
- var mainMenuWin = Ti.UI.createWindow
- ({
- navBarHidden: true,
- backgroundColor: "#FFFFFF"
- });
- var mainMenuWinLabel = Ti.UI.createLabel
- ({
- width: 200,
- text: "HOME SCREEN",
- color: "#000000",
- textAlign: 'center',
- font: {fontSize: 30}
- });
- mainMenuWin.add(mainMenuWinLabel);
- globalCurrScreen = mainMenuWin;
- var navBarData = {SCREEN: "HOME"};
- var navBar = mainNS.tool.appNavigationBar(navBarData);
- mainMenuWin.add(navBar);
- if (Ti.Platform.osname == 'android')
- {
- mainMenuWin.addEventListener('android:back', function() {mainNS.event.loadBackScreenHandler({})} );
- };
- return mainMenuWin;
- };
- mainNS.view.loadCameraScreenWindow = function()
- {
- var cameraScreenWin = Ti.UI.createWindow
- ({
- navBarHidden: true,
- backgroundColor: "#FFFFFF"
- });
- var cameraScreenWinLabel = Ti.UI.createLabel
- ({
- width: 200,
- text: "CAMERA SCREEN",
- color: "#000000",
- textAlign: 'center',
- font: {fontSize: 30}
- });
- cameraScreenWin.add(cameraScreenWinLabel);
- globalCurrScreen = cameraScreenWin;
- var navBarData = {SCREEN: "CAMERA"};
- var navBar = mainNS.tool.appNavigationBar(navBarData);
- cameraScreenWin.add(navBar);
- if (Ti.Platform.osname == 'android')
- {
- cameraScreenWin.addEventListener('android:back', function() {mainNS.event.loadBackScreenHandler({})} );
- };
- return cameraScreenWin;
- };
- // Initial Launch
- mainNS.event.loadHomeScreen({});
- })();
Advertisement
Add Comment
Please, Sign In to add comment