Skip to content

Commit fc77798

Browse files
committed
chore(ios): handle safearea like collectionview
1 parent c783ae3 commit fc77798

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/ui-pager/index.ios.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ export class Pager extends PagerBase {
620620

621621
public onLayout(left: number, top: number, right: number, bottom: number) {
622622
super.onLayout(left, top, right, bottom);
623-
if (this.iosOverflowSafeAreaEnabled) {
623+
if (this.iosOverflowSafeArea) {
624624
const safeArea = this.getSafeAreaInsets();
625625
this._effectiveItemHeight += safeArea.top + safeArea.bottom;
626626
}
@@ -1106,6 +1106,7 @@ class UICollectionViewDataSourceImpl extends NSObject implements UICollectionVie
11061106
// }
11071107

11081108
// If cell is reused it has old content - remove it first.
1109+
const firstRender = !cell.view;
11091110
if (!cell.view) {
11101111
cell.owner = new WeakRef(view);
11111112
} else if (cell.view !== view) {
@@ -1138,8 +1139,9 @@ class UICollectionViewDataSourceImpl extends NSObject implements UICollectionVie
11381139
// }
11391140
}
11401141

1141-
view.iosOverflowSafeArea = owner.iosOverflowSafeArea;
1142-
view['iosIgnoreSafeArea'] = owner['iosIgnoreSafeArea'];
1142+
if (firstRender) {
1143+
view['iosIgnoreSafeArea'] = true;
1144+
}
11431145
owner._layoutCell(view, indexPath);
11441146
const size = owner._getSize();
11451147
const width = Utils.layout.toDevicePixels(size.width);
@@ -1154,12 +1156,14 @@ class UICollectionViewDataSourceImpl extends NSObject implements UICollectionVie
11541156
const template = owner && owner._getItemTemplate(indexPath.row);
11551157
cell = collectionView.dequeueReusableCellWithReuseIdentifierForIndexPath(template.key, indexPath) || PagerCell.initWithEmptyBackground();
11561158
cell.index = indexPath;
1159+
const firstRender = !cell.view;
11571160
if (owner) {
11581161
const size = owner._getSize();
11591162
owner._prepareCell(cell, indexPath);
11601163
const cellView: any = (cell as PagerCell).view;
1161-
cellView.iosOverflowSafeArea = owner.iosOverflowSafeArea;
1162-
cellView['iosIgnoreSafeArea'] = owner['iosIgnoreSafeArea'];
1164+
if (firstRender) {
1165+
cellView['iosIgnoreSafeArea'] = true;
1166+
}
11631167
if (cellView && cellView.isLayoutRequired) {
11641168
View.layoutChild(owner, cellView, 0, 0, Utils.layout.toDevicePixels(size.width), Utils.layout.toDevicePixels(size.height));
11651169
}

0 commit comments

Comments
 (0)