@@ -171,11 +171,11 @@ export class CollectionView extends CollectionViewBase {
171171 p . onLayout && p . onLayout ( this , left , top , right , bottom ) ;
172172 } ) ;
173173
174- const layoutView = this . nativeViewProtected . collectionViewLayout ;
175- if ( ( layoutView instanceof UICollectionViewFlowLayout && this . _effectiveColWidth ) || this . _effectiveRowHeight ) {
176- // @ts -ignore
177- layoutView . estimatedItemSize = layoutView . itemSize = CGSizeMake ( layout . toDeviceIndependentPixels ( this . _effectiveColWidth ) , layout . toDeviceIndependentPixels ( this . _effectiveRowHeight ) ) ;
178- }
174+ // const layoutView = this.nativeViewProtected.collectionViewLayout;
175+ // if ((layoutView instanceof UICollectionViewFlowLayout && this._effectiveColWidth) || this._effectiveRowHeight) {
176+ // // @ts -ignore
177+ // layoutView.estimatedItemSize = layoutView.itemSize = CGSizeMake(layout.toDeviceIndependentPixels(this._effectiveColWidth), layout.toDeviceIndependentPixels(this._effectiveRowHeight));
178+ // }
179179 this . _map . forEach ( ( cellView , cell ) => {
180180 if ( Trace . isEnabled ( ) ) {
181181 CLog ( CLogTypes . log , 'onLayout' , 'cell' , cellView . _listViewItemIndex ) ;
@@ -219,7 +219,7 @@ export class CollectionView extends CollectionViewBase {
219219 const indexes = NSMutableArray . new < NSIndexPath > ( ) ;
220220 indexes . addObject ( NSIndexPath . indexPathForRowInSection ( event . index , 0 ) ) ;
221221 if ( Trace . isEnabled ( ) ) {
222- CLog ( CLogTypes . info , 'reloadItemsAtIndexPaths' , indexes . count ) ;
222+ CLog ( CLogTypes . info , 'reloadItemsAtIndexPaths' , event . index , indexes . count ) ;
223223 }
224224 UIView . performWithoutAnimation ( ( ) => {
225225 view . performBatchUpdatesCompletion ( ( ) => {
@@ -404,7 +404,7 @@ export class CollectionView extends CollectionViewBase {
404404 needsLayout = needsLayout || oldBindingContext !== bindingContext ;
405405
406406 if ( Trace . isEnabled ( ) ) {
407- CLog ( CLogTypes . log , '_prepareCell' , index , ! ! cell . view , ! ! view , cell . view !== view , needsLayout ) ;
407+ CLog ( CLogTypes . log , '_prepareCell' , index , view && view . _listViewItemIndex , ! ! cell . view , ! ! view , cell . view !== view , needsLayout , JSON . stringify ( oldBindingContext ) , JSON . stringify ( bindingContext ) ) ;
408408 }
409409 const args = this . notifyForItemAtIndex ( this , cell , view , CollectionViewBase . itemLoadingEvent , indexPath , bindingContext ) ;
410410 view = args . view ;
@@ -432,12 +432,23 @@ export class CollectionView extends CollectionViewBase {
432432 this . _addView ( view ) ;
433433 cell . contentView . addSubview ( view . nativeViewProtected ) ;
434434 }
435-
436- cellSize = this . measureCell ( cell , view , indexPath ) ;
437-
435+ ( view as any ) . performLayout = ( ) => { } ;
438436 if ( needsLayout ) {
439437 view . requestLayout ( ) ;
440438 }
439+ cellSize = this . measureCell ( cell , view , indexPath ) ;
440+
441+ //performlayout will ask the whole page to relayout which will break us as it goes downward
442+ // and calls onLayout which layouts the cells ...
443+ ( view as any ) . performLayout = ( ) => {
444+ // this is really ugly!
445+ console . log ( 'performLayout' , view . _listViewItemIndex , index ) ;
446+ const widthSpec = layout . makeMeasureSpec ( cellSize [ 0 ] , layout . EXACTLY ) ;
447+ const heightSpec = layout . makeMeasureSpec ( cellSize [ 1 ] , layout . EXACTLY ) ;
448+ View . measureChild ( this , view , widthSpec , heightSpec ) ;
449+ View . layoutChild ( this , view , 0 , 0 , cellSize [ 0 ] , cellSize [ 1 ] ) ;
450+ console . log ( 'performLayout done ' , view . _listViewItemIndex , index ) ;
451+ } ;
441452
442453 if ( Trace . isEnabled ( ) ) {
443454 CLog ( CLogTypes . log , '_prepareCell done' , index , cellSize ) ;
@@ -588,7 +599,6 @@ export class CollectionView extends CollectionViewBase {
588599 if ( cellView && cellView [ 'isLayoutRequired' ] ) {
589600 this . layoutCell ( indexPath . row , cell , cellView ) ;
590601 }
591-
592602 return cell ;
593603 }
594604 collectionViewWillDisplayCellForItemAtIndexPath ( collectionView : UICollectionView , cell : UICollectionViewCell , indexPath : NSIndexPath ) {
@@ -644,9 +654,9 @@ export class CollectionView extends CollectionViewBase {
644654
645655 let measuredSize = this . getCellSize ( row ) ;
646656 if ( ! measuredSize ) {
647- if ( Trace . isEnabled ( ) ) {
648- CLog ( CLogTypes . log , 'collectionViewLayoutSizeForItemAtIndexPath' , row ) ;
649- }
657+ // if (Trace.isEnabled()) {
658+ // CLog(CLogTypes.log, 'collectionViewLayoutSizeForItemAtIndexPath', row);
659+ // }
650660 const templateType = this . _getItemTemplateType ( indexPath ) ;
651661 if ( templateType ) {
652662 const measureData : any = this . _measureCellMap . get ( templateType ) ;
@@ -660,9 +670,9 @@ export class CollectionView extends CollectionViewBase {
660670 this . _measureCellMap . set ( templateType , { cell, view : cell . view } ) ;
661671 }
662672 }
663- if ( Trace . isEnabled ( ) ) {
664- CLog ( CLogTypes . log , 'collectionViewLayoutSizeForItemAtIndexPath' , row , measuredSize ) ;
665- }
673+ // if (Trace.isEnabled()) {
674+ // CLog(CLogTypes.log, 'collectionViewLayoutSizeForItemAtIndexPath', row, measuredSize);
675+ // }
666676 if ( measuredSize ) {
667677 return CGSizeMake ( layout . toDeviceIndependentPixels ( measuredSize [ 0 ] ) , layout . toDeviceIndependentPixels ( measuredSize [ 1 ] ) ) ;
668678 }
0 commit comments