Skip to content

Instantly share code, notes, and snippets.

@yagitoshiro
Last active December 26, 2015 06:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yagitoshiro/7105452 to your computer and use it in GitHub Desktop.
Save yagitoshiro/7105452 to your computer and use it in GitHub Desktop.
P.O.C: Hide TabBar with Titanium SDK 3.x...
//app.js excerpt
var ApplicationTabGroup;
if(Ti.Platform.osname == 'android'){
ApplicationTabGroup = require('ui/common/AndroidTabGroup'); // <- これを追加
}else{
ApplicationTabGroup = require('ui/common/ApplicationTabGroup');
}
new ApplicationTabGroup(Window).open();
//ui/common/AndroidTabGroup.js
function createTab(window){
var self, windows, i, len;
self = new Object();
windows = new Array();
windows.push(window);
self.init = function(){
windows[0].open();
windows[0].visible = true;
};
self.show = function(){
len = windows.length - 1;
if(windows[len].visible !== true){
windows[len].open();
windows[len].visible = true;
}
for(i = 0, len = windows.length; i < len; i++){
windows[i].show();
}
};
self.hide = function(){
for(i = 0, len = windows.length; i < len; i++){
windows[i].hide();
}
};
self.open = function(new_window){
windows.push(new_window);
new_window.open();
};
return self;
}
function createTabGroup(){
var tabs, i, len;
tabs = [];
this.open = function(){
for(i = 1, len = tabs.length; i < len; i++){
tabs[i].hide();
}
tabs[0].init();
};
this.addTab = function(tab){
tabs.push(tab);
};
this.setActiveTab = function(obj){
var fn;
if(typeof(obj) != 'number' && typeof(obj) != 'string'){
fn = function(index, arg){
return obj === arg;
};
}else{
fn = function(index, arg){
return obj === index;
};
}
for(i = 0, len = tabs.length; i < len; i++){
if(fn(tabs[i] === true)){
tabs[i].show();
}else{
tabs[i].hide();
}
}
};
}
function AndroidTabGroup(Window){
var tabs, tab1, tab2, window1, window2, i, len, tabGroup;
window1 = new Window("home");
window2 = new Window("settings");
tab1 = new createTab(window1);
tab2 = new createTab(window2);
window1.containingTab = tab1;
window2.containingTab = tab2;
tabGroup = new createTabGroup();
tabGroup.addTab(tab1);
tabGroup.addTab(tab2);
return tabGroup;
}
module.exports = AndroidTabGroup;
//ui/handheld/ApplicationWindow.js
function ApplicationWindow(title) {
var self = Ti.UI.createWindow({
title:title,
backgroundColor:'white',
bubbleParent: false,
fullscreen: false, // <- 重要、これがないとWindowを開いてもバックボタンでアプリが閉じてしまう
layout: 'vertical'
});
self.add(Ti.UI.createLabel({text: title, top: 100, width: Ti.UI.SIZE, height: Ti.UI.SIZE, color: 'Black'}));
self.addEventListener('click', function(){
var Window = require('ui/handheld/AnotherWindow');
window = new Window('Another Window');
window.bubbleParent = false;
self.containingTab.open(window);
});
return self;
}
module.exports = ApplicationWindow;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment