uicore-ts 1.0.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.
Files changed (128) hide show
  1. package/.idea/misc.xml +6 -0
  2. package/.idea/modules.xml +8 -0
  3. package/.idea/uicore.iml +9 -0
  4. package/.idea/vcs.xml +6 -0
  5. package/LICENSE +21 -0
  6. package/README.md +5 -0
  7. package/compiledScripts/UIActionIndicator.d.ts +12 -0
  8. package/compiledScripts/UIActionIndicator.js +54 -0
  9. package/compiledScripts/UIActionIndicator.js.map +1 -0
  10. package/compiledScripts/UIBaseButton.d.ts +52 -0
  11. package/compiledScripts/UIBaseButton.js +268 -0
  12. package/compiledScripts/UIBaseButton.js.map +1 -0
  13. package/compiledScripts/UIButton.d.ts +54 -0
  14. package/compiledScripts/UIButton.js +247 -0
  15. package/compiledScripts/UIButton.js.map +1 -0
  16. package/compiledScripts/UIColor.d.ts +41 -0
  17. package/compiledScripts/UIColor.js +286 -0
  18. package/compiledScripts/UIColor.js.map +1 -0
  19. package/compiledScripts/UICore.d.ts +27 -0
  20. package/compiledScripts/UICore.js +105 -0
  21. package/compiledScripts/UICore.js.map +1 -0
  22. package/compiledScripts/UICoreExtensions.d.ts +60 -0
  23. package/compiledScripts/UICoreExtensions.js +527 -0
  24. package/compiledScripts/UICoreExtensions.js.map +1 -0
  25. package/compiledScripts/UIDateTimeInput.d.ts +40 -0
  26. package/compiledScripts/UIDateTimeInput.js +38 -0
  27. package/compiledScripts/UIDateTimeInput.js.map +1 -0
  28. package/compiledScripts/UIDialogView.d.ts +23 -0
  29. package/compiledScripts/UIDialogView.js +118 -0
  30. package/compiledScripts/UIDialogView.js.map +1 -0
  31. package/compiledScripts/UIImageView.d.ts +36 -0
  32. package/compiledScripts/UIImageView.js +170 -0
  33. package/compiledScripts/UIImageView.js.map +1 -0
  34. package/compiledScripts/UIKeyValueStringFilter.d.ts +21 -0
  35. package/compiledScripts/UIKeyValueStringFilter.js +98 -0
  36. package/compiledScripts/UIKeyValueStringFilter.js.map +1 -0
  37. package/compiledScripts/UIKeyValueStringSorter.d.ts +38 -0
  38. package/compiledScripts/UIKeyValueStringSorter.js +117 -0
  39. package/compiledScripts/UIKeyValueStringSorter.js.map +1 -0
  40. package/compiledScripts/UILayoutGrid.d.ts +8 -0
  41. package/compiledScripts/UILayoutGrid.js +22 -0
  42. package/compiledScripts/UILayoutGrid.js.map +1 -0
  43. package/compiledScripts/UILink.d.ts +25 -0
  44. package/compiledScripts/UILink.js +81 -0
  45. package/compiledScripts/UILink.js.map +1 -0
  46. package/compiledScripts/UILinkButton.d.ts +18 -0
  47. package/compiledScripts/UILinkButton.js +60 -0
  48. package/compiledScripts/UILinkButton.js.map +1 -0
  49. package/compiledScripts/UINativeScrollView.d.ts +20 -0
  50. package/compiledScripts/UINativeScrollView.js +121 -0
  51. package/compiledScripts/UINativeScrollView.js.map +1 -0
  52. package/compiledScripts/UIObject.d.ts +69 -0
  53. package/compiledScripts/UIObject.js +442 -0
  54. package/compiledScripts/UIObject.js.map +1 -0
  55. package/compiledScripts/UIPoint.d.ts +18 -0
  56. package/compiledScripts/UIPoint.js +68 -0
  57. package/compiledScripts/UIPoint.js.map +1 -0
  58. package/compiledScripts/UIRectangle.d.ts +61 -0
  59. package/compiledScripts/UIRectangle.js +421 -0
  60. package/compiledScripts/UIRectangle.js.map +1 -0
  61. package/compiledScripts/UIRoute.d.ts +39 -0
  62. package/compiledScripts/UIRoute.js +202 -0
  63. package/compiledScripts/UIRoute.js.map +1 -0
  64. package/compiledScripts/UIScrollView.d.ts +19 -0
  65. package/compiledScripts/UIScrollView.js +121 -0
  66. package/compiledScripts/UIScrollView.js.map +1 -0
  67. package/compiledScripts/UISlideScrollerView.d.ts +40 -0
  68. package/compiledScripts/UISlideScrollerView.js +242 -0
  69. package/compiledScripts/UISlideScrollerView.js.map +1 -0
  70. package/compiledScripts/UIStringFilter.d.ts +26 -0
  71. package/compiledScripts/UIStringFilter.js +107 -0
  72. package/compiledScripts/UIStringFilter.js.map +1 -0
  73. package/compiledScripts/UITableView.d.ts +61 -0
  74. package/compiledScripts/UITableView.js +383 -0
  75. package/compiledScripts/UITableView.js.map +1 -0
  76. package/compiledScripts/UITextArea.d.ts +7 -0
  77. package/compiledScripts/UITextArea.js +27 -0
  78. package/compiledScripts/UITextArea.js.map +1 -0
  79. package/compiledScripts/UITextField.d.ts +44 -0
  80. package/compiledScripts/UITextField.js +83 -0
  81. package/compiledScripts/UITextField.js.map +1 -0
  82. package/compiledScripts/UITextView.d.ts +89 -0
  83. package/compiledScripts/UITextView.js +237 -0
  84. package/compiledScripts/UITextView.js.map +1 -0
  85. package/compiledScripts/UITimer.d.ts +13 -0
  86. package/compiledScripts/UITimer.js +45 -0
  87. package/compiledScripts/UITimer.js.map +1 -0
  88. package/compiledScripts/UIView.d.ts +330 -0
  89. package/compiledScripts/UIView.js +1533 -0
  90. package/compiledScripts/UIView.js.map +1 -0
  91. package/compiledScripts/UIViewController.d.ts +38 -0
  92. package/compiledScripts/UIViewController.js +153 -0
  93. package/compiledScripts/UIViewController.js.map +1 -0
  94. package/compiledScripts/index.d.ts +29 -0
  95. package/compiledScripts/index.js +46 -0
  96. package/compiledScripts/index.js.map +1 -0
  97. package/package.json +36 -0
  98. package/scripts/UIActionIndicator.ts +139 -0
  99. package/scripts/UIBaseButton.ts +563 -0
  100. package/scripts/UIButton.ts +552 -0
  101. package/scripts/UIColor.ts +427 -0
  102. package/scripts/UICore.ts +223 -0
  103. package/scripts/UICoreExtensions.ts +949 -0
  104. package/scripts/UIDateTimeInput.ts +109 -0
  105. package/scripts/UIDialogView.ts +297 -0
  106. package/scripts/UIImageView.ts +366 -0
  107. package/scripts/UIKeyValueStringFilter.ts +260 -0
  108. package/scripts/UIKeyValueStringSorter.ts +337 -0
  109. package/scripts/UILayoutGrid.ts +83 -0
  110. package/scripts/UILink.ts +292 -0
  111. package/scripts/UILinkButton.ts +238 -0
  112. package/scripts/UINativeScrollView.ts +254 -0
  113. package/scripts/UIObject.ts +827 -0
  114. package/scripts/UIPoint.ts +123 -0
  115. package/scripts/UIRectangle.ts +730 -0
  116. package/scripts/UIRoute.ts +391 -0
  117. package/scripts/UIScrollView.ts +290 -0
  118. package/scripts/UISlideScrollerView.ts +530 -0
  119. package/scripts/UIStringFilter.ts +293 -0
  120. package/scripts/UITableView.ts +790 -0
  121. package/scripts/UITextArea.ts +91 -0
  122. package/scripts/UITextField.ts +218 -0
  123. package/scripts/UITextView.ts +561 -0
  124. package/scripts/UITimer.ts +107 -0
  125. package/scripts/UIView.ts +2789 -0
  126. package/scripts/UIViewController.ts +304 -0
  127. package/scripts/index.ts +36 -0
  128. package/tsconfig.json +59 -0
@@ -0,0 +1,790 @@
1
+ import { UIButton } from "./UIButton"
2
+ import { UINativeScrollView } from "./UINativeScrollView"
3
+ import { IS, nil, NO, YES } from "./UIObject"
4
+ import { UIPoint } from "./UIPoint"
5
+ import { UIRectangle } from "./UIRectangle"
6
+ import { UIView, UIViewBroadcastEvent } from "./UIView"
7
+
8
+
9
+ export interface UITableViewReusableViewsContainerObject {
10
+
11
+ [key: string]: UIView[];
12
+
13
+ }
14
+
15
+
16
+ export interface UITableViewReusableViewPositionObject {
17
+
18
+ bottomY: number;
19
+ topY: number;
20
+
21
+ isValid: boolean;
22
+
23
+ }
24
+
25
+
26
+
27
+
28
+
29
+ export class UITableView extends UINativeScrollView {
30
+
31
+
32
+
33
+
34
+ allRowsHaveEqualHeight: boolean = NO
35
+ _visibleRows: UIView[] = []
36
+ _firstLayoutVisibleRows: UIView[] = []
37
+
38
+ _rowPositions: UITableViewReusableViewPositionObject[] = []
39
+
40
+ _highestValidRowPositionIndex: number = 0
41
+
42
+ _reusableViews: UITableViewReusableViewsContainerObject = {}
43
+
44
+ _removedReusableViews: UITableViewReusableViewsContainerObject = {}
45
+
46
+ _fullHeightView: UIView
47
+
48
+ _rowIDIndex: number = 0
49
+
50
+ reloadsOnLanguageChange = YES
51
+
52
+ sidePadding = 0
53
+
54
+ _persistedData: any[] = []
55
+ _needsDrawingOfVisibleRowsBeforeLayout = NO
56
+ _isDrawVisibleRowsScheduled = NO
57
+ _shouldAnimateNextLayout: boolean
58
+
59
+ animationDuration = 0.25
60
+
61
+
62
+ constructor(elementID) {
63
+
64
+ super(elementID)
65
+
66
+ this._class = UITableView
67
+ this.superclass = UINativeScrollView
68
+
69
+ this.scrollsX = NO
70
+
71
+ }
72
+
73
+
74
+
75
+ initView(elementID, viewHTMLElement) {
76
+
77
+ super.initView(elementID, viewHTMLElement)
78
+
79
+ this._fullHeightView = new UIView()
80
+ this._fullHeightView.hidden = YES
81
+ this._fullHeightView.userInteractionEnabled = NO
82
+ this.addSubview(this._fullHeightView)
83
+
84
+ }
85
+
86
+
87
+
88
+ loadData() {
89
+
90
+ this._persistedData = []
91
+
92
+ this._calculatePositionsUntilIndex(this.numberOfRows() - 1)
93
+ this._needsDrawingOfVisibleRowsBeforeLayout = YES
94
+
95
+ this.setNeedsLayout()
96
+
97
+ // this.forEachViewInSubtree(function(view) {
98
+
99
+ // view.setNeedsLayout();
100
+
101
+ // })
102
+
103
+ }
104
+
105
+ reloadData() {
106
+
107
+ this._removeVisibleRows()
108
+ this._removeAllReusableRows()
109
+
110
+ this._rowPositions = []
111
+ this._highestValidRowPositionIndex = 0
112
+
113
+ this.loadData()
114
+
115
+ }
116
+
117
+
118
+
119
+ highlightChanges(previousData: any[], newData: any[]) {
120
+
121
+ previousData = previousData.map(function (dataPoint, index, array) {
122
+
123
+ return JSON.stringify(dataPoint)
124
+
125
+ })
126
+
127
+ newData = newData.map(function (dataPoint, index, array) {
128
+
129
+ return JSON.stringify(dataPoint)
130
+
131
+ })
132
+
133
+
134
+ const newIndexes: number[] = []
135
+
136
+ newData.forEach(function (value, index, array) {
137
+
138
+ if (!previousData.contains(value)) {
139
+
140
+ newIndexes.push(index)
141
+
142
+ }
143
+
144
+ })
145
+
146
+ newIndexes.forEach(function (this: UITableView, index) {
147
+
148
+ if (this.isRowWithIndexVisible(index)) {
149
+
150
+ this.highlightRowAsNew(this.viewForRowWithIndex(index))
151
+
152
+ }
153
+
154
+ }.bind(this))
155
+
156
+ }
157
+
158
+
159
+
160
+ highlightRowAsNew(row: UIView) {
161
+
162
+
163
+
164
+ }
165
+
166
+
167
+
168
+
169
+
170
+ invalidateSizeOfRowWithIndex(index: number, animateChange = NO) {
171
+
172
+ if (this._rowPositions[index]) {
173
+ this._rowPositions[index].isValid = NO
174
+ }
175
+
176
+ this._highestValidRowPositionIndex = Math.min(this._highestValidRowPositionIndex, index - 1)
177
+
178
+ // if (index == 0) {
179
+
180
+ // this._highestValidRowPositionIndex = 0;
181
+
182
+ // this._rowPositions = [];
183
+
184
+ // }
185
+
186
+ this._needsDrawingOfVisibleRowsBeforeLayout = YES
187
+
188
+ this._shouldAnimateNextLayout = animateChange
189
+
190
+ }
191
+
192
+
193
+
194
+ _calculateAllPositions() {
195
+ this._calculatePositionsUntilIndex(this.numberOfRows() - 1)
196
+ }
197
+
198
+ _calculatePositionsUntilIndex(maxIndex: number) {
199
+
200
+ var validPositionObject = this._rowPositions[this._highestValidRowPositionIndex]
201
+ if (!IS(validPositionObject)) {
202
+ validPositionObject = {
203
+ bottomY: 0,
204
+ topY: 0,
205
+ isValid: YES
206
+ }
207
+ }
208
+
209
+ var previousBottomY = validPositionObject.bottomY
210
+
211
+ if (!this._rowPositions.length) {
212
+
213
+ this._highestValidRowPositionIndex = -1
214
+
215
+ }
216
+
217
+ for (var i = this._highestValidRowPositionIndex + 1; i <= maxIndex; i++) {
218
+
219
+ var height: number
220
+
221
+ const rowPositionObject = this._rowPositions[i]
222
+
223
+ if (IS((rowPositionObject || nil).isValid)) {
224
+
225
+ height = rowPositionObject.bottomY - rowPositionObject.topY
226
+
227
+ }
228
+ else {
229
+
230
+ height = this.heightForRowWithIndex(i)
231
+
232
+ }
233
+
234
+
235
+
236
+
237
+ const positionObject: UITableViewReusableViewPositionObject = {
238
+ bottomY: previousBottomY + height,
239
+ topY: previousBottomY,
240
+ isValid: YES
241
+ }
242
+
243
+ if (i < this._rowPositions.length) {
244
+ this._rowPositions[i] = positionObject
245
+ }
246
+ else {
247
+ this._rowPositions.push(positionObject)
248
+ }
249
+ this._highestValidRowPositionIndex = i
250
+ previousBottomY = previousBottomY + height
251
+
252
+ }
253
+
254
+ }
255
+
256
+
257
+
258
+ indexesForVisibleRows(paddingRatio = 0.5): number[] {
259
+
260
+ const firstVisibleY = this.contentOffset.y - this.bounds.height * paddingRatio
261
+ const lastVisibleY = firstVisibleY + this.bounds.height * (1 + paddingRatio)
262
+
263
+ const numberOfRows = this.numberOfRows()
264
+
265
+ if (this.allRowsHaveEqualHeight) {
266
+
267
+ const rowHeight = this.heightForRowWithIndex(0)
268
+
269
+ var firstIndex = firstVisibleY / rowHeight
270
+ var lastIndex = lastVisibleY / rowHeight
271
+
272
+ firstIndex = Math.trunc(firstIndex)
273
+ lastIndex = Math.trunc(lastIndex) + 1
274
+
275
+ firstIndex = Math.max(firstIndex, 0)
276
+ lastIndex = Math.min(lastIndex, numberOfRows - 1)
277
+
278
+ var result = []
279
+ for (var i = firstIndex; i < lastIndex + 1; i++) {
280
+ result.push(i)
281
+ }
282
+ return result
283
+ }
284
+
285
+ var accumulatedHeight = 0
286
+ var result = []
287
+
288
+ this._calculateAllPositions()
289
+
290
+ const rowPositions = this._rowPositions
291
+
292
+ for (var i = 0; i < numberOfRows; i++) {
293
+
294
+ const height = rowPositions[i].bottomY - rowPositions[i].topY // this.heightForRowWithIndex(i)
295
+
296
+ accumulatedHeight = accumulatedHeight + height
297
+ if (accumulatedHeight >= firstVisibleY) {
298
+ result.push(i)
299
+ }
300
+ if (accumulatedHeight >= lastVisibleY) {
301
+ break
302
+ }
303
+
304
+ }
305
+
306
+ return result
307
+
308
+ }
309
+
310
+
311
+ _removeVisibleRows() {
312
+
313
+ const visibleRows = []
314
+ this._visibleRows.forEach(function (this: UITableView, row: UIView, index: number, array: UIView[]) {
315
+
316
+ this._persistedData[row._UITableViewRowIndex] = this.persistenceDataItemForRowWithIndex(
317
+ row._UITableViewRowIndex,
318
+ row
319
+ )
320
+ row.removeFromSuperview()
321
+ this._removedReusableViews[row._UITableViewReusabilityIdentifier].push(row)
322
+
323
+
324
+ }, this)
325
+ this._visibleRows = visibleRows
326
+
327
+ }
328
+
329
+
330
+
331
+ _removeAllReusableRows() {
332
+ // @ts-ignore
333
+ this._reusableViews.forEach(function (this: UITableView, rows: UIView[]) {
334
+ rows.forEach(function (this: UITableView, row: UIView, index: number, array: UIView[]) {
335
+
336
+ this._persistedData[row._UITableViewRowIndex] = this.persistenceDataItemForRowWithIndex(
337
+ row._UITableViewRowIndex,
338
+ row
339
+ )
340
+ row.removeFromSuperview()
341
+
342
+ this._markReusableViewAsUnused(row)
343
+
344
+ }.bind(this))
345
+ }.bind(this))
346
+ }
347
+
348
+
349
+
350
+ _markReusableViewAsUnused(row: UIView) {
351
+ if (!this._removedReusableViews[row._UITableViewReusabilityIdentifier].contains(row)) {
352
+ this._removedReusableViews[row._UITableViewReusabilityIdentifier].push(row)
353
+ }
354
+ }
355
+
356
+ _drawVisibleRows() {
357
+
358
+ if (!this.isMemberOfViewTree) {
359
+ return
360
+ }
361
+
362
+ const visibleIndexes = this.indexesForVisibleRows()
363
+
364
+ const minIndex = visibleIndexes[0]
365
+ const maxIndex = visibleIndexes[visibleIndexes.length - 1]
366
+
367
+ const removedViews = []
368
+
369
+ const visibleRows = []
370
+ this._visibleRows.forEach(function (this: UITableView, row: UIView, index: number, array: UIView[]) {
371
+ if (row._UITableViewRowIndex < minIndex || row._UITableViewRowIndex > maxIndex) {
372
+
373
+ //row.removeFromSuperview();
374
+
375
+ this._persistedData[row._UITableViewRowIndex] = this.persistenceDataItemForRowWithIndex(
376
+ row._UITableViewRowIndex,
377
+ row
378
+ )
379
+
380
+ this._removedReusableViews[row._UITableViewReusabilityIdentifier].push(row)
381
+
382
+ removedViews.push(row)
383
+
384
+ }
385
+ else {
386
+ visibleRows.push(row)
387
+ }
388
+ }, this)
389
+ this._visibleRows = visibleRows
390
+
391
+ visibleIndexes.forEach(function (this: UITableView, rowIndex: number, index: number, array: number) {
392
+
393
+
394
+ if (this.isRowWithIndexVisible(rowIndex)) {
395
+ return
396
+ }
397
+ const view: UIView = this.viewForRowWithIndex(rowIndex)
398
+ //view._UITableViewRowIndex = rowIndex;
399
+ this._firstLayoutVisibleRows.push(view)
400
+ this._visibleRows.push(view)
401
+ this.addSubview(view)
402
+
403
+ } as any, this)
404
+
405
+ for (var i = 0; i < removedViews.length; i++) {
406
+
407
+ var view: UIView = removedViews[i]
408
+ if (this._visibleRows.indexOf(view) == -1) {
409
+
410
+ //this._persistedData[view._UITableViewRowIndex] = this.persistenceDataItemForRowWithIndex(view._UITableViewRowIndex, view);
411
+ view.removeFromSuperview()
412
+
413
+ //this._removedReusableViews[view._UITableViewReusabilityIdentifier].push(view);
414
+
415
+ }
416
+
417
+ }
418
+
419
+ //this.setNeedsLayout();
420
+
421
+ }
422
+
423
+
424
+ visibleRowWithIndex(rowIndex: number): UIView {
425
+ for (var i = 0; i < this._visibleRows.length; i++) {
426
+ const row = this._visibleRows[i]
427
+ if (row._UITableViewRowIndex == rowIndex) {
428
+ return row
429
+ }
430
+ }
431
+ return nil
432
+ }
433
+
434
+
435
+ isRowWithIndexVisible(rowIndex: number) {
436
+ return IS(this.visibleRowWithIndex(rowIndex))
437
+ }
438
+
439
+
440
+
441
+ reusableViewForIdentifier(identifier: string, rowIndex: number) {
442
+
443
+ if (!this._removedReusableViews[identifier]) {
444
+ this._removedReusableViews[identifier] = []
445
+ }
446
+
447
+ if (this._removedReusableViews[identifier] && this._removedReusableViews[identifier].length) {
448
+
449
+ const view = this._removedReusableViews[identifier].pop()
450
+
451
+ view._UITableViewRowIndex = rowIndex
452
+
453
+ Object.assign(view, this._persistedData[rowIndex] || this.defaultRowPersistenceDataItem())
454
+
455
+ return view
456
+
457
+ }
458
+
459
+ if (!this._reusableViews[identifier]) {
460
+ this._reusableViews[identifier] = []
461
+ }
462
+
463
+ const newView = this.newReusableViewForIdentifier(identifier, this._rowIDIndex)
464
+ this._rowIDIndex = this._rowIDIndex + 1
465
+
466
+ if (this._rowIDIndex > 40) {
467
+
468
+ const asd = 1
469
+
470
+ }
471
+
472
+ newView._UITableViewReusabilityIdentifier = identifier
473
+
474
+ newView._UITableViewRowIndex = rowIndex
475
+
476
+ Object.assign(newView, this._persistedData[rowIndex] || this.defaultRowPersistenceDataItem())
477
+ this._reusableViews[identifier].push(newView)
478
+
479
+ return newView
480
+
481
+ }
482
+
483
+
484
+ // Functions that should be overridden to draw the correct content START
485
+ newReusableViewForIdentifier(identifier: string, rowIDIndex: number): UIView {
486
+
487
+ const view = new UIButton(this.elementID + "Row" + rowIDIndex)
488
+
489
+ view.stopsPointerEventPropagation = NO
490
+ view.pausesPointerEvents = NO
491
+
492
+ return view
493
+
494
+ }
495
+
496
+ heightForRowWithIndex(index: number): number {
497
+ return 50
498
+ }
499
+
500
+ numberOfRows() {
501
+ return 10000
502
+ }
503
+
504
+ defaultRowPersistenceDataItem() {
505
+
506
+
507
+
508
+ }
509
+
510
+ persistenceDataItemForRowWithIndex(rowIndex: number, row: UIView) {
511
+
512
+
513
+
514
+ }
515
+
516
+ viewForRowWithIndex(rowIndex: number): UIView {
517
+
518
+ const row = this.reusableViewForIdentifier("Row", rowIndex);
519
+ (row as UIButton).titleLabel.text = "Row " + rowIndex
520
+
521
+ return row
522
+
523
+ }
524
+
525
+ // Functions that should be overridden to draw the correct content END
526
+
527
+
528
+ // Functions that trigger redrawing of the content
529
+ didScrollToPosition(offsetPosition: UIPoint) {
530
+
531
+ super.didScrollToPosition(offsetPosition)
532
+
533
+ this.forEachViewInSubtree(function (view: UIView) {
534
+
535
+ view._isPointerValid = NO
536
+
537
+ })
538
+
539
+ if (!this._isDrawVisibleRowsScheduled) {
540
+
541
+ this._isDrawVisibleRowsScheduled = YES
542
+
543
+ UIView.runFunctionBeforeNextFrame(function (this: UITableView) {
544
+
545
+ this._calculateAllPositions()
546
+
547
+ this._drawVisibleRows()
548
+
549
+ this.setNeedsLayout()
550
+
551
+ this._isDrawVisibleRowsScheduled = NO
552
+
553
+ }.bind(this))
554
+
555
+ }
556
+
557
+ }
558
+
559
+ wasAddedToViewTree() {
560
+ this.loadData()
561
+ }
562
+
563
+ setFrame(rectangle: UIRectangle, zIndex?: number, performUncheckedLayout?: boolean) {
564
+
565
+ const frame = this.frame
566
+ super.setFrame(rectangle, zIndex, performUncheckedLayout)
567
+ if (frame.isEqualTo(rectangle) && !performUncheckedLayout) {
568
+ return
569
+ }
570
+
571
+ this._needsDrawingOfVisibleRowsBeforeLayout = YES
572
+
573
+ }
574
+
575
+
576
+
577
+
578
+
579
+ didReceiveBroadcastEvent(event: UIViewBroadcastEvent) {
580
+
581
+ super.didReceiveBroadcastEvent(event)
582
+
583
+ if (event.name == UIView.broadcastEventName.LanguageChanged && this.reloadsOnLanguageChange) {
584
+
585
+ this.reloadData()
586
+
587
+ }
588
+
589
+
590
+ }
591
+
592
+
593
+
594
+
595
+
596
+ private _layoutAllRows(positions = this._rowPositions) {
597
+
598
+ const bounds = this.bounds
599
+
600
+ this._visibleRows.forEach(function (this: UITableView, row: UIView, index: number, array: UIView[]) {
601
+
602
+ const frame = bounds.copy()
603
+
604
+ const positionObject = positions[row._UITableViewRowIndex]
605
+ frame.min.y = positionObject.topY
606
+ frame.max.y = positionObject.bottomY
607
+ row.frame = frame
608
+
609
+ row.style.width = "" + (bounds.width - this.sidePadding * 2).integerValue + "px"
610
+ row.style.left = "" + this.sidePadding.integerValue + "px"
611
+
612
+
613
+ }, this)
614
+
615
+ this._fullHeightView.frame = bounds.rectangleWithHeight((positions.lastElement ||
616
+ nil).bottomY).rectangleWithWidth(bounds.width * 0.5)
617
+
618
+ this._firstLayoutVisibleRows = []
619
+
620
+
621
+ }
622
+
623
+ private _animateLayoutAllRows() {
624
+
625
+ UIView.animateViewOrViewsWithDurationDelayAndFunction(
626
+ this._visibleRows,
627
+ this.animationDuration,
628
+ 0,
629
+ undefined,
630
+ function (this: UITableView) {
631
+
632
+ this._layoutAllRows()
633
+
634
+ }.bind(this),
635
+ function (this: UITableView) {
636
+
637
+ // this._calculateAllPositions()
638
+ // this._layoutAllRows()
639
+
640
+ }.bind(this)
641
+ )
642
+
643
+ }
644
+
645
+
646
+
647
+
648
+
649
+ layoutSubviews() {
650
+
651
+ const previousPositions: UITableViewReusableViewPositionObject[] = JSON.parse(JSON.stringify(this._rowPositions))
652
+
653
+ const previousVisibleRowsLength = this._visibleRows.length
654
+
655
+ if (this._needsDrawingOfVisibleRowsBeforeLayout) {
656
+
657
+ //this._calculateAllPositions()
658
+
659
+ this._drawVisibleRows()
660
+
661
+ this._needsDrawingOfVisibleRowsBeforeLayout = NO
662
+
663
+ }
664
+
665
+
666
+
667
+ super.layoutSubviews()
668
+
669
+
670
+ if (!this.numberOfRows() || !this.isMemberOfViewTree) {
671
+
672
+ return
673
+
674
+ }
675
+
676
+
677
+
678
+
679
+
680
+ if (this._shouldAnimateNextLayout) {
681
+
682
+
683
+
684
+ // Need to do layout with the previous positions
685
+
686
+ this._layoutAllRows(previousPositions)
687
+
688
+
689
+ if (previousVisibleRowsLength < this._visibleRows.length) {
690
+
691
+
692
+ UIView.runFunctionBeforeNextFrame(function (this: UITableView) {
693
+
694
+ this._animateLayoutAllRows()
695
+
696
+ }.bind(this))
697
+
698
+ }
699
+ else {
700
+
701
+ this._animateLayoutAllRows()
702
+
703
+ }
704
+
705
+
706
+ this._shouldAnimateNextLayout = NO
707
+
708
+ }
709
+ else {
710
+
711
+ // if (this._needsDrawingOfVisibleRowsBeforeLayout) {
712
+
713
+ // this._drawVisibleRows();
714
+
715
+ // this._needsDrawingOfVisibleRowsBeforeLayout = NO;
716
+
717
+ // }
718
+
719
+ this._calculateAllPositions()
720
+
721
+ this._layoutAllRows()
722
+
723
+
724
+ }
725
+
726
+
727
+
728
+
729
+
730
+ }
731
+
732
+
733
+
734
+
735
+
736
+ intrinsicContentHeight(constrainingWidth = 0) {
737
+
738
+
739
+
740
+ var result = 0
741
+
742
+ this._calculateAllPositions()
743
+
744
+ if (this._rowPositions.length) {
745
+
746
+ result = this._rowPositions[this._rowPositions.length - 1].bottomY
747
+
748
+ }
749
+
750
+ return result
751
+
752
+ }
753
+
754
+
755
+
756
+
757
+
758
+ }
759
+
760
+
761
+
762
+
763
+
764
+
765
+
766
+
767
+
768
+
769
+
770
+
771
+
772
+
773
+
774
+
775
+
776
+
777
+
778
+
779
+
780
+
781
+
782
+
783
+
784
+
785
+
786
+
787
+
788
+
789
+
790
+