@nstudio/nativescript-loading-indicator 3.0.4 → 4.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +0 -0
- package/README.md +18 -34
- package/common.d.ts +83 -0
- package/{loading-indicator.common.js → common.js} +3 -5
- package/common.js.map +1 -0
- package/{loading-indicator.android.d.ts → index.android.d.ts} +5 -2
- package/index.android.js +547 -0
- package/index.android.js.map +1 -0
- package/index.d.ts +103 -102
- package/{loading-indicator.ios.d.ts → index.ios.d.ts} +2 -2
- package/{loading-indicator.ios.js → index.ios.js} +32 -33
- package/index.ios.js.map +1 -0
- package/package.json +16 -62
- package/platforms/android/AndroidManifest.xml +2 -0
- package/platforms/android/nativescript_loading_indicator.aar +0 -0
- package/platforms/android/res/drawable/circle_shape.xml +6 -0
- package/platforms/android/res/drawable/circular_progress_bar.xml +18 -0
- package/platforms/android/res/drawable/circular_progress_bar_thick.xml +18 -0
- package/loading-indicator.android.js +0 -531
- package/loading-indicator.common.d.ts +0 -38
- package/references.d.ts +0 -3
- package/typings/objc!MBProgressHUD.d.ts +0 -240
@@ -1,531 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
function __export(m) {
|
3
|
-
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
4
|
-
}
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
var application = require("@nativescript/core/application");
|
7
|
-
var color_1 = require("@nativescript/core/color");
|
8
|
-
var image_source_1 = require("@nativescript/core/image-source");
|
9
|
-
var platform_1 = require("@nativescript/core/platform");
|
10
|
-
var frame_1 = require("@nativescript/core/ui/frame");
|
11
|
-
var utils_1 = require("@nativescript/core/utils/utils");
|
12
|
-
var loading_indicator_common_1 = require("./loading-indicator.common");
|
13
|
-
__export(require("./loading-indicator.common"));
|
14
|
-
var R_ATTR_PROGRESS_BAR_STYLE_HORIZONTAL = 0x01010078;
|
15
|
-
var PACKAGE = 'com.github.triniwiz.ns.loading.indicator';
|
16
|
-
var ViewCompatNamespace = useAndroidX()
|
17
|
-
? androidx.core.view
|
18
|
-
: android.support.v4.view;
|
19
|
-
function useAndroidX() {
|
20
|
-
return global.androidx && global.androidx.core.view;
|
21
|
-
}
|
22
|
-
var HIDE_RETRY_MS = 100;
|
23
|
-
var LoadingIndicator = (function () {
|
24
|
-
function LoadingIndicator() {
|
25
|
-
this._defaultProgressColor = new color_1.Color('#007DD6');
|
26
|
-
this._progressId = android.view.View.generateViewId();
|
27
|
-
this._messageId = android.view.View.generateViewId();
|
28
|
-
this._detailsId = android.view.View.generateViewId();
|
29
|
-
this._customViewId = android.view.View.generateViewId();
|
30
|
-
this._loadersInstances = [];
|
31
|
-
this._isCreatingPopOver = false;
|
32
|
-
}
|
33
|
-
LoadingIndicator.prototype.show = function (options) {
|
34
|
-
var _this = this;
|
35
|
-
var context = utils_1.ad.getApplicationContext();
|
36
|
-
if (context) {
|
37
|
-
options = options || {};
|
38
|
-
options.android = options.android || {};
|
39
|
-
options.userInteractionEnabled = options.userInteractionEnabled !== undefined;
|
40
|
-
if (!this._popOver) {
|
41
|
-
this._isCreatingPopOver = true;
|
42
|
-
new Promise(function (resolve) {
|
43
|
-
_this._createPopOver(context, options);
|
44
|
-
_this._loadersInstances.push(_this._popOver);
|
45
|
-
resolve();
|
46
|
-
}).then(function () {
|
47
|
-
_this._isCreatingPopOver = false;
|
48
|
-
}).catch(function (error) {
|
49
|
-
_this._isCreatingPopOver = false;
|
50
|
-
var message = error && error.message ? ": " + error.message : '';
|
51
|
-
console.error("Error creating Loading Indicator Pop Over" + message);
|
52
|
-
});
|
53
|
-
return;
|
54
|
-
}
|
55
|
-
this._updatePopOver(context, options);
|
56
|
-
}
|
57
|
-
};
|
58
|
-
LoadingIndicator.prototype.hide = function (targetView, attemptTimeout) {
|
59
|
-
if (attemptTimeout === void 0) { attemptTimeout = 1000; }
|
60
|
-
if (this._isCreatingPopOver) {
|
61
|
-
this._waitForCreatePopOver(attemptTimeout);
|
62
|
-
return;
|
63
|
-
}
|
64
|
-
this._tryHide();
|
65
|
-
};
|
66
|
-
LoadingIndicator.prototype._tryHide = function () {
|
67
|
-
try {
|
68
|
-
for (var i = 0; i < this._loadersInstances.length; i++) {
|
69
|
-
var loader = this._loadersInstances[i];
|
70
|
-
if (loader) {
|
71
|
-
if (this._isShowing(loader)) {
|
72
|
-
loader.dismiss();
|
73
|
-
this._loadersInstances.splice(i, 1);
|
74
|
-
}
|
75
|
-
}
|
76
|
-
}
|
77
|
-
this._popOver = null;
|
78
|
-
this._currentProgressColor = null;
|
79
|
-
}
|
80
|
-
catch (e) {
|
81
|
-
console.log(e);
|
82
|
-
}
|
83
|
-
};
|
84
|
-
LoadingIndicator.prototype._waitForCreatePopOver = function (attemptTimeout) {
|
85
|
-
var _this = this;
|
86
|
-
var startTime = Date.now();
|
87
|
-
var awaitCreation = function () { return __awaiter(_this, void 0, void 0, function () {
|
88
|
-
return __generator(this, function (_a) {
|
89
|
-
switch (_a.label) {
|
90
|
-
case 0:
|
91
|
-
if (!this._isCreatingPopOver) {
|
92
|
-
return [2, this._tryHide()];
|
93
|
-
}
|
94
|
-
if (Date.now() > startTime + attemptTimeout) {
|
95
|
-
console.warn('Hide attempt timeout exceeded');
|
96
|
-
return [2];
|
97
|
-
}
|
98
|
-
return [4, new Promise(function (resolve) { return setTimeout(resolve, HIDE_RETRY_MS); })];
|
99
|
-
case 1:
|
100
|
-
_a.sent();
|
101
|
-
return [2, awaitCreation()];
|
102
|
-
}
|
103
|
-
});
|
104
|
-
}); };
|
105
|
-
return awaitCreation();
|
106
|
-
};
|
107
|
-
LoadingIndicator.prototype._isShowing = function (loader) {
|
108
|
-
return loader.isShowing();
|
109
|
-
};
|
110
|
-
LoadingIndicator.prototype._createPopOver = function (context, options) {
|
111
|
-
this._popOver = new android.widget.PopupWindow();
|
112
|
-
var ref = new WeakRef(this);
|
113
|
-
this._popOver.setTouchable(options.userInteractionEnabled);
|
114
|
-
var contentView = new android.widget.LinearLayout(context);
|
115
|
-
var defaultTextColor = new color_1.Color(options.color || '#000');
|
116
|
-
var defaultTextNativeColor = defaultTextColor.android
|
117
|
-
? defaultTextColor.android
|
118
|
-
: android.graphics.Color.BLACK;
|
119
|
-
var defaultDetailsNativeColor = new color_1.Color(255 * 0.8, defaultTextColor.r, defaultTextColor.g, defaultTextColor.b).android;
|
120
|
-
contentView.setOnTouchListener(new android.view.View.OnTouchListener({
|
121
|
-
onTouch: function (view, event) {
|
122
|
-
var cancelListener = options.android.cancelListener;
|
123
|
-
var cancelable = options.android.cancelable;
|
124
|
-
var owner = ref.get();
|
125
|
-
if (cancelListener && typeof cancelListener === 'function') {
|
126
|
-
if (owner && cancelable) {
|
127
|
-
owner._popOver.dismiss();
|
128
|
-
cancelListener(owner._popOver);
|
129
|
-
owner._popOver = null;
|
130
|
-
}
|
131
|
-
}
|
132
|
-
return true;
|
133
|
-
}
|
134
|
-
}));
|
135
|
-
var defaultBackgroundColor = android.graphics.Color.WHITE;
|
136
|
-
contentView.setBackgroundColor(options.dimBackground
|
137
|
-
? new color_1.Color(255 * 0.6, 0, 0, 0).android
|
138
|
-
: android.graphics.Color.TRANSPARENT);
|
139
|
-
contentView.setGravity(android.view.Gravity.CENTER);
|
140
|
-
contentView.setLayoutParams(new android.view.ViewGroup.LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT, android.view.ViewGroup.LayoutParams.FILL_PARENT));
|
141
|
-
var parentView = new android.widget.LinearLayout(context);
|
142
|
-
parentView.setOnTouchListener(new android.view.View.OnTouchListener({
|
143
|
-
onTouch: function (view, event) {
|
144
|
-
return true;
|
145
|
-
}
|
146
|
-
}));
|
147
|
-
ViewCompatNamespace.ViewCompat.setElevation(parentView, 9.0);
|
148
|
-
var params = parentView.getLayoutParams();
|
149
|
-
var parentViewParams = params
|
150
|
-
? params
|
151
|
-
: new android.widget.LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
|
152
|
-
var defaultPadding = 10 * platform_1.screen.mainScreen.scale;
|
153
|
-
parentView.setPadding(defaultPadding, defaultPadding, defaultPadding, defaultPadding);
|
154
|
-
if (options.margin !== undefined) {
|
155
|
-
var margin = options.margin * platform_1.screen.mainScreen.scale;
|
156
|
-
parentViewParams.setMargins(margin, margin, margin, margin);
|
157
|
-
}
|
158
|
-
parentView.setLayoutParams(parentViewParams);
|
159
|
-
var backgroundColor = options.backgroundColor
|
160
|
-
? new color_1.Color(options.backgroundColor).android
|
161
|
-
: defaultBackgroundColor;
|
162
|
-
if (options.hideBezel) {
|
163
|
-
parentView.setBackgroundColor(android.graphics.Color.TRANSPARENT);
|
164
|
-
}
|
165
|
-
else {
|
166
|
-
var border = new android.graphics.drawable.ShapeDrawable();
|
167
|
-
border.getPaint().setColor(backgroundColor);
|
168
|
-
var cornerRadiusValue = 8;
|
169
|
-
var cornerRadius = Array.create('float', 8);
|
170
|
-
cornerRadius[0] = cornerRadiusValue;
|
171
|
-
cornerRadius[1] = cornerRadiusValue;
|
172
|
-
cornerRadius[2] = cornerRadiusValue;
|
173
|
-
cornerRadius[3] = cornerRadiusValue;
|
174
|
-
cornerRadius[4] = cornerRadiusValue;
|
175
|
-
cornerRadius[5] = cornerRadiusValue;
|
176
|
-
cornerRadius[6] = cornerRadiusValue;
|
177
|
-
cornerRadius[7] = cornerRadiusValue;
|
178
|
-
var shape = new android.graphics.drawable.shapes.RoundRectShape(cornerRadius, null, null);
|
179
|
-
border.setShape(shape);
|
180
|
-
parentView.setBackgroundDrawable(border);
|
181
|
-
}
|
182
|
-
parentView.setGravity(android.view.Gravity.CENTER);
|
183
|
-
parentView.setOrientation(android.widget.LinearLayout.VERTICAL);
|
184
|
-
var progressView;
|
185
|
-
var customOrText = options.mode === loading_indicator_common_1.Mode.CustomView || options.mode === loading_indicator_common_1.Mode.Text;
|
186
|
-
if (!customOrText) {
|
187
|
-
var determinate = options.progress !== undefined ||
|
188
|
-
options.mode === loading_indicator_common_1.Mode.Determinate ||
|
189
|
-
options.mode === loading_indicator_common_1.Mode.DeterminateHorizontalBar ||
|
190
|
-
options.mode === loading_indicator_common_1.Mode.AnnularDeterminate;
|
191
|
-
if (determinate) {
|
192
|
-
progressView = new android.widget.ProgressBar(context, null, R_ATTR_PROGRESS_BAR_STYLE_HORIZONTAL);
|
193
|
-
}
|
194
|
-
else {
|
195
|
-
progressView = new android.widget.ProgressBar(context);
|
196
|
-
}
|
197
|
-
progressView.setId(this._progressId);
|
198
|
-
parentView.addView(progressView);
|
199
|
-
}
|
200
|
-
if (options.mode === loading_indicator_common_1.Mode.CustomView) {
|
201
|
-
if (options.customView) {
|
202
|
-
var customView = this._createCustomView(context, options);
|
203
|
-
if (customView) {
|
204
|
-
parentView.addView(customView);
|
205
|
-
}
|
206
|
-
}
|
207
|
-
}
|
208
|
-
if (options.message) {
|
209
|
-
var messageView = new android.widget.TextView(context);
|
210
|
-
messageView.setText(options.message);
|
211
|
-
messageView.setId(this._messageId);
|
212
|
-
if (options.color) {
|
213
|
-
messageView.setTextColor(defaultTextNativeColor);
|
214
|
-
}
|
215
|
-
messageView.setLayoutParams(new android.widget.LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.WRAP_CONTENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT));
|
216
|
-
parentView.addView(messageView);
|
217
|
-
}
|
218
|
-
if (options.details) {
|
219
|
-
var detailsView = new android.widget.TextView(context);
|
220
|
-
detailsView.setText(options.details);
|
221
|
-
detailsView.setId(this._detailsId);
|
222
|
-
detailsView.setTextColor(defaultDetailsNativeColor);
|
223
|
-
detailsView.setLayoutParams(new android.widget.LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.WRAP_CONTENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT));
|
224
|
-
parentView.addView(detailsView);
|
225
|
-
}
|
226
|
-
switch (options.mode) {
|
227
|
-
case loading_indicator_common_1.Mode.CustomView:
|
228
|
-
break;
|
229
|
-
case loading_indicator_common_1.Mode.AnnularDeterminate:
|
230
|
-
progressView.setIndeterminate(false);
|
231
|
-
progressView.setMax(100);
|
232
|
-
progressView.setProgress(0);
|
233
|
-
progressView.setProgressDrawable(this._getProgressDrawable());
|
234
|
-
progressView.setBackgroundDrawable(this._getBackgroundDrawable());
|
235
|
-
progressView.setLayoutParams(new android.widget.LinearLayout.LayoutParams(60 * platform_1.screen.mainScreen.scale, 60 * platform_1.screen.mainScreen.scale));
|
236
|
-
break;
|
237
|
-
case loading_indicator_common_1.Mode.Determinate:
|
238
|
-
progressView.setIndeterminate(false);
|
239
|
-
progressView.setMax(100);
|
240
|
-
progressView.setProgress(0);
|
241
|
-
progressView.setProgressDrawable(this._getProgressDrawableThick());
|
242
|
-
progressView.setBackgroundDrawable(this._getBackgroundDrawable());
|
243
|
-
progressView.setLayoutParams(new android.widget.LinearLayout.LayoutParams(60 * platform_1.screen.mainScreen.scale, 60 * platform_1.screen.mainScreen.scale));
|
244
|
-
break;
|
245
|
-
case loading_indicator_common_1.Mode.DeterminateHorizontalBar:
|
246
|
-
progressView.setIndeterminate(false);
|
247
|
-
progressView.setMax(100);
|
248
|
-
progressView.setProgress(0);
|
249
|
-
break;
|
250
|
-
case loading_indicator_common_1.Mode.Text:
|
251
|
-
break;
|
252
|
-
case loading_indicator_common_1.Mode.Indeterminate:
|
253
|
-
progressView.setIndeterminate(true);
|
254
|
-
break;
|
255
|
-
default:
|
256
|
-
progressView.setIndeterminate(options.progress !== undefined ? false : true);
|
257
|
-
break;
|
258
|
-
}
|
259
|
-
if (options.progress !== undefined ||
|
260
|
-
options.mode === loading_indicator_common_1.Mode.Determinate ||
|
261
|
-
options.mode === loading_indicator_common_1.Mode.AnnularDeterminate ||
|
262
|
-
options.mode === loading_indicator_common_1.Mode.DeterminateHorizontalBar ||
|
263
|
-
options.mode === loading_indicator_common_1.Mode.Indeterminate ||
|
264
|
-
!options.mode) {
|
265
|
-
if (options.color) {
|
266
|
-
this._setColor(options.color, progressView);
|
267
|
-
this._currentProgressColor = new color_1.Color(options.color);
|
268
|
-
}
|
269
|
-
if (options.backgroundColor) {
|
270
|
-
this._setBackgroundColor(options.backgroundColor, progressView);
|
271
|
-
}
|
272
|
-
}
|
273
|
-
contentView.addView(parentView);
|
274
|
-
this._popOver.setContentView(contentView);
|
275
|
-
var view = frame_1.Frame.topmost().android.rootViewGroup ||
|
276
|
-
frame_1.Frame.topmost().currentPage.android;
|
277
|
-
if (options.android && options.android.view) {
|
278
|
-
var nativeView = options.android.view;
|
279
|
-
this._popOver.setWidth(nativeView.getWidth());
|
280
|
-
this._popOver.setHeight(nativeView.getHeight());
|
281
|
-
this._popOver.showAtLocation(nativeView, android.view.Gravity.CENTER, 0, 0);
|
282
|
-
}
|
283
|
-
else {
|
284
|
-
this._popOver.setWidth(platform_1.screen.mainScreen.widthPixels);
|
285
|
-
this._popOver.setHeight(platform_1.screen.mainScreen.heightPixels);
|
286
|
-
this._popOver.showAtLocation(view, android.view.Gravity.CENTER, 0, 0);
|
287
|
-
}
|
288
|
-
};
|
289
|
-
LoadingIndicator.prototype._updatePopOver = function (context, options) {
|
290
|
-
var contentView = this._popOver.getContentView();
|
291
|
-
var parentView = contentView.getChildAt(0);
|
292
|
-
var count = parentView.getChildCount();
|
293
|
-
var defaultTextColor = new color_1.Color(options.color || 'black');
|
294
|
-
var defaultTextNativeColor = defaultTextColor.android
|
295
|
-
? defaultTextColor.android
|
296
|
-
: android.graphics.Color.BLACK;
|
297
|
-
var defaultDetailsNativeColor = new color_1.Color(255 * 0.8, defaultTextColor.r, defaultTextColor.g, defaultTextColor.b).android;
|
298
|
-
if (options.mode === loading_indicator_common_1.Mode.Text) {
|
299
|
-
var progressView = parentView.getChildAt(0);
|
300
|
-
if (progressView) {
|
301
|
-
var progressViewId = progressView.getId();
|
302
|
-
if (progressViewId === this._progressId) {
|
303
|
-
parentView.removeView(progressView);
|
304
|
-
count = parentView.getChildCount();
|
305
|
-
}
|
306
|
-
}
|
307
|
-
}
|
308
|
-
if (options.mode === loading_indicator_common_1.Mode.CustomView) {
|
309
|
-
for (var i = 0; i < count; i++) {
|
310
|
-
var view = parentView.getChildAt(i);
|
311
|
-
parentView.removeView(view);
|
312
|
-
}
|
313
|
-
var customView = this._createCustomView(context, options);
|
314
|
-
if (customView) {
|
315
|
-
parentView.addView(customView);
|
316
|
-
}
|
317
|
-
count = parentView.getChildCount();
|
318
|
-
}
|
319
|
-
if (options.progress &&
|
320
|
-
options.mode !== loading_indicator_common_1.Mode.Text &&
|
321
|
-
options.mode !== loading_indicator_common_1.Mode.CustomView) {
|
322
|
-
var progressView = parentView.getChildAt(0);
|
323
|
-
var progressViewId = progressView.getId();
|
324
|
-
if (progressView instanceof android.widget.ProgressBar &&
|
325
|
-
progressViewId === this._progressId &&
|
326
|
-
progressView.isIndeterminate()) {
|
327
|
-
parentView.removeView(progressView);
|
328
|
-
progressView = this._createDeterminateProgressView(context);
|
329
|
-
parentView.addView(progressView, 0);
|
330
|
-
}
|
331
|
-
if (!(progressView instanceof android.widget.ProgressBar)) {
|
332
|
-
progressView = this._createDeterminateProgressView(context);
|
333
|
-
parentView.addView(progressView, 0);
|
334
|
-
}
|
335
|
-
count = parentView.getChildCount();
|
336
|
-
if (options.color) {
|
337
|
-
this._setColor(options.color, progressView);
|
338
|
-
this._currentProgressColor = new color_1.Color(options.color);
|
339
|
-
}
|
340
|
-
if (options.backgroundColor) {
|
341
|
-
this._setBackgroundColor(options.backgroundColor, progressView);
|
342
|
-
}
|
343
|
-
progressView.setProgress(options.progress * 100);
|
344
|
-
}
|
345
|
-
if (!options.progress &&
|
346
|
-
options.mode !== loading_indicator_common_1.Mode.Text &&
|
347
|
-
options.mode !== loading_indicator_common_1.Mode.CustomView &&
|
348
|
-
options.mode === loading_indicator_common_1.Mode.Indeterminate) {
|
349
|
-
var progressView = parentView.getChildAt(0);
|
350
|
-
if (progressView instanceof android.widget.ProgressBar === false || progressView === undefined) {
|
351
|
-
progressView = new android.widget.ProgressBar(context);
|
352
|
-
}
|
353
|
-
if (options.color) {
|
354
|
-
this._setColor(options.color, progressView);
|
355
|
-
this._currentProgressColor = new color_1.Color(options.color);
|
356
|
-
}
|
357
|
-
if (options.backgroundColor) {
|
358
|
-
this._setBackgroundColor(options.backgroundColor, progressView);
|
359
|
-
}
|
360
|
-
count = parentView.getChildCount();
|
361
|
-
}
|
362
|
-
if (options.message) {
|
363
|
-
var messageView = void 0;
|
364
|
-
var view = void 0;
|
365
|
-
var firstView = parentView.getChildAt(0);
|
366
|
-
switch (count) {
|
367
|
-
case 1:
|
368
|
-
if (firstView.getId() === this._messageId) {
|
369
|
-
firstView.setTextColor(defaultTextNativeColor);
|
370
|
-
firstView.setText(options.message);
|
371
|
-
}
|
372
|
-
else {
|
373
|
-
messageView = new android.widget.TextView(context);
|
374
|
-
messageView.setId(this._messageId);
|
375
|
-
messageView.setText(options.message);
|
376
|
-
messageView.setTextColor(defaultTextNativeColor);
|
377
|
-
messageView.setLayoutParams(new android.widget.LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.WRAP_CONTENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT));
|
378
|
-
parentView.addView(messageView);
|
379
|
-
}
|
380
|
-
break;
|
381
|
-
case 2:
|
382
|
-
view = parentView.getChildAt(1);
|
383
|
-
var viewId = view.getId();
|
384
|
-
if (viewId === this._messageId) {
|
385
|
-
view.setText(options.message);
|
386
|
-
view.setTextColor(defaultTextNativeColor);
|
387
|
-
}
|
388
|
-
else if (viewId === this._detailsId) {
|
389
|
-
messageView = new android.widget.TextView(context);
|
390
|
-
messageView.setId(this._messageId);
|
391
|
-
messageView.setText(options.message);
|
392
|
-
messageView.setTextColor(defaultTextNativeColor);
|
393
|
-
messageView.setLayoutParams(new android.widget.LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.WRAP_CONTENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT));
|
394
|
-
parentView.addView(messageView, 1);
|
395
|
-
}
|
396
|
-
break;
|
397
|
-
case 3:
|
398
|
-
view = parentView.getChildAt(2);
|
399
|
-
view.setTextColor(defaultTextNativeColor);
|
400
|
-
view.setText(options.message);
|
401
|
-
break;
|
402
|
-
default:
|
403
|
-
break;
|
404
|
-
}
|
405
|
-
count = parentView.getChildCount();
|
406
|
-
}
|
407
|
-
if (options.details) {
|
408
|
-
var detailsView = void 0;
|
409
|
-
switch (count) {
|
410
|
-
case 1:
|
411
|
-
var firstView = parentView.getChildAt(0);
|
412
|
-
if (firstView === this._detailsId) {
|
413
|
-
firstView.setTextColor(defaultDetailsNativeColor);
|
414
|
-
firstView.setText(options.details);
|
415
|
-
}
|
416
|
-
else {
|
417
|
-
detailsView = new android.widget.TextView(context);
|
418
|
-
detailsView.setId(this._detailsId);
|
419
|
-
detailsView.setTextColor(defaultDetailsNativeColor);
|
420
|
-
detailsView.setText(options.details);
|
421
|
-
detailsView.setLayoutParams(new android.widget.LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.WRAP_CONTENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT));
|
422
|
-
parentView.addView(detailsView);
|
423
|
-
}
|
424
|
-
break;
|
425
|
-
case 2:
|
426
|
-
detailsView = parentView.getChildAt(1);
|
427
|
-
var detailsViewId = detailsView.getId();
|
428
|
-
if (detailsViewId === this._detailsId) {
|
429
|
-
detailsView.setTextColor(defaultDetailsNativeColor);
|
430
|
-
detailsView.setText(options.details);
|
431
|
-
}
|
432
|
-
else if (detailsViewId === this._messageId) {
|
433
|
-
detailsView = new android.widget.TextView(context);
|
434
|
-
detailsView.setId(this._detailsId);
|
435
|
-
detailsView.setTextColor(defaultDetailsNativeColor);
|
436
|
-
detailsView.setText(options.details);
|
437
|
-
detailsView.setLayoutParams(new android.widget.LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.WRAP_CONTENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT));
|
438
|
-
parentView.addView(detailsView, 2);
|
439
|
-
}
|
440
|
-
break;
|
441
|
-
case 3:
|
442
|
-
detailsView = parentView.getChildAt(2);
|
443
|
-
detailsView.setTextColor(defaultDetailsNativeColor);
|
444
|
-
detailsView.setText(options.details);
|
445
|
-
break;
|
446
|
-
default:
|
447
|
-
break;
|
448
|
-
}
|
449
|
-
}
|
450
|
-
this._popOver.update();
|
451
|
-
};
|
452
|
-
LoadingIndicator.prototype._createCustomView = function (context, options) {
|
453
|
-
var customView;
|
454
|
-
if (options.customView instanceof android.graphics.Bitmap) {
|
455
|
-
customView = new android.widget.ImageView(context);
|
456
|
-
customView.setImageBitmap(options.customView);
|
457
|
-
}
|
458
|
-
else if (options.customView instanceof android.view.View) {
|
459
|
-
customView = options.customView;
|
460
|
-
}
|
461
|
-
else if (typeof options.customView === 'string') {
|
462
|
-
customView = new android.widget.ImageView(context);
|
463
|
-
var fileName = options.customView
|
464
|
-
.replace('.jpg', '')
|
465
|
-
.replace('.png', '')
|
466
|
-
.replace('.jpeg', '');
|
467
|
-
var image = image_source_1.ImageSource.fromFileOrResourceSync('res://' + fileName);
|
468
|
-
if (image && image.android) {
|
469
|
-
customView.setImageBitmap(image.android);
|
470
|
-
}
|
471
|
-
}
|
472
|
-
customView.setId(this._customViewId);
|
473
|
-
return customView;
|
474
|
-
};
|
475
|
-
LoadingIndicator.prototype._createDeterminateProgressView = function (context) {
|
476
|
-
var progressView = new android.widget.ProgressBar(context, null, R_ATTR_PROGRESS_BAR_STYLE_HORIZONTAL);
|
477
|
-
progressView.setId(this._progressId);
|
478
|
-
progressView.setMax(100);
|
479
|
-
progressView.setProgress(0);
|
480
|
-
progressView.setProgressDrawable(this._getProgressDrawable());
|
481
|
-
progressView.setBackgroundDrawable(this._getBackgroundDrawable());
|
482
|
-
progressView.setLayoutParams(new android.widget.LinearLayout.LayoutParams(60 * platform_1.screen.mainScreen.scale, 60 * platform_1.screen.mainScreen.scale));
|
483
|
-
return progressView;
|
484
|
-
};
|
485
|
-
LoadingIndicator.prototype._setBackgroundColor = function (color, view) {
|
486
|
-
var progressDrawable = view.getProgressDrawable();
|
487
|
-
var indeterminateDrawable = view.getIndeterminateDrawable();
|
488
|
-
if (progressDrawable instanceof android.graphics.drawable.LayerDrawable &&
|
489
|
-
progressDrawable.getNumberOfLayers() > 0) {
|
490
|
-
var backgroundDrawable = progressDrawable.getDrawable(0);
|
491
|
-
if (backgroundDrawable) {
|
492
|
-
backgroundDrawable.setColorFilter(new color_1.Color(color).android, android.graphics.PorterDuff.Mode.SRC_IN);
|
493
|
-
}
|
494
|
-
}
|
495
|
-
if (indeterminateDrawable instanceof
|
496
|
-
android.graphics.drawable.LayerDrawable &&
|
497
|
-
indeterminateDrawable.getNumberOfLayers() > 0) {
|
498
|
-
var backgroundDrawable = indeterminateDrawable.getDrawable(0);
|
499
|
-
if (backgroundDrawable) {
|
500
|
-
backgroundDrawable.setColorFilter(new color_1.Color(color).android, android.graphics.PorterDuff.Mode.SRC_IN);
|
501
|
-
}
|
502
|
-
}
|
503
|
-
};
|
504
|
-
LoadingIndicator.prototype._setColor = function (color, view) {
|
505
|
-
var progressDrawable = view.getProgressDrawable();
|
506
|
-
var indeterminateDrawable = view.getIndeterminateDrawable();
|
507
|
-
if (progressDrawable) {
|
508
|
-
progressDrawable.setColorFilter(new color_1.Color(color).android, android.graphics.PorterDuff.Mode.SRC_IN);
|
509
|
-
}
|
510
|
-
if (indeterminateDrawable) {
|
511
|
-
indeterminateDrawable.setColorFilter(new color_1.Color(color).android, android.graphics.PorterDuff.Mode.SRC_IN);
|
512
|
-
}
|
513
|
-
};
|
514
|
-
LoadingIndicator.prototype._getResources = function () {
|
515
|
-
var ctx = application.android.foregroundActivity;
|
516
|
-
return ctx.getResources();
|
517
|
-
};
|
518
|
-
LoadingIndicator.prototype._getBackgroundDrawable = function () {
|
519
|
-
return this._getResources().getDrawable(com.github.triniwiz.ns.loading.indicator.R.drawable.circle_shape);
|
520
|
-
};
|
521
|
-
LoadingIndicator.prototype._getProgressDrawable = function () {
|
522
|
-
return this._getResources().getDrawable(com.github.triniwiz.ns.loading.indicator.R.drawable.circular_progress_bar);
|
523
|
-
};
|
524
|
-
LoadingIndicator.prototype._getProgressDrawableThick = function () {
|
525
|
-
return this._getResources().getDrawable(com.github.triniwiz.ns.loading.indicator.R.drawable
|
526
|
-
.circular_progress_bar_thick);
|
527
|
-
};
|
528
|
-
return LoadingIndicator;
|
529
|
-
}());
|
530
|
-
exports.LoadingIndicator = LoadingIndicator;
|
531
|
-
//# sourceMappingURL=loading-indicator.android.js.map
|
@@ -1,38 +0,0 @@
|
|
1
|
-
export interface OptionsCommon {
|
2
|
-
message?: string;
|
3
|
-
details?: string;
|
4
|
-
color?: string;
|
5
|
-
backgroundColor?: string;
|
6
|
-
progress?: number;
|
7
|
-
margin?: number;
|
8
|
-
userInteractionEnabled?: boolean;
|
9
|
-
dimBackground?: boolean;
|
10
|
-
hideBezel?: boolean;
|
11
|
-
mode?: Mode;
|
12
|
-
customView?: any;
|
13
|
-
ios?: OptionsIOS;
|
14
|
-
android?: OptionsAndroid;
|
15
|
-
}
|
16
|
-
export interface OptionsIOS {
|
17
|
-
view?: UIView;
|
18
|
-
square?: boolean;
|
19
|
-
}
|
20
|
-
export interface OptionsAndroid {
|
21
|
-
view?: android.view.View;
|
22
|
-
max?: number;
|
23
|
-
progressNumberFormat?: string;
|
24
|
-
progressPercentFormat?: number;
|
25
|
-
progressStyle?: number;
|
26
|
-
secondaryProgress?: number;
|
27
|
-
cancelable?: boolean;
|
28
|
-
cancelListener?: (dialog: any) => void;
|
29
|
-
elevation?: number;
|
30
|
-
}
|
31
|
-
export declare enum Mode {
|
32
|
-
Indeterminate = 0,
|
33
|
-
Determinate = 1,
|
34
|
-
DeterminateHorizontalBar = 2,
|
35
|
-
AnnularDeterminate = 3,
|
36
|
-
CustomView = 4,
|
37
|
-
Text = 5
|
38
|
-
}
|
package/references.d.ts
DELETED