Created
April 9, 2014 16:03
-
-
Save addieljuarez/10286624 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Application Window Component Constructor | |
| function ApplicationWindow() { | |
| var Cloud = require('ti.cloud'); | |
| var WinPhoto = require('ui/handheld/winPhoto'); | |
| var self = Ti.UI.createWindow({ | |
| backgroundColor:'#ffffff', | |
| layout:'vertical', | |
| }); | |
| var inputNombre = Titanium.UI.createTextField({ | |
| top:50, | |
| height:45, | |
| width:200, | |
| hintText:'Correo', | |
| }); | |
| var inputPassword = Titanium.UI.createTextField({ | |
| top:20, | |
| height:45, | |
| width:200, | |
| hintText:'Password', | |
| passwordMask:true, | |
| }); | |
| var buttonSucces= Titanium.UI.createButton({ | |
| top:30, | |
| height:40, | |
| width:150, | |
| title:'Enviar', | |
| }); | |
| buttonSucces.addEventListener('click', function(){ | |
| inputNombre.blur(); | |
| inputPassword.blur(); | |
| Cloud.Users.login({ | |
| login: inputNombre.value, | |
| password: inputPassword.value, | |
| }, function (e) { | |
| if (e.success) { | |
| var user = e.users[0]; | |
| var winPhoto = new WinPhoto(); | |
| winPhoto.open(); | |
| // alert('Success:\n' + | |
| // 'id: ' + user.id + '\n' + | |
| // 'sessionId: ' + Cloud.sessionId + '\n' + | |
| // 'first name: ' + user.first_name + '\n' + | |
| // 'last name: ' + user.last_name); | |
| } else { | |
| alert('Error:\n' + | |
| ((e.error && e.message) || JSON.stringify(e))); | |
| } | |
| }); | |
| }); | |
| self.add(inputNombre); | |
| self.add(inputPassword); | |
| self.add(buttonSucces); | |
| return self; | |
| } | |
| module.exports = ApplicationWindow; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function WinPhoto(){ | |
| var Cloud = require('ti.cloud'); | |
| var self = Titanium.UI.createWindow({ | |
| backgroundColor:'Black', | |
| layout:'vertical', | |
| }); | |
| var image = Titanium.UI.createImageView({ | |
| height:150, | |
| width:150, | |
| top:80, | |
| borderColor:'red', | |
| }); | |
| var buttonSend = Titanium.UI.createButton({ | |
| title:'Enviar', | |
| top:30, | |
| width:150, | |
| height:40, | |
| }); | |
| image.addEventListener('click', function(e){ | |
| Titanium.Media.openPhotoGallery({ | |
| success: function(event){ | |
| var img = event.media; | |
| image.image = img; | |
| }, | |
| error: function(){ | |
| alert('error'); | |
| }, | |
| cancel: function(){ | |
| } | |
| }); | |
| }); | |
| buttonSend.addEventListener('click', function(){ | |
| Cloud.Photos.create({ | |
| photo: image.getImage(), | |
| }, function (e) { | |
| if (e.success) { | |
| var photo = e.photos[0]; | |
| alert('Success:\n' + | |
| 'id: ' + photo.id + '\n' + | |
| 'filename: ' + photo.filename + '\n' + | |
| 'size: ' + photo.size, | |
| 'updated_at: ' + photo.updated_at); | |
| } else { | |
| alert('Error:\n' + | |
| ((e.error && e.message) || JSON.stringify(e))); | |
| } | |
| }); | |
| }); | |
| self.add(image); | |
| self.add(buttonSend); | |
| return self; | |
| } | |
| module.exports = WinPhoto; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment