Skip to content

Commit d7cecc5

Browse files
committed
chore: refactor
1 parent fc77798 commit d7cecc5

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

src/ui-pager/index.common.ts

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,20 @@ let UNIQUE_VIEW_TYPE = 0;
7070

7171
@CSSType('Pager')
7272
export abstract class PagerBase extends ContainerView implements AddChildFromBuilder {
73+
static mRegisteredTransformers = {};
74+
// This one works along with existing NS property change event system
75+
public static selectedIndexChangeEvent = 'selectedIndexChange';
76+
public static scrollEvent = 'scroll';
77+
public static swipeEvent = 'swipe';
78+
public static swipeStartEvent = 'swipeStart';
79+
public static swipeOverEvent = 'swipeOver';
80+
public static swipeEndEvent = 'swipeEnd';
81+
public static loadMoreItemsEvent = 'loadMoreItems';
82+
public static itemLoadingEvent = 'itemLoading';
83+
public static itemDisposingEvent = 'itemDisposing';
84+
85+
public static knownFunctions = ['itemTemplateSelector', 'itemIdGenerator']; // See component-builder.ts isKnownFunction
86+
7387
public items: any[] | ItemsSource;
7488
public selectedIndex: number;
7589
public itemTemplate: string | Template;
@@ -83,31 +97,21 @@ export abstract class PagerBase extends ContainerView implements AddChildFromBui
8397
public autoPlayDelay: number;
8498
public autoPlay: boolean;
8599
public preserveIndexOnItemsChange: boolean = false;
86-
// This one works along with existing NS property change event system
87-
public static selectedIndexChangeEvent = 'selectedIndexChange';
88-
public static scrollEvent = 'scroll';
89-
public static swipeEvent = 'swipe';
90-
public static swipeStartEvent = 'swipeStart';
91-
public static swipeOverEvent = 'swipeOver';
92-
public static swipeEndEvent = 'swipeEnd';
93-
public static loadMoreItemsEvent = 'loadMoreItems';
94-
public static itemLoadingEvent = 'itemLoading';
95-
public static itemDisposingEvent = 'itemDisposing';
96100
public orientation: Orientation;
97-
public _effectiveItemHeight: number;
98-
public _effectiveItemWidth: number;
99101
public transformers: string;
100102
public loadMoreCount: number = 1;
101-
public _childrenViews: { view: PagerItem; type: number }[];
102-
abstract readonly _childrenCount: number;
103103
public disableSwipe: boolean = false;
104-
public static knownFunctions = ['itemTemplateSelector', 'itemIdGenerator']; // See component-builder.ts isKnownFunction
104+
105+
abstract readonly _childrenCount: number;
106+
107+
protected _effectiveItemHeight: number;
108+
protected _effectiveItemWidth: number;
109+
public _childrenViews: { view: PagerItem; type: number }[];
105110

106111
protected mObservableArrayInstance: ObservableArray<any>;
107112

108113
abstract refresh(): void;
109114

110-
static mRegisteredTransformers = {};
111115
public static registerTransformer(key: string, transformer) {
112116
PagerBase.mRegisteredTransformers[key] = transformer;
113117
}

src/ui-pager/index.ios.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -880,9 +880,7 @@ class UICollectionDelegateImpl extends NSObject implements UICollectionViewDeleg
880880

881881
public collectionViewLayoutMinimumLineSpacingForSectionAtIndex(collectionView: UICollectionView, collectionViewLayout: UICollectionViewLayout, section: number): number {
882882
const owner = this._owner ? this._owner.get() : null;
883-
if (!owner) return 0;
884-
const result = owner._getSpacing();
885-
return result;
883+
return owner?._getSpacing() ?? 0;
886884
}
887885

888886
public scrollViewWillBeginDragging(scrollView: UIScrollView): void {
@@ -1201,7 +1199,7 @@ class UICollectionViewFlowLinearLayoutImpl extends UICollectionViewFlowLayout {
12011199
const owner = this._owner ? this._owner.get() : null;
12021200
const originalLayoutAttribute = super.layoutAttributesForElementsInRect(rect);
12031201
const visibleLayoutAttributes = NSMutableArray.alloc().init();
1204-
if (owner && owner.transformers) {
1202+
if (owner?.transformers) {
12051203
const transformsArray = owner.transformers
12061204
.split(' ')
12071205
.map((s) => Pager.mRegisteredTransformers[s])
@@ -1217,11 +1215,10 @@ class UICollectionViewFlowLinearLayoutImpl extends UICollectionViewFlowLayout {
12171215
}
12181216
}
12191217
}
1220-
} else {
1221-
return originalLayoutAttribute;
1218+
return visibleLayoutAttributes as any;
12221219
}
12231220

1224-
return visibleLayoutAttributes as any;
1221+
return originalLayoutAttribute;
12251222
}
12261223

12271224
public shouldInvalidateLayoutForBoundsChange(newBounds: CGRect): boolean {

0 commit comments

Comments
 (0)