Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions Resources/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ else {
//create a private scope to prevent further polluting the global object
(function() {
var AppTabGroup = require('ui/AppTabGroup').AppTabGroup,
ListWindow = require('ui/ListWindow').ListWindow,
AddWindow = require('ui/AddWindow').AddWindow;
ListWindow = require('ui/ListWindow').ListWindow;

// Initialize local storage
require('db').createDb();
Expand All @@ -24,17 +23,7 @@ else {
title: 'Todo',
backgroundColor: '#fff',
navBarHidden: false,
isDone: 0,
activity: {
onCreateOptionsMenu: function(e) {
var menu = e.menu;
var menuItem = menu.add({ title: "Add Task" });
menuItem.setIcon("images/ic_menu_add.png");
menuItem.addEventListener("click", function(e) {
new AddWindow().open();
});
}
}
isDone: 0
})
},
{
Expand All @@ -51,4 +40,4 @@ else {

globals.tabs.open();
})();
}
}
5 changes: 3 additions & 2 deletions Resources/ui/AddWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ exports.AddWindow = function() {
top: '20dp',
hintText: 'New Item',
borderStyle: Ti.UI.INPUT_BORDERSTYLE_ROUNDED,
returnKeyType: Ti.UI.RETURNKEY_DONE
returnKeyType: Ti.UI.RETURNKEY_DONE,
color: '#000'
});
itemField.addEventListener('return', function(e) {
addTask(itemField.value, self);
Expand Down Expand Up @@ -53,4 +54,4 @@ var addTask = function(value, win) {
require('db').addItem(value);
Ti.App.fireEvent('app:updateTables');
win.close();
};
};
30 changes: 29 additions & 1 deletion Resources/ui/AppTabGroup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
exports.AppTabGroup = function() {

var AddWindow = require('ui/AddWindow').AddWindow;
var self = Ti.UI.createTabGroup();

//loop through tab objects and add them to the tab group
Expand All @@ -14,7 +16,33 @@ exports.AppTabGroup = function() {
//track the current tab for the tab group
self.addEventListener('focus', function(e) {
self.currentTab = e.tab;
// clear the action bar menu when switching between tabs for Android
if (Ti.Platform.name === "android") {
self.getActivity().invalidateOptionsMenu();
}
});

if (Ti.Platform.name === "android") {
self.addEventListener("open", function(e) {
var activity = self.getActivity();
activity.onCreateOptionsMenu = function(e) {
var item, menu;
menu = e.menu;
menu.clear();
// if it is the Todo tab on Android, add menu item to action bar
if (!self.activeTab.window.isDone) {
item = menu.add({
title : "Add",
icon : "images/images/ic_menu_add.png",
showAsAction: Ti.Android.SHOW_AS_ACTION_IF_ROOM
});
item.addEventListener("click", function(e) {
new AddWindow().open();
});
} // end check for isDone variable
}; // end createOptionsMenu
});
}

return self;
};
};
3 changes: 2 additions & 1 deletion Resources/ui/ListWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ var getTableData = function(done) {
title: todoItems[i].item,
color: '#000',
font: {
fontWeight: 'bold'
fontWeight: 'bold',
fontSize: '14dp'
}
});
data.push(row);
Expand Down
2 changes: 1 addition & 1 deletion tiapp.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
<sdk-version>3.5.0.GA</sdk-version>
<sdk-version>4.0.0.RC4</sdk-version>
<deployment-targets>
<target device="mobileweb">true</target>
<target device="iphone">true</target>
Expand Down