Last active
December 22, 2015 18:19
-
-
Save ricardoalcocer/6512574 to your computer and use it in GitHub Desktop.
Titanium Cross-platform Navigation Group for Titanium Classic. This is a follow up to https://github.com/ricardoalcocer/TiCrossPlatformNavigationGroup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var lib=require('/lib/xpngclassic'); | |
// win1 | |
var win1 = Titanium.UI.createWindow({ | |
backgroundColor: '#fff', | |
navBarHidden:false | |
}); | |
var button = Titanium.UI.createButton({ | |
title: 'Open Blue Window' | |
}); | |
// win2 | |
var win2 = Titanium.UI.createWindow({ | |
backgroundColor: 'red', | |
title: 'Red Window', | |
navBarHidden:false | |
}); | |
button.addEventListener('click', function(){ | |
lib.openWin(nav,win3); | |
}); | |
win2.add(button); | |
// win3 | |
var win3 = Titanium.UI.createWindow({ | |
backgroundColor: 'blue', | |
title: 'Blue Window', | |
navBarHidden:false | |
}); | |
// | |
if (Ti.Platform.osname!=='android'){ | |
var nav = Titanium.UI.iPhone.createNavigationGroup({ | |
window: win2 | |
}); | |
win1.add(nav); | |
win1.open(); | |
}else{ | |
win2.open(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.openWin=function(navGroup,winName){ | |
// this will make the this libary work on both Classic and Alloy | |
if (typeof Alloy === 'undefined'){ | |
var w=winName; // transfer the value to a new variable so the rest of the code remains the same | |
}else{ | |
var w=Alloy.createController(winName).getView(); | |
} | |
if (Ti.Platform.osname==='android'){ | |
w.addEventListener('open',function(e){ | |
if (! w.getActivity()) { | |
Ti.API.error("Can't access action bar on a lightweight window."); | |
} else { | |
actionBar = w.activity.actionBar; | |
if (actionBar) { | |
actionBar.displayHomeAsUp=true; | |
actionBar.onHomeIconItemSelected = function() { | |
w.close(); | |
}; | |
} | |
w.activity.invalidateOptionsMenu(); | |
} | |
}) | |
w.open(); | |
}else{ | |
navGroup.open(w,{animated:true}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment