Skip to content

Instantly share code, notes, and snippets.

@iantearle
Created November 5, 2012 12:46
Show Gist options
  • Save iantearle/4017028 to your computer and use it in GitHub Desktop.
Save iantearle/4017028 to your computer and use it in GitHub Desktop.
Trying to retrieve the values from username and password in Login.
//FirstView Component Constructor
function Login() {
var Title = require('ui/common/Title'),
Logo = require('ui/common/Logo');
UserPassword = require('ui/common/UserPassword');
//create object instance, a parasitic subclass of Observable
var self = Ti.UI.createView({
width: Ti.Platform.displayCaps.platformWidth - 50,
left: 50
});
self.add(new Title('Login'));
var logoRow = Ti.UI.createView({
left:0,
top:80,
height: Ti.UI.SIZE,
width: Ti.Platform.displayCaps.platformWidth - 50
});
var logoContainer = Ti.UI.createView({
left:73,
height: Ti.UI.SIZE,
width: Ti.UI.SIZE
});
logoContainer.add(new Logo([144], ['#349EB7', 124], ['#F0FBFE', 18]));
logoRow.add(Ti.UI.createLabel({
color: '#349EB7',
font: { fontFamily: 'Gotham-Bold',fontSize: 24 },
height: 'auto',
top: 58, left: 53,
text: 'DAY'
}));
logoRow.add(Ti.UI.createLabel({
color: '#349EB7',
font: { fontFamily: 'Gotham-Light',fontSize: 24 },
height: 'auto',
top: 58, right: 50,
text: '100'
}));
logoRow.add(logoContainer);
self.add(logoRow);
var scrollView = Ti.UI.createScrollView({
layout: 'vertical',
contentWidth: 'auto',
contentHeight: 'auto',
showVerticalScrollIndicator: true,
touchEnabled: true,
});
scrollView.add(Ti.UI.createView({
height: 240,
width: Ti.Platform.displayCaps.platformWidth - 50
}));
scrollView.add(new UserPassword());
self.add(scrollView);
return self;
}
module.exports = Login;
// UserPassword
function UserPassword() {
//create object instance, a parasitic subclass of Observable
var self = Ti.UI.createView({
width: Ti.Platform.displayCaps.platformWidth - 64,
top: 0,
bottom: 10,
height: 75,
backgroundColor: '#ffffff',
left: 7,
borderRadius: 10,
borderWidth: 1,
borderColor: '#a9b2b4'
});
var user = Titanium.UI.createTextField({
color: '#29788A',
hintText:'Username',
height:36,
top:0,
left:36,
value: 'bob'
});
var password = Titanium.UI.createTextField({
color: '#29788A',
hintText:'Password',
height:36,
top:37,
left:36,
passwordMask: true
});
self.add(Ti.UI.createLabel({
color: '#29788A',
font: { fontFamily: SSPika.fontfamily(),fontSize: 18 },
height: 'auto',
top: 8, left:10,
text: SSPika.icon('user')
}));
self.add(user);
self.add(Ti.UI.createView({
width: Ti.Platform.displayCaps.platformWidth - 64,
height: 1,
backgroundColor: '#a9b2b4',
}));
self.add(Ti.UI.createLabel({
color: '#29788A',
font: { fontFamily: SSPika.fontfamily(),fontSize: 18 },
height: 'auto',
top: 46, left:10,
text: SSPika.icon('key')
}));
self.add(password);
return self;
}
module.exports = UserPassword;
@boydlee
Copy link

boydlee commented Nov 5, 2012

// UserPassword
function UserPassword() {
//create object instance, a parasitic subclass of Observable
var self = Ti.UI.createView({
width: Ti.Platform.displayCaps.platformWidth - 64,
top: 0,
bottom: 10,
height: 75,
backgroundColor: '#ffffff',
left: 7,
borderRadius: 10,
borderWidth: 1,
borderColor: '#a9b2b4'
});

var user = Titanium.UI.createTextField({
    color: '#29788A',
    hintText:'Username',
    height:36,
    top:0,
    left:36,
    value: 'bob'
});

var password = Titanium.UI.createTextField({
    color: '#29788A',
    hintText:'Password',
    height:36,
    top:37,
    left:36,
    passwordMask: true
});

self.add(Ti.UI.createLabel({
    color: '#29788A',
    font: { fontFamily: SSPika.fontfamily(),fontSize: 18 },
    height: 'auto',
    top: 8, left:10,
    text: SSPika.icon('user')
}));
self.add(user);
self.add(Ti.UI.createView({
    width: Ti.Platform.displayCaps.platformWidth - 64,
    height: 1,
    backgroundColor: '#a9b2b4',
}));
self.add(Ti.UI.createLabel({
    color: '#29788A',
    font: { fontFamily: SSPika.fontfamily(),fontSize: 18 },
    height: 'auto',
    top: 46, left:10,
    text: SSPika.icon('key')
}));
self.add(password);


   /**** 
     a couple of 'getters'
   ***/
    self.getUsername = function(){
         return user.value;
    };       
    self.getPassword = function(){
         return password.value;
    };

return self;

}

module.exports = UserPassword;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment