Skip to content

Instantly share code, notes, and snippets.

@TheBrousse
Created July 27, 2014 20:06
Show Gist options
  • Save TheBrousse/0479fdb7ab749945c8b3 to your computer and use it in GitHub Desktop.
Save TheBrousse/0479fdb7ab749945c8b3 to your computer and use it in GitHub Desktop.
nappDrawer on Android
exports.SwapView = function(controllerToShow) {
// Remove the controllers.view from centerWindow
if (OS_ANDROID) {
Alloy.Globals.navbar.remove(Alloy.Globals.centerView.getView());
// Destroy the old controller
Alloy.Globals.centerView.destroy();
Alloy.Globals.centerView = null;
Ti.API.debug('SwapView.centerView: ' + Alloy.Globals.centerView);
}
// Assign the new controller
Alloy.Globals.centerView = controllerToShow;
Ti.API.debug('SwapView.centerView.controller: /' + Alloy.Globals.centerView.__controllerPath);
// Add the controller's view to our centerWindow
if (OS_ANDROID) {
Alloy.Globals.drawer.setCenterWindow(Alloy.Globals.centerView.getView());
} else {
Alloy.Globals.navbar.openWindow(Alloy.Globals.centerView.getView(), {
animated: true
});
}
if (Alloy.Globals.drawer.isLeftWindowOpen()) {
Alloy.Globals.drawer.toggleLeftWindow();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment