66 KeyedTemplate ,
77 Length ,
88 Observable ,
9+ Property ,
910 ProxyViewContainer ,
1011 Trace ,
1112 View ,
@@ -23,6 +24,37 @@ export * from './collectionview-common';
2324
2425const infinity = layout . makeMeasureSpec ( 0 , layout . UNSPECIFIED ) ;
2526
27+
28+ export enum ContentInsetAdjustmentBehavior {
29+ Always = UIScrollViewContentInsetAdjustmentBehavior . Always ,
30+ Automatic = UIScrollViewContentInsetAdjustmentBehavior . Automatic ,
31+ Never = UIScrollViewContentInsetAdjustmentBehavior . Never ,
32+ ScrollableAxes = UIScrollViewContentInsetAdjustmentBehavior . ScrollableAxes
33+ }
34+
35+ function parseContentInsetAdjustmentBehavior ( value : string | number ) {
36+ if ( typeof value === 'string' ) {
37+ switch ( value ) {
38+ case 'always' :
39+ return ContentInsetAdjustmentBehavior . Always ;
40+ case 'never' :
41+ return ContentInsetAdjustmentBehavior . Never ;
42+ case 'ccrollableAxes' :
43+ return ContentInsetAdjustmentBehavior . ScrollableAxes ;
44+ default :
45+ case 'automatic' :
46+ return ContentInsetAdjustmentBehavior . Automatic ;
47+ }
48+ } else {
49+ return value ;
50+ }
51+ }
52+ export const contentInsetAdjustmentBehaviorProperty = new Property < CollectionView , ContentInsetAdjustmentBehavior > ( {
53+ name : 'contentInsetAdjustmentBehavior' ,
54+ valueConverter : parseContentInsetAdjustmentBehavior ,
55+ defaultValue : ContentInsetAdjustmentBehavior . Automatic
56+ } ) ;
57+
2658export class CollectionView extends CollectionViewBase {
2759 private _layout : UICollectionViewLayout ;
2860 private _dataSource : CollectionViewDataSource ;
@@ -112,6 +144,10 @@ export class CollectionView extends CollectionViewBase {
112144 return this . _map . size ;
113145 }
114146
147+ public [ contentInsetAdjustmentBehaviorProperty . setNative ] ( value : ContentInsetAdjustmentBehavior ) {
148+ this . nativeViewProtected . contentInsetAdjustmentBehavior = value as any ;
149+ }
150+
115151 public [ paddingTopProperty . setNative ] ( value : Length ) {
116152 this . _setPadding ( { top : layout . toDeviceIndependentPixels ( this . effectivePaddingTop ) } ) ;
117153 }
@@ -505,12 +541,12 @@ export class CollectionView extends CollectionViewBase {
505541 }
506542 return undefined ;
507543 }
508- layoutCell ( index : number , cell : any , cellView : View ) : any {
544+ layoutCell ( index : number , cell : CollectionViewCell , cellView : View ) : any {
509545 const cellSize = this . getCellSize ( index ) ;
510546 cellView . iosOverflowSafeAreaEnabled = false ;
511547 View . layoutChild ( this , cellView , 0 , 0 , cellSize [ 0 ] , cellSize [ 1 ] ) ;
512548 if ( Trace . isEnabled ( ) ) {
513- CLog ( CLogTypes . log , 'layoutCell' , index , cellSize [ 0 ] , cellSize [ 1 ] , cellView . getMeasuredWidth ( ) , cellView . getMeasuredHeight ( ) ) ;
549+ CLog ( CLogTypes . log , 'layoutCell' , index , cellView . getMeasuredWidth ( ) , cellView . getMeasuredHeight ( ) ) ;
514550 }
515551 }
516552
@@ -787,3 +823,5 @@ class UICollectionViewDelegateImpl extends NSObject implements UICollectionViewD
787823 }
788824 }
789825}
826+
827+ contentInsetAdjustmentBehaviorProperty . register ( CollectionView ) ;
0 commit comments