Permalink
Browse files

Many fix. Now working :)

  • Loading branch information...
1 parent d71acb3 commit edd3fc9d48f4b7f56a9c6a967d89bb3b6fae5171 @pedrobrasileiro committed Feb 28, 2012
View
@@ -3,9 +3,5 @@ Ti.include('lib/init.js');
Ti.include('lib/ui.js');
Ti.include('lib/http.js');
-MyApp.mod = {};
-MyApp.mod.hud = require('modules/hud.mod');
-MyApp.mod.passcode = require('modules/passcode.mod');
-
// Run App
MyApp.init();
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
View
@@ -4,10 +4,11 @@
MyApp.ui.win = false;
MyApp.ui.table = false;
MyApp.ui.data = [
- {title:'Heads Up Display (HUD)',hasDetail:true},
- {title:'Passcode Modal',hasDetail:true}
+ {title:'Show HUD', hasDetail:true}
];
+ var SampleHUD = require('modules/SampleHUD');
+
MyApp.ui.createWindow = function(modal,callb) {
MyApp.ui.win = Ti.UI.createWindow({
modal : (modal) ? true : false
@@ -40,23 +41,12 @@
MyApp.ui.table.addEventListener('click',function(e) {
if (e.index == 0) {
- var HUD = MyApp.mod.hud.init(MyApp.ui.win);
+ var HUD = new SampleHUD(MyApp.ui.win);
HUD.show('Doing Something');
setTimeout(function(){
HUD.hide();
},2000);
}
-
- if (e.index == 1) {
- var PIN = MyApp.mod.passcode.init({code:1234,barColor:'#0079C1'});
- PIN.open({
- success:function(){
- Ti.API.info('Success');
- },error:function(){
- Ti.API.info('failed');
- }});
- }
-
});
});
@@ -1 +0,0 @@
-alert('hello');
@@ -0,0 +1,74 @@
+function SampleHUD(win, path) {
+ Ti.API.info('init');
+ path = path || '';
+ var t1 = Titanium.UI.create2DMatrix();
+ t1 = t1.scale(2);
+ var t2 = Titanium.UI.create2DMatrix();
+ t2 = t2.scale(0);
+
+ this.parentWin = win;
+
+ this.veil = Ti.UI.createView({
+ opacity : 1
+ });
+
+ this._HUD = Ti.UI.createView({
+ height : 100,
+ width : 200,
+ backgroundColor : '#333',
+ borderRadius : 13,
+ top : 'auto',
+ left : 'auto',
+ opacity : 0,
+ transform : t1
+ });
+
+ this._HUD_activity = Ti.UI.createActivityIndicator({
+ top : 'auto',
+ left : 'auto',
+ width : 175,
+ height : 75,
+ message : '',
+ color : 'white',
+ style : (Ti.Platform.name == 'android') ? null : Titanium.UI.iPhone.ActivityIndicatorStyle.BIG
+ });
+
+ this._HUD.add(this._HUD_activity);
+
+ win.add(this.veil);
+ win.add(this._HUD);
+}
+
+SampleHUD.prototype.show = function(msg) {
+ Ti.API.info(msg);
+ this._HUD_activity.message = msg;
+ this._HUD_activity.show();
+ this._HUD.animate({
+ opacity : 1,
+ duration : 200,
+ transform : Titanium.UI.create2DMatrix().scale(1.0)
+ });
+};
+
+SampleHUD.prototype.hide = function(callb) {
+ Ti.API.info('Hiding HUD');
+
+ var parent = this;
+
+ this._HUD.animate({
+ opacity : 0,
+ duration : 200,
+ transform : Titanium.UI.create2DMatrix().scale(0)
+ },
+ function() {
+ parent._HUD_activity.hide();
+ parent.parentWin.remove(parent._HUD);
+ parent.parentWin.remove(parent.veil);
+ parent._HUD = null;
+
+ if(callb){callb();}
+ }
+ );
+};
+
+module.exports = SampleHUD;
@@ -1,58 +0,0 @@
-exports.init = function(win, path) {
- Ti.API.info('init');
-
- path = path || '';
- var t1 = Titanium.UI.create2DMatrix();
- t1 = t1.scale(2);
- var t2 = Titanium.UI.create2DMatrix();
- t2 = t2.scale(0);
-
- var veil = Ti.UI.createView({opacity:1});
- var _HUD = Ti.UI.createView({
- height: 100,
- width:200,
- backgroundColor:'#333',
- borderRadius:13,
- top: 'auto',
- left:'auto',
- opacity:0,
- transform:t1
- });
-
- _HUD.activity = Ti.UI.createActivityIndicator({
- top: 'auto',
- left: 'auto',
- width: 175,
- height: 75,
- message: '',
- color: 'white',
- style: (Ti.Platform.name == 'android') ? null : Titanium.UI.iPhone.ActivityIndicatorStyle.BIG
- });
-
- // Extend Methods
- _HUD.show = function(msg) {
- Ti.API.info(msg);
- _HUD.activity.message = msg;
- _HUD.activity.show();
- _HUD.animate({opacity:1,duration:200,transform:Titanium.UI.create2DMatrix().scale(1.0)});
- };
-
- _HUD.hide = function(callb) {
- Ti.API.info('Hiding HUD');
- _HUD.animate({opacity:0,duration:200,transform:Titanium.UI.create2DMatrix().scale(0)},function(){
- _HUD.activity.hide();
- win.remove(_HUD);
- win.remove(veil);
- _HUD = null;
-
- if (callb) {callb();}
- });
- };
-
- _HUD.add(_HUD.activity);
-
- win.add(veil);
- win.add(_HUD);
-
- return _HUD;
-};
@@ -1,55 +0,0 @@
-// This is a module class object literal, rather than a commonJS implementation.
-// I added this to show an alternative method for creating modules.
-
-MyApp.hud = function (win, path) {
- path = path || '';
- var t1 = Titanium.UI.create2DMatrix();
- t1 = t1.scale(2);
- var t2 = Titanium.UI.create2DMatrix();
- t2 = t2.scale(0);
-
- var veil = Ti.UI.createView({opacity:1});
- var _HUD = Ti.UI.createView({
- height: 100,
- width:200,
- backgroundColor:'#333',
- borderRadius:13,
- top: 'auto',
- left:'auto',
- opacity:0,
- transform:t1
- });
- _HUD.activity = Ti.UI.createActivityIndicator({
- top: 'auto',
- left: 'auto',
- width: 175,
- height: 75,
- message: '',
- color: 'white',
- style: MyApp.android ? null : Titanium.UI.iPhone.ActivityIndicatorStyle.BIG
- });
-
- _HUD.add(_HUD.activity);
-
- // Add Methods
- _HUD.show = function(msg) {
- _HUD.activity.message = msg;
- _HUD.activity.show();
- _HUD.animate({opacity:1,duration:200,transform:Titanium.UI.create2DMatrix().scale(1.0)});
- };
- _HUD.hide = function (callb) {
- _HUD.animate({opacity:0,duration:200,transform:Titanium.UI.create2DMatrix().scale(0)},function(){
- _HUD.activity.hide();
- win.remove(_HUD);
- win.remove(veil);
- _HUD = null;
-
- if (callb) {callb();}
- });
- };
-
- win.add(veil);
- win.add(_HUD);
-
- return _HUD;
-};
Oops, something went wrong.

0 comments on commit edd3fc9

Please sign in to comment.