aboutsummaryrefslogtreecommitdiffstats
path: root/Resources/friendship/ui/ActivityIndicator.js
blob: ef2949cfc4035b4871550b56a74c4ebc42d60564 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
(function() {
	fs.ui.createLoadingView = function() {
		var loading_view = Ti.UI.createView({
			height: 100,
			width: 100,
			visible: false
		});
		
		var background = Ti.UI.createView({
			backgroundColor: '#222',
			opacity: 0.82,
			borderRadius: 10
		});
		var loader = Ti.UI.createActivityIndicator({
			style: (fs.app.isAndroid) ? null : Titanium.UI.iPhone.ActivityIndicatorStyle.BIG
		});
		
		var loader_msg = Ti.UI.createLabel( {
			    text:'loading',
			    height:'auto',
			    width:'auto',
			    top:0,
			    color:'#fff',
			    font:{fontSize:10},
			    textAlign:'center'
		});
		
		loading_view.add(background);
		loading_view.add(loader);
		loading_view.add( loader_msg );
		loader.show();
		
		Ti.App.addEventListener('app:show.loader', function() {
			if (!loading_view.visible) {
				loading_view.visible = true;
			}
		});

		Ti.App.addEventListener('app:msg.loader', function(msg) {
			loader_msg.text = msg.text;
		});
		
		Ti.App.addEventListener('app:hide.loader', function() {
			loading_view.visible = false;
		});
		
		return loading_view;
	};
})();