@nstudio/nativescript-loading-indicator 3.0.3 → 4.1.1

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.
@@ -1,28 +1,18 @@
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()
1
+ import { Application, Color, Frame, ImageSource, Screen, } from '@nativescript/core';
2
+ import { Mode } from './common';
3
+ export * from './common';
4
+ const R_ATTR_PROGRESS_BAR_STYLE_HORIZONTAL = 0x01010078;
5
+ const PACKAGE = 'com.github.triniwiz.ns.loading.indicator';
6
+ const ViewCompatNamespace = useAndroidX()
17
7
  ? androidx.core.view
18
8
  : android.support.v4.view;
19
9
  function useAndroidX() {
20
10
  return global.androidx && global.androidx.core.view;
21
11
  }
22
- var HIDE_RETRY_MS = 100;
23
- var LoadingIndicator = (function () {
24
- function LoadingIndicator() {
25
- this._defaultProgressColor = new color_1.Color('#007DD6');
12
+ const HIDE_RETRY_MS = 100;
13
+ export class LoadingIndicator {
14
+ constructor() {
15
+ this._defaultProgressColor = new Color('#007DD6');
26
16
  this._progressId = android.view.View.generateViewId();
27
17
  this._messageId = android.view.View.generateViewId();
28
18
  this._detailsId = android.view.View.generateViewId();
@@ -30,43 +20,45 @@ var LoadingIndicator = (function () {
30
20
  this._loadersInstances = [];
31
21
  this._isCreatingPopOver = false;
32
22
  }
33
- LoadingIndicator.prototype.show = function (options) {
34
- var _this = this;
35
- var context = utils_1.ad.getApplicationContext();
23
+ show(options) {
24
+ const context = Application.android.foregroundActivity || Application.android.startActivity;
36
25
  if (context) {
37
26
  options = options || {};
38
27
  options.android = options.android || {};
39
- options.userInteractionEnabled = options.userInteractionEnabled !== undefined;
28
+ options.userInteractionEnabled =
29
+ options.userInteractionEnabled !== undefined;
40
30
  if (!this._popOver) {
41
31
  this._isCreatingPopOver = true;
42
- new Promise(function (resolve) {
43
- _this._createPopOver(context, options);
44
- _this._loadersInstances.push(_this._popOver);
32
+ new Promise((resolve) => {
33
+ this._createPopOver(context, options);
34
+ this._loadersInstances.push(this._popOver);
45
35
  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);
36
+ })
37
+ .then(() => {
38
+ this._isCreatingPopOver = false;
39
+ })
40
+ .catch((error) => {
41
+ // Ensure this is left in a clean state.
42
+ this._isCreatingPopOver = false;
43
+ const message = error && error.message ? `: ${error.message}` : '';
44
+ console.error(`Error creating Loading Indicator Pop Over${message}`);
52
45
  });
53
46
  return;
54
47
  }
55
48
  this._updatePopOver(context, options);
56
49
  }
57
- };
58
- LoadingIndicator.prototype.hide = function (targetView, attemptTimeout) {
59
- if (attemptTimeout === void 0) { attemptTimeout = 1000; }
50
+ }
51
+ hide(targetView, attemptTimeout = 1000) {
60
52
  if (this._isCreatingPopOver) {
61
53
  this._waitForCreatePopOver(attemptTimeout);
62
54
  return;
63
55
  }
64
56
  this._tryHide();
65
- };
66
- LoadingIndicator.prototype._tryHide = function () {
57
+ }
58
+ _tryHide() {
67
59
  try {
68
- for (var i = 0; i < this._loadersInstances.length; i++) {
69
- var loader = this._loadersInstances[i];
60
+ for (let i = 0; i < this._loadersInstances.length; i++) {
61
+ const loader = this._loadersInstances[i];
70
62
  if (loader) {
71
63
  if (this._isShowing(loader)) {
72
64
  loader.dismiss();
@@ -80,48 +72,40 @@ var LoadingIndicator = (function () {
80
72
  catch (e) {
81
73
  console.log(e);
82
74
  }
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
- }); };
75
+ }
76
+ _waitForCreatePopOver(attemptTimeout) {
77
+ const startTime = Date.now();
78
+ const awaitCreation = async () => {
79
+ if (!this._isCreatingPopOver) {
80
+ return this._tryHide();
81
+ }
82
+ if (Date.now() > startTime + attemptTimeout) {
83
+ console.warn('Hide attempt timeout exceeded');
84
+ return;
85
+ }
86
+ await new Promise((resolve) => setTimeout(resolve, HIDE_RETRY_MS));
87
+ return awaitCreation();
88
+ };
105
89
  return awaitCreation();
106
- };
107
- LoadingIndicator.prototype._isShowing = function (loader) {
90
+ }
91
+ _isShowing(loader) {
108
92
  return loader.isShowing();
109
- };
110
- LoadingIndicator.prototype._createPopOver = function (context, options) {
93
+ }
94
+ _createPopOver(context, options) {
111
95
  this._popOver = new android.widget.PopupWindow();
112
- var ref = new WeakRef(this);
96
+ const ref = new WeakRef(this);
113
97
  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
98
+ const contentView = new android.widget.LinearLayout(context);
99
+ const defaultTextColor = new Color(options.color || '#000');
100
+ const defaultTextNativeColor = defaultTextColor.android
117
101
  ? defaultTextColor.android
118
102
  : android.graphics.Color.BLACK;
119
- var defaultDetailsNativeColor = new color_1.Color(255 * 0.8, defaultTextColor.r, defaultTextColor.g, defaultTextColor.b).android;
103
+ const defaultDetailsNativeColor = new Color(255 * 0.8, defaultTextColor.r, defaultTextColor.g, defaultTextColor.b).android;
120
104
  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();
105
+ onTouch(view, event) {
106
+ const cancelListener = options.android.cancelListener;
107
+ const cancelable = options.android.cancelable;
108
+ const owner = ref.get();
125
109
  if (cancelListener && typeof cancelListener === 'function') {
126
110
  if (owner && cancelable) {
127
111
  owner._popOver.dismiss();
@@ -130,43 +114,47 @@ var LoadingIndicator = (function () {
130
114
  }
131
115
  }
132
116
  return true;
133
- }
117
+ },
134
118
  }));
135
- var defaultBackgroundColor = android.graphics.Color.WHITE;
119
+ const defaultBackgroundColor = android.graphics.Color.WHITE;
120
+ // handle dimming background option
136
121
  contentView.setBackgroundColor(options.dimBackground
137
- ? new color_1.Color(255 * 0.6, 0, 0, 0).android
122
+ ? new Color(255 * 0.6, 0, 0, 0).android
138
123
  : android.graphics.Color.TRANSPARENT);
139
124
  contentView.setGravity(android.view.Gravity.CENTER);
140
125
  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);
126
+ const parentView = new android.widget.LinearLayout(context);
142
127
  parentView.setOnTouchListener(new android.view.View.OnTouchListener({
143
- onTouch: function (view, event) {
128
+ onTouch(view, event) {
144
129
  return true;
145
- }
130
+ },
146
131
  }));
132
+ // Use the ViewCompatNamespace to properly map to `ViewCompat` for AndroidX and support lib versions to avoid breaking change
147
133
  ViewCompatNamespace.ViewCompat.setElevation(parentView, 9.0);
148
- var params = parentView.getLayoutParams();
149
- var parentViewParams = params
134
+ const params = parentView.getLayoutParams();
135
+ const parentViewParams = params
150
136
  ? params
151
137
  : 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;
138
+ const defaultPadding = 10 * Screen.mainScreen.scale;
153
139
  parentView.setPadding(defaultPadding, defaultPadding, defaultPadding, defaultPadding);
140
+ // handle margin option
154
141
  if (options.margin !== undefined) {
155
- var margin = options.margin * platform_1.screen.mainScreen.scale;
142
+ const margin = options.margin * Screen.mainScreen.scale;
156
143
  parentViewParams.setMargins(margin, margin, margin, margin);
157
144
  }
158
145
  parentView.setLayoutParams(parentViewParams);
159
- var backgroundColor = options.backgroundColor
160
- ? new color_1.Color(options.backgroundColor).android
146
+ const backgroundColor = options.backgroundColor
147
+ ? new Color(options.backgroundColor).android
161
148
  : defaultBackgroundColor;
149
+ // handle hideBezel option
162
150
  if (options.hideBezel) {
163
151
  parentView.setBackgroundColor(android.graphics.Color.TRANSPARENT);
164
152
  }
165
153
  else {
166
- var border = new android.graphics.drawable.ShapeDrawable();
154
+ const border = new android.graphics.drawable.ShapeDrawable();
167
155
  border.getPaint().setColor(backgroundColor);
168
- var cornerRadiusValue = 8;
169
- var cornerRadius = Array.create('float', 8);
156
+ const cornerRadiusValue = 8;
157
+ const cornerRadius = Array.create('float', 8);
170
158
  cornerRadius[0] = cornerRadiusValue;
171
159
  cornerRadius[1] = cornerRadiusValue;
172
160
  cornerRadius[2] = cornerRadiusValue;
@@ -175,19 +163,19 @@ var LoadingIndicator = (function () {
175
163
  cornerRadius[5] = cornerRadiusValue;
176
164
  cornerRadius[6] = cornerRadiusValue;
177
165
  cornerRadius[7] = cornerRadiusValue;
178
- var shape = new android.graphics.drawable.shapes.RoundRectShape(cornerRadius, null, null);
166
+ const shape = new android.graphics.drawable.shapes.RoundRectShape(cornerRadius, null, null);
179
167
  border.setShape(shape);
180
168
  parentView.setBackgroundDrawable(border);
181
169
  }
182
170
  parentView.setGravity(android.view.Gravity.CENTER);
183
171
  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;
172
+ let progressView;
173
+ const customOrText = options.mode === Mode.CustomView || options.mode === Mode.Text;
186
174
  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;
175
+ const determinate = options.progress !== undefined ||
176
+ options.mode === Mode.Determinate ||
177
+ options.mode === Mode.DeterminateHorizontalBar ||
178
+ options.mode === Mode.AnnularDeterminate;
191
179
  if (determinate) {
192
180
  progressView = new android.widget.ProgressBar(context, null, R_ATTR_PROGRESS_BAR_STYLE_HORIZONTAL);
193
181
  }
@@ -197,16 +185,17 @@ var LoadingIndicator = (function () {
197
185
  progressView.setId(this._progressId);
198
186
  parentView.addView(progressView);
199
187
  }
200
- if (options.mode === loading_indicator_common_1.Mode.CustomView) {
188
+ // handle customView option
189
+ if (options.mode === Mode.CustomView) {
201
190
  if (options.customView) {
202
- var customView = this._createCustomView(context, options);
191
+ const customView = this._createCustomView(context, options);
203
192
  if (customView) {
204
193
  parentView.addView(customView);
205
194
  }
206
195
  }
207
196
  }
208
197
  if (options.message) {
209
- var messageView = new android.widget.TextView(context);
198
+ const messageView = new android.widget.TextView(context);
210
199
  messageView.setText(options.message);
211
200
  messageView.setId(this._messageId);
212
201
  if (options.color) {
@@ -215,8 +204,9 @@ var LoadingIndicator = (function () {
215
204
  messageView.setLayoutParams(new android.widget.LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.WRAP_CONTENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT));
216
205
  parentView.addView(messageView);
217
206
  }
207
+ // handle details message text
218
208
  if (options.details) {
219
- var detailsView = new android.widget.TextView(context);
209
+ const detailsView = new android.widget.TextView(context);
220
210
  detailsView.setText(options.details);
221
211
  detailsView.setId(this._detailsId);
222
212
  detailsView.setTextColor(defaultDetailsNativeColor);
@@ -224,32 +214,32 @@ var LoadingIndicator = (function () {
224
214
  parentView.addView(detailsView);
225
215
  }
226
216
  switch (options.mode) {
227
- case loading_indicator_common_1.Mode.CustomView:
217
+ case Mode.CustomView:
228
218
  break;
229
- case loading_indicator_common_1.Mode.AnnularDeterminate:
219
+ case Mode.AnnularDeterminate:
230
220
  progressView.setIndeterminate(false);
231
221
  progressView.setMax(100);
232
222
  progressView.setProgress(0);
233
223
  progressView.setProgressDrawable(this._getProgressDrawable());
234
224
  progressView.setBackgroundDrawable(this._getBackgroundDrawable());
235
- progressView.setLayoutParams(new android.widget.LinearLayout.LayoutParams(60 * platform_1.screen.mainScreen.scale, 60 * platform_1.screen.mainScreen.scale));
225
+ progressView.setLayoutParams(new android.widget.LinearLayout.LayoutParams(60 * Screen.mainScreen.scale, 60 * Screen.mainScreen.scale));
236
226
  break;
237
- case loading_indicator_common_1.Mode.Determinate:
227
+ case Mode.Determinate:
238
228
  progressView.setIndeterminate(false);
239
229
  progressView.setMax(100);
240
230
  progressView.setProgress(0);
241
231
  progressView.setProgressDrawable(this._getProgressDrawableThick());
242
232
  progressView.setBackgroundDrawable(this._getBackgroundDrawable());
243
- progressView.setLayoutParams(new android.widget.LinearLayout.LayoutParams(60 * platform_1.screen.mainScreen.scale, 60 * platform_1.screen.mainScreen.scale));
233
+ progressView.setLayoutParams(new android.widget.LinearLayout.LayoutParams(60 * Screen.mainScreen.scale, 60 * Screen.mainScreen.scale));
244
234
  break;
245
- case loading_indicator_common_1.Mode.DeterminateHorizontalBar:
235
+ case Mode.DeterminateHorizontalBar:
246
236
  progressView.setIndeterminate(false);
247
237
  progressView.setMax(100);
248
238
  progressView.setProgress(0);
249
239
  break;
250
- case loading_indicator_common_1.Mode.Text:
240
+ case Mode.Text:
251
241
  break;
252
- case loading_indicator_common_1.Mode.Indeterminate:
242
+ case Mode.Indeterminate:
253
243
  progressView.setIndeterminate(true);
254
244
  break;
255
245
  default:
@@ -257,70 +247,72 @@ var LoadingIndicator = (function () {
257
247
  break;
258
248
  }
259
249
  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 ||
250
+ options.mode === Mode.Determinate ||
251
+ options.mode === Mode.AnnularDeterminate ||
252
+ options.mode === Mode.DeterminateHorizontalBar ||
253
+ options.mode === Mode.Indeterminate ||
264
254
  !options.mode) {
265
255
  if (options.color) {
266
256
  this._setColor(options.color, progressView);
267
- this._currentProgressColor = new color_1.Color(options.color);
257
+ this._currentProgressColor = new Color(options.color);
268
258
  }
259
+ // handle background color
269
260
  if (options.backgroundColor) {
270
261
  this._setBackgroundColor(options.backgroundColor, progressView);
271
262
  }
272
263
  }
273
264
  contentView.addView(parentView);
274
265
  this._popOver.setContentView(contentView);
275
- var view = frame_1.Frame.topmost().android.rootViewGroup ||
276
- frame_1.Frame.topmost().currentPage.android;
266
+ // handle anchoring target view
277
267
  if (options.android && options.android.view) {
278
- var nativeView = options.android.view;
268
+ const nativeView = options.android.view;
279
269
  this._popOver.setWidth(nativeView.getWidth());
280
270
  this._popOver.setHeight(nativeView.getHeight());
281
271
  this._popOver.showAtLocation(nativeView, android.view.Gravity.CENTER, 0, 0);
282
272
  }
283
- else {
284
- this._popOver.setWidth(platform_1.screen.mainScreen.widthPixels);
285
- this._popOver.setHeight(platform_1.screen.mainScreen.heightPixels);
273
+ else if (Frame.topmost() && (Frame.topmost().android || (Frame.topmost().currentPage && Frame.topmost().currentPage.android))) {
274
+ const view = Frame.topmost().android.rootViewGroup ||
275
+ Frame.topmost().currentPage.android;
276
+ this._popOver.setWidth(Screen.mainScreen.widthPixels);
277
+ this._popOver.setHeight(Screen.mainScreen.heightPixels);
286
278
  this._popOver.showAtLocation(view, android.view.Gravity.CENTER, 0, 0);
287
279
  }
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
280
+ }
281
+ _updatePopOver(context, options) {
282
+ const contentView = this._popOver.getContentView();
283
+ const parentView = contentView.getChildAt(0);
284
+ let count = parentView.getChildCount();
285
+ const defaultTextColor = new Color(options.color || 'black');
286
+ const defaultTextNativeColor = defaultTextColor.android
295
287
  ? defaultTextColor.android
296
288
  : 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);
289
+ const defaultDetailsNativeColor = new Color(255 * 0.8, defaultTextColor.r, defaultTextColor.g, defaultTextColor.b).android;
290
+ if (options.mode === Mode.Text) {
291
+ const progressView = parentView.getChildAt(0);
300
292
  if (progressView) {
301
- var progressViewId = progressView.getId();
293
+ const progressViewId = progressView.getId();
302
294
  if (progressViewId === this._progressId) {
303
295
  parentView.removeView(progressView);
304
296
  count = parentView.getChildCount();
305
297
  }
306
298
  }
307
299
  }
308
- if (options.mode === loading_indicator_common_1.Mode.CustomView) {
309
- for (var i = 0; i < count; i++) {
310
- var view = parentView.getChildAt(i);
300
+ if (options.mode === Mode.CustomView) {
301
+ for (let i = 0; i < count; i++) {
302
+ const view = parentView.getChildAt(i);
311
303
  parentView.removeView(view);
312
304
  }
313
- var customView = this._createCustomView(context, options);
305
+ const customView = this._createCustomView(context, options);
314
306
  if (customView) {
315
307
  parentView.addView(customView);
316
308
  }
317
309
  count = parentView.getChildCount();
318
310
  }
319
311
  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();
312
+ options.mode !== Mode.Text &&
313
+ options.mode !== Mode.CustomView) {
314
+ let progressView = parentView.getChildAt(0);
315
+ const progressViewId = progressView.getId();
324
316
  if (progressView instanceof android.widget.ProgressBar &&
325
317
  progressViewId === this._progressId &&
326
318
  progressView.isIndeterminate()) {
@@ -335,34 +327,41 @@ var LoadingIndicator = (function () {
335
327
  count = parentView.getChildCount();
336
328
  if (options.color) {
337
329
  this._setColor(options.color, progressView);
338
- this._currentProgressColor = new color_1.Color(options.color);
330
+ this._currentProgressColor = new Color(options.color);
339
331
  }
332
+ // handle background color
340
333
  if (options.backgroundColor) {
341
334
  this._setBackgroundColor(options.backgroundColor, progressView);
342
335
  }
343
336
  progressView.setProgress(options.progress * 100);
344
337
  }
345
338
  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) {
339
+ options.mode !== Mode.Text &&
340
+ options.mode !== Mode.CustomView &&
341
+ options.mode === Mode.Indeterminate) {
342
+ /**
343
+ * Get the existing indicator if it exists, assess whether or not the
344
+ * acquired child is the correct class.
345
+ */
346
+ let progressView = parentView.getChildAt(0);
347
+ if (progressView instanceof android.widget.ProgressBar === false ||
348
+ progressView === undefined) {
351
349
  progressView = new android.widget.ProgressBar(context);
352
350
  }
353
351
  if (options.color) {
354
352
  this._setColor(options.color, progressView);
355
- this._currentProgressColor = new color_1.Color(options.color);
353
+ this._currentProgressColor = new Color(options.color);
356
354
  }
355
+ // handle background color
357
356
  if (options.backgroundColor) {
358
357
  this._setBackgroundColor(options.backgroundColor, progressView);
359
358
  }
360
359
  count = parentView.getChildCount();
361
360
  }
362
361
  if (options.message) {
363
- var messageView = void 0;
364
- var view = void 0;
365
- var firstView = parentView.getChildAt(0);
362
+ let messageView;
363
+ let view;
364
+ const firstView = parentView.getChildAt(0);
366
365
  switch (count) {
367
366
  case 1:
368
367
  if (firstView.getId() === this._messageId) {
@@ -380,7 +379,7 @@ var LoadingIndicator = (function () {
380
379
  break;
381
380
  case 2:
382
381
  view = parentView.getChildAt(1);
383
- var viewId = view.getId();
382
+ const viewId = view.getId();
384
383
  if (viewId === this._messageId) {
385
384
  view.setText(options.message);
386
385
  view.setTextColor(defaultTextNativeColor);
@@ -404,11 +403,12 @@ var LoadingIndicator = (function () {
404
403
  }
405
404
  count = parentView.getChildCount();
406
405
  }
406
+ // handle details message text
407
407
  if (options.details) {
408
- var detailsView = void 0;
408
+ let detailsView;
409
409
  switch (count) {
410
410
  case 1:
411
- var firstView = parentView.getChildAt(0);
411
+ const firstView = parentView.getChildAt(0);
412
412
  if (firstView === this._detailsId) {
413
413
  firstView.setTextColor(defaultDetailsNativeColor);
414
414
  firstView.setText(options.details);
@@ -424,7 +424,7 @@ var LoadingIndicator = (function () {
424
424
  break;
425
425
  case 2:
426
426
  detailsView = parentView.getChildAt(1);
427
- var detailsViewId = detailsView.getId();
427
+ const detailsViewId = detailsView.getId();
428
428
  if (detailsViewId === this._detailsId) {
429
429
  detailsView.setTextColor(defaultDetailsNativeColor);
430
430
  detailsView.setText(options.details);
@@ -448,9 +448,9 @@ var LoadingIndicator = (function () {
448
448
  }
449
449
  }
450
450
  this._popOver.update();
451
- };
452
- LoadingIndicator.prototype._createCustomView = function (context, options) {
453
- var customView;
451
+ }
452
+ _createCustomView(context, options) {
453
+ let customView;
454
454
  if (options.customView instanceof android.graphics.Bitmap) {
455
455
  customView = new android.widget.ImageView(context);
456
456
  customView.setImageBitmap(options.customView);
@@ -460,72 +460,70 @@ var LoadingIndicator = (function () {
460
460
  }
461
461
  else if (typeof options.customView === 'string') {
462
462
  customView = new android.widget.ImageView(context);
463
- var fileName = options.customView
463
+ const fileName = options.customView
464
464
  .replace('.jpg', '')
465
465
  .replace('.png', '')
466
466
  .replace('.jpeg', '');
467
- var image = image_source_1.ImageSource.fromFileOrResourceSync('res://' + fileName);
467
+ const image = ImageSource.fromFileOrResourceSync('res://' + fileName);
468
468
  if (image && image.android) {
469
469
  customView.setImageBitmap(image.android);
470
470
  }
471
471
  }
472
472
  customView.setId(this._customViewId);
473
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);
474
+ }
475
+ _createDeterminateProgressView(context) {
476
+ const progressView = new android.widget.ProgressBar(context, null, R_ATTR_PROGRESS_BAR_STYLE_HORIZONTAL);
477
477
  progressView.setId(this._progressId);
478
478
  progressView.setMax(100);
479
479
  progressView.setProgress(0);
480
480
  progressView.setProgressDrawable(this._getProgressDrawable());
481
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));
482
+ progressView.setLayoutParams(new android.widget.LinearLayout.LayoutParams(60 * Screen.mainScreen.scale, 60 * Screen.mainScreen.scale));
483
483
  return progressView;
484
- };
485
- LoadingIndicator.prototype._setBackgroundColor = function (color, view) {
486
- var progressDrawable = view.getProgressDrawable();
487
- var indeterminateDrawable = view.getIndeterminateDrawable();
484
+ }
485
+ _setBackgroundColor(color, view) {
486
+ const progressDrawable = view.getProgressDrawable();
487
+ const indeterminateDrawable = view.getIndeterminateDrawable();
488
488
  if (progressDrawable instanceof android.graphics.drawable.LayerDrawable &&
489
489
  progressDrawable.getNumberOfLayers() > 0) {
490
- var backgroundDrawable = progressDrawable.getDrawable(0);
490
+ const backgroundDrawable = progressDrawable.getDrawable(0);
491
491
  if (backgroundDrawable) {
492
- backgroundDrawable.setColorFilter(new color_1.Color(color).android, android.graphics.PorterDuff.Mode.SRC_IN);
492
+ backgroundDrawable.setColorFilter(new Color(color).android, android.graphics.PorterDuff.Mode.SRC_IN);
493
493
  }
494
494
  }
495
495
  if (indeterminateDrawable instanceof
496
496
  android.graphics.drawable.LayerDrawable &&
497
497
  indeterminateDrawable.getNumberOfLayers() > 0) {
498
- var backgroundDrawable = indeterminateDrawable.getDrawable(0);
498
+ const backgroundDrawable = indeterminateDrawable.getDrawable(0);
499
499
  if (backgroundDrawable) {
500
- backgroundDrawable.setColorFilter(new color_1.Color(color).android, android.graphics.PorterDuff.Mode.SRC_IN);
500
+ backgroundDrawable.setColorFilter(new Color(color).android, android.graphics.PorterDuff.Mode.SRC_IN);
501
501
  }
502
502
  }
503
- };
504
- LoadingIndicator.prototype._setColor = function (color, view) {
505
- var progressDrawable = view.getProgressDrawable();
506
- var indeterminateDrawable = view.getIndeterminateDrawable();
503
+ }
504
+ _setColor(color, view) {
505
+ const progressDrawable = view.getProgressDrawable();
506
+ const indeterminateDrawable = view.getIndeterminateDrawable();
507
507
  if (progressDrawable) {
508
- progressDrawable.setColorFilter(new color_1.Color(color).android, android.graphics.PorterDuff.Mode.SRC_IN);
508
+ progressDrawable.setColorFilter(new Color(color).android, android.graphics.PorterDuff.Mode.SRC_IN);
509
509
  }
510
510
  if (indeterminateDrawable) {
511
- indeterminateDrawable.setColorFilter(new color_1.Color(color).android, android.graphics.PorterDuff.Mode.SRC_IN);
511
+ indeterminateDrawable.setColorFilter(new Color(color).android, android.graphics.PorterDuff.Mode.SRC_IN);
512
512
  }
513
- };
514
- LoadingIndicator.prototype._getResources = function () {
515
- var ctx = application.android.foregroundActivity;
513
+ }
514
+ _getResources() {
515
+ const ctx = Application.android.foregroundActivity;
516
516
  return ctx.getResources();
517
- };
518
- LoadingIndicator.prototype._getBackgroundDrawable = function () {
517
+ }
518
+ _getBackgroundDrawable() {
519
519
  return this._getResources().getDrawable(com.github.triniwiz.ns.loading.indicator.R.drawable.circle_shape);
520
- };
521
- LoadingIndicator.prototype._getProgressDrawable = function () {
520
+ }
521
+ _getProgressDrawable() {
522
522
  return this._getResources().getDrawable(com.github.triniwiz.ns.loading.indicator.R.drawable.circular_progress_bar);
523
- };
524
- LoadingIndicator.prototype._getProgressDrawableThick = function () {
523
+ }
524
+ _getProgressDrawableThick() {
525
525
  return this._getResources().getDrawable(com.github.triniwiz.ns.loading.indicator.R.drawable
526
526
  .circular_progress_bar_thick);
527
- };
528
- return LoadingIndicator;
529
- }());
530
- exports.LoadingIndicator = LoadingIndicator;
531
- //# sourceMappingURL=loading-indicator.android.js.map
527
+ }
528
+ }
529
+ //# sourceMappingURL=index.android.js.map