@nativescript-community/ui-pager 13.0.33 → 13.0.36

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 (34) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/angular/esm2020/index.mjs +55 -0
  3. package/angular/{esm2015/nativescript-community-ui-pager-angular.js → esm2020/nativescript-community-ui-pager-angular.mjs} +0 -0
  4. package/angular/esm2020/pager-items-comp.mjs +304 -0
  5. package/angular/fesm2015/nativescript-community-ui-pager-angular.mjs +379 -0
  6. package/angular/fesm2015/nativescript-community-ui-pager-angular.mjs.map +1 -0
  7. package/angular/{fesm2015/nativescript-community-ui-pager-angular.js → fesm2020/nativescript-community-ui-pager-angular.mjs} +15 -24
  8. package/angular/fesm2020/nativescript-community-ui-pager-angular.mjs.map +1 -0
  9. package/angular/package.json +20 -6
  10. package/index.android.js +336 -350
  11. package/index.android.js.map +1 -1
  12. package/index.common.d.ts +1 -4
  13. package/index.common.js +4 -7
  14. package/index.common.js.map +1 -1
  15. package/index.d.ts +1 -1
  16. package/index.ios.d.ts +15 -15
  17. package/index.ios.js +259 -375
  18. package/index.ios.js.map +1 -1
  19. package/package.json +9 -4
  20. package/react/index.d.ts +5 -5
  21. package/react/index.js +4 -2
  22. package/react/index.js.map +1 -1
  23. package/references.d.ts +1 -0
  24. package/svelte/index.js +3 -2
  25. package/svelte/index.js.map +1 -1
  26. package/typings/objc!CHIPageControl.d.ts +197 -0
  27. package/vue/pager.js +15 -15
  28. package/vue/pager.js.map +1 -1
  29. package/.pnpm-debug.log +0 -1
  30. package/angular/bundles/nativescript-community-ui-pager-angular.umd.js +0 -759
  31. package/angular/bundles/nativescript-community-ui-pager-angular.umd.js.map +0 -1
  32. package/angular/esm2015/index.js +0 -55
  33. package/angular/esm2015/pager-items-comp.js +0 -312
  34. package/angular/fesm2015/nativescript-community-ui-pager-angular.js.map +0 -1
package/index.android.js CHANGED
@@ -1,7 +1,7 @@
1
- import { ChangeType, Color, Device, ObservableArray, Property, Screen, StackLayout, View, profile } from '@nativescript/core';
1
+ import { ChangeType, Color, Device, ObservableArray, Property, Screen, StackLayout, View, ViewBase, profile } from '@nativescript/core';
2
2
  import { isString } from '@nativescript/core/utils/types';
3
3
  import { layout } from '@nativescript/core/utils/utils';
4
- import { ITEMLOADING, Indicator, LOADMOREITEMS, PagerBase, Transformer, autoPlayProperty, autoplayDelayProperty, disableSwipeProperty, indicatorColorProperty, indicatorProperty, indicatorSelectedColorProperty, itemTemplatesProperty, itemsProperty, orientationProperty, peakingProperty, selectedIndexProperty, showIndicatorProperty, spacingProperty } from './index.common';
4
+ import { Indicator, PagerBase, PagerItem, Transformer, autoPlayProperty, autoplayDelayProperty, disableSwipeProperty, indicatorColorProperty, indicatorProperty, indicatorSelectedColorProperty, itemTemplatesProperty, itemsProperty, orientationProperty, peakingProperty, selectedIndexProperty, showIndicatorProperty, spacingProperty } from './index.common';
5
5
  export * from './index.common';
6
6
  export { Transformer } from './index.common';
7
7
  function notifyForItemAtIndex(owner, nativeView, view, eventName, index) {
@@ -11,7 +11,7 @@ function notifyForItemAtIndex(owner, nativeView, view, eventName, index) {
11
11
  index,
12
12
  view,
13
13
  ios: undefined,
14
- android: nativeView,
14
+ android: nativeView
15
15
  };
16
16
  owner.notify(args);
17
17
  return args;
@@ -31,6 +31,7 @@ export class Pager extends PagerBase {
31
31
  this._observableArrayHandler = (args) => {
32
32
  if (this.indicatorView && this.showIndicator) {
33
33
  this.indicatorView.setCount(this._childrenCount);
34
+ this.indicatorView.setSelected(args.index);
34
35
  }
35
36
  if (this.pagerAdapter) {
36
37
  switch (args.action) {
@@ -96,7 +97,7 @@ export class Pager extends PagerBase {
96
97
  this.on(View.layoutChangedEvent, this.onLayoutChange, this);
97
98
  const LayoutParams = android.widget.RelativeLayout.LayoutParams;
98
99
  nativeView.addView(this.pager, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
99
- this._indicatorView = new (com).rd.PageIndicatorView2(this._context);
100
+ this._indicatorView = new com.rd.PageIndicatorView2(this._context);
100
101
  const params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
101
102
  params.addRule(android.widget.RelativeLayout.ALIGN_PARENT_BOTTOM);
102
103
  params.addRule(android.widget.RelativeLayout.CENTER_HORIZONTAL);
@@ -184,7 +185,7 @@ export class Pager extends PagerBase {
184
185
  this._setIndicator(value);
185
186
  }
186
187
  _setIndicator(value) {
187
- const AnimationType = (com).rd.animation.type.AnimationType;
188
+ const AnimationType = com.rd.animation.type.AnimationType;
188
189
  switch (value) {
189
190
  case Indicator.None:
190
191
  this.indicatorView.setAnimationType(AnimationType.NONE);
@@ -258,13 +259,13 @@ export class Pager extends PagerBase {
258
259
  }
259
260
  [indicatorColorProperty.setNative](value) {
260
261
  if (this.indicatorView) {
261
- const color = (!value || value instanceof Color) ? value : new Color(value);
262
+ const color = !value || value instanceof Color ? value : new Color(value);
262
263
  this.indicatorView.setUnselectedColor(color ? color.android : null);
263
264
  }
264
265
  }
265
266
  [indicatorSelectedColorProperty.setNative](value) {
266
267
  if (this.indicatorView) {
267
- const color = (!value || value instanceof Color) ? value : new Color(value);
268
+ const color = !value || value instanceof Color ? value : new Color(value);
268
269
  this.indicatorView.setSelectedColor(color ? color.android : null);
269
270
  }
270
271
  }
@@ -300,9 +301,7 @@ export class Pager extends PagerBase {
300
301
  }
301
302
  }
302
303
  _updateScrollPosition() {
303
- const index = this.circularMode
304
- ? this.selectedIndex + 1
305
- : this.selectedIndex;
304
+ const index = this.circularMode ? this.selectedIndex + 1 : this.selectedIndex;
306
305
  if (this.pager.getCurrentItem() !== index) {
307
306
  this.indicatorView.setInteractiveAnimation(false);
308
307
  this.pager.setCurrentItem(index, false);
@@ -333,7 +332,7 @@ export class Pager extends PagerBase {
333
332
  this.initStaticPagerAdapter();
334
333
  }
335
334
  [selectedIndexProperty.setNative](value) {
336
- if (this.isLoaded && this.isLayoutValid && this.pager) {
335
+ if (this.isLoaded && this.pager) {
337
336
  const index = this.circularMode ? value + 1 : value;
338
337
  if (this.pager.getCurrentItem() !== index) {
339
338
  this.pager.setCurrentItem(index, !this.disableAnimation);
@@ -494,9 +493,7 @@ export class Pager extends PagerBase {
494
493
  }
495
494
  }
496
495
  get itemCount() {
497
- return this._childrenCount
498
- ? this._childrenCount + (this.circularMode ? 2 : 0)
499
- : 0;
496
+ return this._childrenCount ? this._childrenCount + (this.circularMode ? 2 : 0) : 0;
500
497
  }
501
498
  get lastIndex() {
502
499
  if (this.items && this.items.length === 0) {
@@ -514,7 +511,7 @@ export const pagesCountProperty = new Property({
514
511
  valueConverter: (v) => parseInt(v, 10),
515
512
  valueChanged: (pager, oldValue, newValue) => {
516
513
  pager.updatePagesCount(pager.pagesCount);
517
- },
514
+ }
518
515
  });
519
516
  pagesCountProperty.register(Pager);
520
517
  let PageChangeCallback;
@@ -522,123 +519,116 @@ function initPagerChangeCallback() {
522
519
  if (PageChangeCallback) {
523
520
  return PageChangeCallback;
524
521
  }
525
- var PageChangeCallbackImpl = /** @class */ (function (_super) {
526
- __extends(PageChangeCallbackImpl, _super);
527
- function PageChangeCallbackImpl(owner) {
528
- var _this = _super.call(this) || this;
529
- _this.owner = owner;
530
- return global.__native(_this);
531
- }
532
- PageChangeCallbackImpl.prototype.onPageSelected = function (position) {
533
- var owner = this.owner && this.owner.get();
534
- if (owner) {
535
- owner.notify({
536
- eventName: Pager.swipeEvent,
537
- object: owner,
538
- });
539
- }
540
- };
541
- PageChangeCallbackImpl.prototype.onPageScrolled = function (position, positionOffset, positionOffsetPixels) {
542
- var owner = this.owner && this.owner.get();
543
- if (owner && owner.isLayoutValid) {
544
- if (owner.circularMode) {
545
- position = owner.pagerAdapter.getPosition(position);
546
- }
547
- var offset = position * positionOffsetPixels;
548
- if (owner.orientation === 'vertical') {
549
- owner._horizontalOffset = 0;
550
- owner._verticalOffset = offset;
551
- }
552
- else if (owner.orientation === 'horizontal') {
553
- owner._horizontalOffset = offset;
554
- owner._verticalOffset = 0;
555
- }
556
- owner.notify({
557
- eventName: Pager.scrollEvent,
558
- object: owner,
559
- selectedIndex: position,
560
- currentPosition: position + positionOffset,
561
- scrollX: owner.horizontalOffset,
562
- scrollY: owner.verticalOffset,
563
- });
564
- if (owner.items &&
565
- position ===
566
- owner.pagerAdapter.lastIndex() - owner.loadMoreCount) {
567
- owner.notify({ eventName: LOADMOREITEMS, object: owner });
568
- }
569
- if (owner.showIndicator && owner.indicatorView) {
570
- var progress = Pager.getProgress(owner.indicatorView, position, positionOffset, false);
571
- var selectingPosition = progress[0];
572
- var selectingProgress = progress[1];
573
- owner.indicatorView.setInteractiveAnimation(true);
574
- owner.indicatorView.setProgress(selectingPosition, selectingProgress);
575
- }
522
+ let PageChangeCallbackImpl = class PageChangeCallbackImpl extends androidx.viewpager2.widget.ViewPager2.OnPageChangeCallback {
523
+ constructor(owner) {
524
+ super();
525
+ this.owner = owner;
526
+ return global.__native(this);
576
527
  }
577
- };
578
- PageChangeCallbackImpl.prototype.onPageScrollStateChanged = function (state) {
579
- var owner = this.owner && this.owner.get();
580
- if (owner) {
581
- if (owner.lastEvent === 0 && state === 1) {
528
+ onPageSelected(position) {
529
+ const owner = this.owner && this.owner.get();
530
+ if (owner) {
582
531
  owner.notify({
583
- eventName: Pager.swipeStartEvent,
584
- object: owner,
532
+ eventName: Pager.swipeEvent,
533
+ object: owner
585
534
  });
586
- owner.lastEvent = 1;
587
535
  }
588
- else if (owner.lastEvent === 1 && state === 1) {
589
- owner.notify({
590
- eventName: Pager.swipeOverEvent,
591
- object: owner,
592
- });
593
- owner.lastEvent = 1;
594
- }
595
- else if (owner.lastEvent === 1 && state === 2) {
536
+ }
537
+ onPageScrolled(position, positionOffset, positionOffsetPixels) {
538
+ const owner = this.owner && this.owner.get();
539
+ if (owner && owner.isLayoutValid) {
540
+ if (owner.circularMode) {
541
+ position = owner.pagerAdapter.getPosition(position);
542
+ }
543
+ const offset = position * positionOffsetPixels;
544
+ if (owner.orientation === 'vertical') {
545
+ owner._horizontalOffset = 0;
546
+ owner._verticalOffset = offset;
547
+ }
548
+ else if (owner.orientation === 'horizontal') {
549
+ owner._horizontalOffset = offset;
550
+ owner._verticalOffset = 0;
551
+ }
596
552
  owner.notify({
597
- eventName: Pager.swipeEndEvent,
553
+ eventName: Pager.scrollEvent,
598
554
  object: owner,
555
+ selectedIndex: position,
556
+ currentPosition: position + positionOffset,
557
+ scrollX: owner.horizontalOffset,
558
+ scrollY: owner.verticalOffset
599
559
  });
600
- owner.lastEvent = 2;
560
+ if (owner.items && position === owner.pagerAdapter.lastIndex() - owner.loadMoreCount) {
561
+ owner.notify({ eventName: Pager.loadMoreItemsEvent, object: owner });
562
+ }
563
+ if (owner.showIndicator && owner.indicatorView) {
564
+ const progress = Pager.getProgress(owner.indicatorView, position, positionOffset, false);
565
+ const selectingPosition = progress[0];
566
+ const selectingProgress = progress[1];
567
+ owner.indicatorView.setInteractiveAnimation(true);
568
+ owner.indicatorView.setProgress(selectingPosition, selectingProgress);
569
+ }
601
570
  }
602
- else {
603
- owner.lastEvent = 0;
604
- }
605
- if (owner.isLayoutValid &&
606
- state ===
607
- androidx.viewpager2.widget.ViewPager2.SCROLL_STATE_IDLE) {
608
- // ts-ignore
609
- var count = owner.pagerAdapter.getItemCount();
610
- var index = owner.pager.getCurrentItem();
611
- if (owner.circularMode) {
612
- if (index === 0) {
613
- // last item
614
- owner.indicatorView.setInteractiveAnimation(false);
615
- owner.pager.setCurrentItem(count - 2, false);
616
- selectedIndexProperty.nativeValueChange(owner, count - 3);
617
- owner.indicatorView.setSelected(count - 3);
618
- owner.indicatorView.setInteractiveAnimation(true);
619
- }
620
- else if (index === count - 1) {
621
- // first item
622
- owner.indicatorView.setInteractiveAnimation(false);
623
- owner.indicatorView.setSelected(0);
624
- owner.pager.setCurrentItem(1, false);
625
- selectedIndexProperty.nativeValueChange(owner, 0);
626
- owner.indicatorView.setInteractiveAnimation(true);
571
+ }
572
+ onPageScrollStateChanged(state) {
573
+ const owner = this.owner && this.owner.get();
574
+ if (owner) {
575
+ if (owner.lastEvent === 0 && state === 1) {
576
+ owner.notify({
577
+ eventName: Pager.swipeStartEvent,
578
+ object: owner
579
+ });
580
+ owner.lastEvent = 1;
581
+ }
582
+ else if (owner.lastEvent === 1 && state === 1) {
583
+ owner.notify({
584
+ eventName: Pager.swipeOverEvent,
585
+ object: owner
586
+ });
587
+ owner.lastEvent = 1;
588
+ }
589
+ else if (owner.lastEvent === 1 && state === 2) {
590
+ owner.notify({
591
+ eventName: Pager.swipeEndEvent,
592
+ object: owner
593
+ });
594
+ owner.lastEvent = 2;
595
+ }
596
+ else {
597
+ owner.lastEvent = 0;
598
+ }
599
+ if (owner.isLayoutValid && state === androidx.viewpager2.widget.ViewPager2.SCROLL_STATE_IDLE) {
600
+ const count = owner.pagerAdapter.getItemCount();
601
+ const index = owner.pager.getCurrentItem();
602
+ if (owner.circularMode) {
603
+ if (index === 0) {
604
+ owner.indicatorView.setInteractiveAnimation(false);
605
+ owner.pager.setCurrentItem(count - 2, false);
606
+ selectedIndexProperty.nativeValueChange(owner, count - 3);
607
+ owner.indicatorView.setSelected(count - 3);
608
+ owner.indicatorView.setInteractiveAnimation(true);
609
+ }
610
+ else if (index === count - 1) {
611
+ owner.indicatorView.setInteractiveAnimation(false);
612
+ owner.indicatorView.setSelected(0);
613
+ owner.pager.setCurrentItem(1, false);
614
+ selectedIndexProperty.nativeValueChange(owner, 0);
615
+ owner.indicatorView.setInteractiveAnimation(true);
616
+ }
617
+ else {
618
+ selectedIndexProperty.nativeValueChange(owner, index - 1);
619
+ }
627
620
  }
628
621
  else {
629
- selectedIndexProperty.nativeValueChange(owner, index - 1);
622
+ selectedIndexProperty.nativeValueChange(owner, index);
623
+ owner.indicatorView.setSelected(index);
630
624
  }
631
625
  }
632
- else {
633
- selectedIndexProperty.nativeValueChange(owner, index);
634
- owner.indicatorView.setSelected(index);
635
- }
636
626
  }
637
627
  }
638
628
  };
639
- return PageChangeCallbackImpl;
640
- }(androidx.viewpager2.widget.ViewPager2
641
- .OnPageChangeCallback));
629
+ PageChangeCallbackImpl = __decorate([
630
+ NativeClass
631
+ ], PageChangeCallbackImpl);
642
632
  PageChangeCallback = PageChangeCallbackImpl;
643
633
  }
644
634
  let PagerRecyclerAdapter;
@@ -646,139 +636,138 @@ function initPagerRecyclerAdapter() {
646
636
  if (PagerRecyclerAdapter) {
647
637
  return;
648
638
  }
649
- var PagerRecyclerAdapterImpl = /** @class */ (function (_super) {
650
- __extends(PagerRecyclerAdapterImpl, _super);
651
- function PagerRecyclerAdapterImpl(owner) {
652
- var _this = _super.call(this) || this;
653
- _this.owner = owner;
654
- return global.__native(_this);
655
- }
656
- PagerRecyclerAdapterImpl.prototype.onCreateViewHolder = function (param0, type) {
657
- var owner = this.owner ? this.owner.get() : null;
658
- if (!owner) {
659
- return null;
660
- }
661
- var template = owner._itemTemplatesInternal[type];
662
- var view = template.createView();
663
- if (!view && owner._itemViewLoader !== undefined) {
664
- view = owner._itemViewLoader(template.key);
665
- }
666
- var sp = new StackLayout();
667
- if (view) {
668
- sp.addChild(view);
639
+ let PagerRecyclerAdapterImpl = class PagerRecyclerAdapterImpl extends androidx.recyclerview.widget.RecyclerView.Adapter {
640
+ constructor(owner) {
641
+ super();
642
+ this.owner = owner;
643
+ return global.__native(this);
669
644
  }
670
- else {
671
- sp[PLACEHOLDER] = true;
672
- }
673
- owner._addView(sp);
674
- sp.nativeView.setLayoutParams(new android.view.ViewGroup.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT));
675
- owner._realizedItems.set(sp.nativeView, sp);
676
- initPagerViewHolder();
677
- return new PagerViewHolder(new WeakRef(sp), new WeakRef(owner));
678
- };
679
- PagerRecyclerAdapterImpl.prototype.getPosition = function (index) {
680
- var owner = this.owner && this.owner.get();
681
- var position = index;
682
- if (owner && owner.circularMode) {
683
- if (position === 0) {
684
- position = this.lastDummy();
645
+ onCreateViewHolder(param0, type) {
646
+ const owner = this.owner ? this.owner.get() : null;
647
+ if (!owner) {
648
+ return null;
685
649
  }
686
- else if (position === this.firstDummy()) {
687
- position = 0;
650
+ const template = owner._itemTemplatesInternal[type];
651
+ let view = template.createView();
652
+ if (!view && owner._itemViewLoader !== undefined) {
653
+ view = owner._itemViewLoader(template.key);
654
+ }
655
+ const sp = new StackLayout();
656
+ if (view) {
657
+ sp.addChild(view);
688
658
  }
689
659
  else {
690
- position = position - 1;
660
+ sp[PLACEHOLDER] = true;
691
661
  }
692
- }
693
- return position;
694
- };
695
- PagerRecyclerAdapterImpl.prototype.onBindViewHolder = function (holder, index) {
696
- var owner = this.owner ? this.owner.get() : null;
697
- if (owner) {
698
- if (owner.circularMode) {
699
- if (index === 0) {
700
- index = this.lastDummy();
662
+ owner._addView(sp);
663
+ sp.nativeView.setLayoutParams(new android.view.ViewGroup.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT));
664
+ owner._realizedItems.set(sp.nativeView, sp);
665
+ initPagerViewHolder();
666
+ return new PagerViewHolder(new WeakRef(sp), new WeakRef(owner));
667
+ }
668
+ getPosition(index) {
669
+ const owner = this.owner && this.owner.get();
670
+ let position = index;
671
+ if (owner && owner.circularMode) {
672
+ if (position === 0) {
673
+ position = this.lastDummy();
701
674
  }
702
- else if (index === this.firstDummy()) {
703
- index = 0;
675
+ else if (position === this.firstDummy()) {
676
+ position = 0;
704
677
  }
705
678
  else {
706
- index = index - 1;
679
+ position = position - 1;
707
680
  }
708
681
  }
709
- var bindingContext = owner._getDataItem(index);
710
- var args = {
711
- eventName: ITEMLOADING,
712
- object: owner,
713
- android: holder,
714
- ios: undefined,
715
- index: index,
716
- bindingContext: bindingContext,
717
- view: holder.view[PLACEHOLDER] ? null : holder.view.getChildAt(0)
718
- };
719
- owner.notify(args);
720
- if (holder.view[PLACEHOLDER]) {
721
- if (args.view) {
722
- holder.view.addChild(args.view);
682
+ return position;
683
+ }
684
+ onBindViewHolder(holder, index) {
685
+ const owner = this.owner ? this.owner.get() : null;
686
+ if (owner) {
687
+ if (owner.circularMode) {
688
+ if (index === 0) {
689
+ index = this.lastDummy();
690
+ }
691
+ else if (index === this.firstDummy()) {
692
+ index = 0;
693
+ }
694
+ else {
695
+ index = index - 1;
696
+ }
723
697
  }
724
- else {
725
- holder.view.addChild(owner._getDefaultItemContent(index));
698
+ const bindingContext = owner._getDataItem(index);
699
+ const args = {
700
+ eventName: Pager.itemLoadingEvent,
701
+ object: owner,
702
+ android: holder,
703
+ ios: undefined,
704
+ index,
705
+ bindingContext,
706
+ view: holder.view[PLACEHOLDER] ? null : holder.view.getChildAt(0)
707
+ };
708
+ owner.notify(args);
709
+ if (holder.view[PLACEHOLDER]) {
710
+ if (args.view) {
711
+ holder.view.addChild(args.view);
712
+ }
713
+ else {
714
+ holder.view.addChild(owner._getDefaultItemContent(index));
715
+ }
716
+ holder.view[PLACEHOLDER] = false;
726
717
  }
727
- holder.view[PLACEHOLDER] = false;
718
+ owner._prepareItem(holder.view, index);
728
719
  }
729
- owner._prepareItem(holder.view, index);
730
720
  }
731
- };
732
- PagerRecyclerAdapterImpl.prototype.getItemId = function (i) {
733
- var owner = this.owner ? this.owner.get() : null;
734
- var id = i;
735
- if (owner && owner.items) {
736
- var item = owner.items.getItem ? owner.items.getItem(i) : owner.items[i];
737
- if (item) {
738
- id = owner.itemIdGenerator(item, i, owner.items);
721
+ getItemId(i) {
722
+ const owner = this.owner ? this.owner.get() : null;
723
+ let id = i;
724
+ if (owner && owner.items) {
725
+ const item = owner.items.getItem ? owner.items.getItem(i) : owner.items[i];
726
+ if (item) {
727
+ id = owner.itemIdGenerator(item, i, owner.items);
728
+ }
739
729
  }
730
+ return long(id);
740
731
  }
741
- return long(id);
742
- };
743
- PagerRecyclerAdapterImpl.prototype.getItemCount = function () {
744
- var owner = this.owner ? this.owner.get() : null;
745
- return owner && owner.items && owner.items.length
746
- ? owner.items.length + (owner.circularMode ? 2 : 0)
747
- : 0;
748
- };
749
- PagerRecyclerAdapterImpl.prototype.getItemViewType = function (index) {
750
- var owner = this.owner ? this.owner.get() : null;
751
- if (owner) {
752
- var template = owner._getItemTemplate(index);
753
- return owner._itemTemplatesInternal.indexOf(template);
732
+ getItemCount() {
733
+ const owner = this.owner ? this.owner.get() : null;
734
+ return owner && owner.items && owner.items.length ? owner.items.length + (owner.circularMode ? 2 : 0) : 0;
754
735
  }
755
- return 0;
756
- };
757
- PagerRecyclerAdapterImpl.prototype.lastIndex = function () {
758
- var owner = this.owner && this.owner.get();
759
- if (owner) {
760
- if (owner.items.length === 0) {
761
- return 0;
736
+ getItemViewType(index) {
737
+ const owner = this.owner ? this.owner.get() : null;
738
+ if (owner) {
739
+ const template = owner._getItemTemplate(index);
740
+ return owner._itemTemplatesInternal.indexOf(template);
762
741
  }
763
- return owner.circularMode ? this.getItemCount() - 3 : this.getItemCount() - 1;
742
+ return 0;
764
743
  }
765
- return 0;
766
- };
767
- PagerRecyclerAdapterImpl.prototype.firstDummy = function () {
768
- var count = this.getItemCount();
769
- if (count === 0) {
744
+ lastIndex() {
745
+ const owner = this.owner && this.owner.get();
746
+ if (owner) {
747
+ if (owner.items.length === 0) {
748
+ return 0;
749
+ }
750
+ return owner.circularMode ? this.getItemCount() - 3 : this.getItemCount() - 1;
751
+ }
770
752
  return 0;
771
753
  }
772
- return this.getItemCount() - 1;
773
- };
774
- PagerRecyclerAdapterImpl.prototype.lastDummy = function () {
775
- return this.lastIndex();
776
- };
777
- PagerRecyclerAdapterImpl.prototype.hasStableIds = function () {
778
- return true;
754
+ firstDummy() {
755
+ const count = this.getItemCount();
756
+ if (count === 0) {
757
+ return 0;
758
+ }
759
+ return this.getItemCount() - 1;
760
+ }
761
+ lastDummy() {
762
+ return this.lastIndex();
763
+ }
764
+ hasStableIds() {
765
+ return true;
766
+ }
779
767
  };
780
- return PagerRecyclerAdapterImpl;
781
- }(androidx.recyclerview.widget.RecyclerView.Adapter));
768
+ PagerRecyclerAdapterImpl = __decorate([
769
+ NativeClass
770
+ ], PagerRecyclerAdapterImpl);
782
771
  PagerRecyclerAdapter = PagerRecyclerAdapterImpl;
783
772
  }
784
773
  let StaticPagerStateAdapter;
@@ -786,89 +775,91 @@ function initStaticPagerStateAdapter() {
786
775
  if (StaticPagerStateAdapter) {
787
776
  return;
788
777
  }
789
- var StaticPagerStateAdapterImpl = /** @class */ (function (_super) {
790
- __extends(StaticPagerStateAdapterImpl, _super);
791
- function StaticPagerStateAdapterImpl(owner) {
792
- var _this = _super.call(this) || this;
793
- _this.owner = owner;
794
- return global.__native(_this);
795
- }
796
- StaticPagerStateAdapterImpl.prototype.onCreateViewHolder = function (param0, type) {
797
- var owner = this.owner ? this.owner.get() : null;
798
- if (!owner) {
799
- return null;
778
+ let StaticPagerStateAdapterImpl = class StaticPagerStateAdapterImpl extends androidx.recyclerview.widget.RecyclerView.Adapter {
779
+ constructor(owner) {
780
+ super();
781
+ this.owner = owner;
782
+ return global.__native(this);
800
783
  }
801
- var view = owner._childrenViewsType.get(type);
802
- var sp = new StackLayout(); // Pager2 requires match_parent so add a parent with to fill
803
- if (view && !view.parent) {
804
- sp.addChild(view);
784
+ onCreateViewHolder(param0, type) {
785
+ const owner = this.owner ? this.owner.get() : null;
786
+ if (!owner) {
787
+ return null;
788
+ }
789
+ const view = owner._childrenViewsType.get(type);
790
+ const sp = new StackLayout();
791
+ if (view && !view.parent) {
792
+ sp.addChild(view);
793
+ }
794
+ else {
795
+ sp[PLACEHOLDER] = true;
796
+ }
797
+ owner._addView(sp);
798
+ sp.nativeView.setLayoutParams(new android.view.ViewGroup.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT));
799
+ owner._realizedItems.set(sp.nativeView, sp);
800
+ initPagerViewHolder();
801
+ return new PagerViewHolder(new WeakRef(sp), new WeakRef(owner));
802
+ }
803
+ onBindViewHolder(holder, index) {
804
+ const owner = this.owner ? this.owner.get() : null;
805
+ if (owner) {
806
+ const args = {
807
+ eventName: Pager.itemLoadingEvent,
808
+ object: owner,
809
+ android: holder,
810
+ ios: undefined,
811
+ index,
812
+ view: holder.view[PLACEHOLDER] ? null : holder.view
813
+ };
814
+ owner.notify(args);
815
+ if (holder.view[PLACEHOLDER]) {
816
+ if (args.view) {
817
+ holder.view.addChild(args.view);
818
+ }
819
+ holder.view[PLACEHOLDER] = false;
820
+ }
821
+ }
805
822
  }
806
- else {
807
- sp[PLACEHOLDER] = true;
823
+ hasStableIds() {
824
+ return true;
808
825
  }
809
- owner._addView(sp);
810
- sp.nativeView.setLayoutParams(new android.view.ViewGroup.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT));
811
- initPagerViewHolder();
812
- return new PagerViewHolder(new WeakRef(sp), new WeakRef(owner));
813
- };
814
- StaticPagerStateAdapterImpl.prototype.onBindViewHolder = function (holder, index) {
815
- var owner = this.owner ? this.owner.get() : null;
816
- if (owner) {
817
- var args = {
818
- eventName: ITEMLOADING,
819
- object: owner,
820
- android: holder,
821
- ios: undefined,
822
- index: index,
823
- view: holder.view[PLACEHOLDER] ? null : holder.view
824
- };
825
- owner.notify(args);
826
- if (holder.view[PLACEHOLDER]) {
827
- if (args.view) {
828
- holder.view.addChild(args.view);
826
+ getItem(i) {
827
+ const owner = this.owner ? this.owner.get() : null;
828
+ if (owner) {
829
+ if (owner._childrenViews) {
830
+ return owner._childrenViews[i].view;
829
831
  }
830
- holder.view[PLACEHOLDER] = false;
831
832
  }
833
+ return null;
832
834
  }
833
- };
834
- StaticPagerStateAdapterImpl.prototype.hasStableIds = function () {
835
- return true;
836
- };
837
- StaticPagerStateAdapterImpl.prototype.getItem = function (i) {
838
- var owner = this.owner ? this.owner.get() : null;
839
- if (owner) {
840
- if (owner._childrenViews) {
841
- return owner._childrenViews[i].view;
835
+ getItemId(i) {
836
+ const owner = this.owner ? this.owner.get() : null;
837
+ let id = i;
838
+ if (owner) {
839
+ const item = this.getItem(i);
840
+ if (item) {
841
+ id = owner.itemIdGenerator(item, i, Array.from(owner._childrenViews));
842
+ }
842
843
  }
843
- }
844
- return null;
845
- };
846
- StaticPagerStateAdapterImpl.prototype.getItemId = function (i) {
847
- var owner = this.owner ? this.owner.get() : null;
848
- var id = i;
849
- if (owner) {
850
- var item = this.getItem(i);
851
- if (item) {
852
- id = owner.itemIdGenerator(item, i, Array.from(owner._childrenViews));
844
+ return long(id);
845
+ }
846
+ getItemCount() {
847
+ var _a;
848
+ const owner = this.owner ? this.owner.get() : null;
849
+ return (owner && ((_a = owner._childrenViews) === null || _a === void 0 ? void 0 : _a.length)) || 0;
850
+ }
851
+ getItemViewType(index) {
852
+ var _a;
853
+ const owner = (_a = this.owner) === null || _a === void 0 ? void 0 : _a.get();
854
+ if (owner && owner._childrenViews) {
855
+ return owner._childrenViews[index].type;
853
856
  }
857
+ return index;
854
858
  }
855
- return long(id);
856
859
  };
857
- StaticPagerStateAdapterImpl.prototype.getItemCount = function () {
858
- var _a;
859
- var owner = this.owner ? this.owner.get() : null;
860
- return owner && ((_a = owner._childrenViews) === null || _a === void 0 ? void 0 : _a.length) || 0;
861
- };
862
- StaticPagerStateAdapterImpl.prototype.getItemViewType = function (index) {
863
- var _a;
864
- var owner = (_a = this.owner) === null || _a === void 0 ? void 0 : _a.get();
865
- if (owner && owner._childrenViews) {
866
- return owner._childrenViews[index].type;
867
- }
868
- return index;
869
- };
870
- return StaticPagerStateAdapterImpl;
871
- }(androidx.recyclerview.widget.RecyclerView.Adapter));
860
+ StaticPagerStateAdapterImpl = __decorate([
861
+ NativeClass
862
+ ], StaticPagerStateAdapterImpl);
872
863
  StaticPagerStateAdapter = StaticPagerStateAdapterImpl;
873
864
  }
874
865
  let PagerViewHolder;
@@ -876,23 +867,20 @@ function initPagerViewHolder() {
876
867
  if (PagerViewHolder) {
877
868
  return;
878
869
  }
879
- var PagerViewHolderImpl = /** @class */ (function (_super) {
880
- __extends(PagerViewHolderImpl, _super);
881
- function PagerViewHolderImpl(owner, pager) {
882
- var _this = _super.call(this, owner.get().nativeViewProtected) || this;
883
- _this.owner = owner;
884
- _this.pager = pager;
885
- return global.__native(_this);
886
- }
887
- Object.defineProperty(PagerViewHolderImpl.prototype, "view", {
888
- get: function () {
870
+ let PagerViewHolderImpl = class PagerViewHolderImpl extends androidx.recyclerview.widget.RecyclerView.ViewHolder {
871
+ constructor(owner, pager) {
872
+ super(owner.get().nativeViewProtected);
873
+ this.owner = owner;
874
+ this.pager = pager;
875
+ return global.__native(this);
876
+ }
877
+ get view() {
889
878
  return this.owner ? this.owner.get() : null;
890
- },
891
- enumerable: true,
892
- configurable: true
893
- });
894
- return PagerViewHolderImpl;
895
- }(androidx.recyclerview.widget.RecyclerView.ViewHolder));
879
+ }
880
+ };
881
+ PagerViewHolderImpl = __decorate([
882
+ NativeClass
883
+ ], PagerViewHolderImpl);
896
884
  PagerViewHolder = PagerViewHolderImpl;
897
885
  }
898
886
  let ZoomOutPageTransformer;
@@ -900,29 +888,28 @@ function initZoomOutPageTransformer() {
900
888
  if (ZoomOutPageTransformer) {
901
889
  return;
902
890
  }
903
- var ZoomOutPageTransformerImpl = /** @class */ (function (_super) {
904
- __extends(ZoomOutPageTransformerImpl, _super);
905
- function ZoomOutPageTransformerImpl() {
906
- var _this = _super.call(this) || this;
907
- return global.__native(_this);
908
- }
909
- ZoomOutPageTransformerImpl.prototype.transformPage = function (view, position) {
910
- var MIN_SCALE = 0.85;
911
- if (position <= 1 || position >= -1) {
912
- var scale = Math.max(MIN_SCALE, 1 - Math.abs(position));
913
- view.setScaleX(scale);
914
- view.setScaleY(scale);
915
- }
916
- else {
917
- view.setScaleX(1);
918
- view.setScaleY(1);
891
+ let ZoomOutPageTransformerImpl = class ZoomOutPageTransformerImpl extends java.lang.Object {
892
+ constructor() {
893
+ super();
894
+ return global.__native(this);
895
+ }
896
+ transformPage(view, position) {
897
+ const MIN_SCALE = 0.85;
898
+ if (position <= 1 || position >= -1) {
899
+ const scale = Math.max(MIN_SCALE, 1 - Math.abs(position));
900
+ view.setScaleX(scale);
901
+ view.setScaleY(scale);
902
+ }
903
+ else {
904
+ view.setScaleX(1);
905
+ view.setScaleY(1);
906
+ }
919
907
  }
920
908
  };
921
909
  ZoomOutPageTransformerImpl = __decorate([
910
+ NativeClass,
922
911
  Interfaces([androidx.viewpager2.widget.ViewPager2.PageTransformer])
923
912
  ], ZoomOutPageTransformerImpl);
924
- return ZoomOutPageTransformerImpl;
925
- }(java.lang.Object));
926
913
  ZoomOutPageTransformer = ZoomOutPageTransformerImpl;
927
914
  }
928
915
  let ZoomInPageTransformer;
@@ -930,25 +917,24 @@ function initZoomInPageTransformer() {
930
917
  if (ZoomInPageTransformer) {
931
918
  return;
932
919
  }
933
- var ZoomInPageTransformerImpl = /** @class */ (function (_super) {
934
- __extends(ZoomInPageTransformerImpl, _super);
935
- function ZoomInPageTransformerImpl() {
936
- var _this = _super.call(this) || this;
937
- return global.__native(_this);
938
- }
939
- ZoomInPageTransformerImpl.prototype.transformPage = function (view, position) {
940
- var scale = position < 0 ? position + 1.0 : Math.abs(1.0 - position);
941
- view.setScaleX(scale);
942
- view.setScaleY(scale);
943
- view.setPivotX(view.getWidth() * 0.5);
944
- view.setPivotY(view.getHeight() * 0.5);
945
- view.setAlpha(view < -1.0 || position > 1.0 ? 0.0 : 1.0 - (scale - 1.0));
920
+ let ZoomInPageTransformerImpl = class ZoomInPageTransformerImpl extends java.lang.Object {
921
+ constructor() {
922
+ super();
923
+ return global.__native(this);
924
+ }
925
+ transformPage(view, position) {
926
+ const scale = position < 0 ? position + 1.0 : Math.abs(1.0 - position);
927
+ view.setScaleX(scale);
928
+ view.setScaleY(scale);
929
+ view.setPivotX(view.getWidth() * 0.5);
930
+ view.setPivotY(view.getHeight() * 0.5);
931
+ view.setAlpha(view < -1.0 || position > 1.0 ? 0.0 : 1.0 - (scale - 1.0));
932
+ }
946
933
  };
947
934
  ZoomInPageTransformerImpl = __decorate([
935
+ NativeClass,
948
936
  Interfaces([androidx.viewpager2.widget.ViewPager2.PageTransformer])
949
937
  ], ZoomInPageTransformerImpl);
950
- return ZoomInPageTransformerImpl;
951
- }(java.lang.Object));
952
938
  ZoomInPageTransformer = ZoomInPageTransformerImpl;
953
939
  }
954
940
  //# sourceMappingURL=index.android.js.map