Skip to content

Instantly share code, notes, and snippets.

@stephenfeather
Last active December 29, 2015 11:59
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 stephenfeather/7667391 to your computer and use it in GitHub Desktop.
Save stephenfeather/7667391 to your computer and use it in GitHub Desktop.
Sample code for Richard Olenick in answer to http://developer.appcelerator.com/question/159878/trying-to-switch-windows-with-use-of-a-button-click#comment-195523 assumes all these files are in Resources/
var Login = require('loginScreen');
var loginPage = new Login();
loginPage.open();
function Home(){
var win = Titanium.UI.createWindow({
title: "Label View",
backgroundColor: 'orange',
exitOnClose: true,
layout: 'vertical'
});
var AvailableJobsButton = Titanium.UI.createButton({
title: "Available Jobs",
top: "10%",
height: "10%",
width:"100%",
font:{fontSize: "32"},
id: "AvailableJobs", //custom property
});
var CurrentJobsButton = Titanium.UI.createButton({
title: "Current Jobs",
top: "40%",
height: "10%",
width:"100%",
font:{fontSize: "32"},
id: "CurrentJobs", //custom property
});
var CompletedJobsButton = Titanium.UI.createButton({
title: "Completed Jobs",
top: "70%",
height: "10%",
width:"100%",
font:{fontSize: "32"},
id: "CompletedJobs", //custom property
});
AvailableJobsButton.addEventListener("click", function(e){
alert(e.source.id + " fired a " + e.type + " event");
});
CurrentJobsButton.addEventListener("click", function(e){
alert(e.source.id + " fired a " + e.type + " event");
});
CompletedJobsButton.addEventListener("click", function(e){
alert(e.source.id + " fired a " + e.type + " event");
});
win.add(AvailableJobsButton);
win.add(CurrentJobsButton);
win.add(CompletedJobsButton);
return win;
}
module.exports = Home;
/**
* @author Ricky
*/
function Login(){
var win = Titanium.UI.createWindow({
title: "Login Screen",
backgroundColor: "orange",
exitOnClose: true
});
var ClutchInspectLabel = Titanium.UI.createLabel({
text: "ClutchInspect",
color: "black",
top: "10%",
font: {fontSize: "42"}
});
var LoginButton = Titanium.UI.createButton({
title: "LOGIN",
top: "80%",
height: "10%",
width:"45%",
font:{fontSize: "24"},
id: "Login", //custom property
});
var UserNameBox = Titanium.UI.createTextArea({
borderWidth: 2,
borderColor: '#bbb',
borderRadius: 5,
color: '#888',
font: {fontSize:20, fontWeight:'bold'},
keyboardType: Ti.UI.KEYBOARD_DEFAULT,
returnKeyType: Ti.UI.RETURNKEY_NEXT,
textAlign: 'left',
value: '',
top: "45%",
left: "25%",
width: 300, height : 50
});
var PasswordBox = Titanium.UI.createTextArea({
borderWidth: 2,
borderColor: '#bbb',
borderRadius: 5,
color: '#888',
font: {fontSize:20, fontWeight:'bold'},
keyboardType: Ti.UI.KEYBOARD_DEFAULT,
returnKeyType: Ti.UI.RETURNKEY_DONE,
passwordMask: 'true',
textAlign: 'left',
value: '',
top: "55%",
left: "25%",
width: 300, height : 50,
});
var InputPassword = Titanium.UI.createTextField({
id:'InputPassword',
hintText:Ti.Locale.getString('Password'),
passwordMask:true,
className:'DefaultPasswordField',
});
var UserNameLabel = Titanium.UI.createLabel({
text:"Username:",
top: "45%",
left: 0,
textAlign: "center",
font:{fontSize: "24"},
color: "black",
backgroundColor: "orange"
});
var PasswordLabel = Titanium.UI.createLabel({
text:"Password:",
top: "55%",
left: 0,
textAlign: "center",
font:{fontSize: "24"},
color: "black",
backgroundColor: "orange"
});
LoginButton.addEventListener("click", function() {
var Home = require('/homeScreen');
var homePage = new Home();
homePage.open();
});
//win.add(InputPassword);
win.add(UserNameBox);
win.add(PasswordBox);
win.add(UserNameLabel);
win.add(PasswordLabel);
win.add(LoginButton);
win.add(ClutchInspectLabel);
return win;
}
module.exports = Login;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment