eclipsesource / tabris-js

Create native mobile apps in JavaScript or TypeScript.
https://tabrisjs.com
BSD 3-Clause "New" or "Revised" License
1.4k stars 170 forks source link

CollectionView does not position initial cells underneath statusBar #1810

Open mpost opened 5 years ago

mpost commented 5 years ago

Problem description

The bounds of the CollectionView are shown underneath the statusBar but the initial cells are not. They are positioned below the statusBar as if the dislplayMode was not set to float. It is possible to scroll the cells underneath though.

Expected behavior

The CollectionView should put the initial cells under the statusBar.

Environment

Code snippet

import {CollectionView, contentView, statusBar, TextView} from 'tabris';

const items = [
  'Apple', 'Banana', 'Cherry', 'Apple', 'Banana', 'Cherry',
  'Apple', 'Banana', 'Cherry', 'Apple', 'Banana', 'Cherry',
  'Apple', 'Banana', 'Cherry', 'Apple', 'Banana', 'Cherry',
  'Apple', 'Banana', 'Cherry', 'Apple', 'Banana', 'Cherry',
  'Apple', 'Banana', 'Cherry', 'Apple', 'Banana', 'Cherry',
  'Apple', 'Banana', 'Cherry', 'Apple', 'Banana', 'Cherry',
  'Apple', 'Banana', 'Cherry', 'Apple', 'Banana', 'Cherry',
  'Apple', 'Banana', 'Cherry', 'Apple', 'Banana', 'Cherry',
  'Apple', 'Banana', 'Cherry', 'Apple', 'Banana', 'Cherry',
  'Apple', 'Banana', 'Cherry', 'Apple', 'Banana', 'Cherry'
];

statusBar.displayMode = 'float';
statusBar.background = '#dddd';

new CollectionView({
  left: 0, top: 0, right: 0, bottom: 0,
  itemCount: items.length,
  createCell: () => new TextView(),
  updateCell: (view, index) => {
    view.text = items[index];
  }
}).appendTo(contentView);
mpost commented 5 years ago

The issue is related to the "safe area" as present on iOS. The CollectionView pushed its cells to be inside the devices safe area (in this case below the statusBar). We have discussed possible solutions to better support the safe area and will improve upon that in the future.

patrykmol commented 3 years ago

This behavior is intended in case of scroll view and it's derivatives.