react-native-week-view: React Native on macOS or on web - broken width and month not changing

The library is not working when compiling a react-native project for macOS (Catalyst for example). Itโ€™s not working either when using react-native-web version.

The following elements are not working:

  1. The width of the day header is not correct
  2. The scroll is hard to test in these conditions, but it seems to not be able to trigger a next month change when you scroll past a certain amount of time horizontally.

Please find a video illustrating the first examples:

react-native-web-week-view-480

Steps to reproduce:

Notes

  • It could be some simple width and height calculation to update and that would make it work ๐Ÿคž

About this issue

Most upvoted comments

The current workaround is to add navigation button to navigate to previous or next week.

How can we get this issue moving forward?

PR #201 will fix up to 4.1.

As to 4.2, Iโ€™m afraid without scroll events in web there is not much more we can do. I see a lot of attention in rn-web, (e.g. https://github.com/necolas/react-native-web/issues/2249, https://github.com/necolas/react-native-web/pull/2241), hopefully they will have a fix soon

On the side, Iโ€™m implementing some performance improvements, and that might include migrating to recycler-list-view, which should support rn-web scroll events. Although these changes are taking me a bit longer. (Iโ€™ll probably open a separate issue regarding this soon). UPDATE: See #209, we are not migrating to another library for now.

So our best bet might be to wait for react-native-web to support onMomentumScrollEnd.

Maybe this comment is related to our issue: https://github.com/expo/expo/issues/16822#issuecomment-1099169366 ?

TL;DR: I fixed some things, but is still not working 100%, probably due to an upstream bug from react-native-web VirtualizedList. Demo:

fixed-header

(btw the cursor is not moving because I was scrolling with the wheel)


Details:

There are multiple things in the initial example that were wrong:

  1. Header does not have the appropriate width
  2. All the grey horizontal grid lines are rendered at 00:00hrs
  3. Vertical scrolling works, but the initial scroll to the startHour is not performed (i.e. you cannot call scrollTo() for the ScrollView ref)
  4. Horizontal scrolling is broken 4.1 The initial position should be today (in my example would be May 6), but the initial position shows April 21 4.2 You cannot scroll past certain dates to the right or left
  5. When scrolling the grid horizontally, the header does not follow the grid smoothly (i.e. animated)

What I did:

  1. ๐Ÿ‘ Compute the header width using the size of the window
  2. ๐Ÿ‘ Grey gridlines are now properly rendered throughout the grid (was a simple flex issue)
  3. ๐Ÿ‘ The initial vertical position is fixed, and the vertical scroll works properly
    • Note: this required constraining the ScrollViewโ€™s height to height: '100vh' (100 viewportโ€™s height, web only)
  4. VirtualizedList and FlatList have shown issues in react-native-web (for example see a list of issues here: https://github.com/necolas/react-native-web/pull/2241#issuecomment-1055824946)
    • 4.1. ๐Ÿ‘ The initialScrollIndex behavior was fixed --> the week starts pointing to today (see gif)
    • 4.2 ๐Ÿ‘Ž ๐Ÿ‘Ž The scrolling is still constrained to 5 pages (weeks), from April 18 to May 22 (see gif)
      • Culprit: the onMomentumScrollEnd event from the horizontal VirtualizedList is not being triggered
      • We need that event to add pages (weeks) dynamically to the left and right
      • In the first render, we show 5 pages (those are the only pages shown in the gif)
      • I tested a small VirtualizedList example, and I think this is an issue from react-native-web (I can provide more details for a small repro)
  5. ๐Ÿ‘Ž Could not make the animation smoother (though, the horizontal scrolling should be resolved first anyway)

4.2 is probably a dealbreaker for most apps. We should corroborate if it is a bug from react-native-web; hopefully they will have a workaround soon

I havenโ€™t added meets on the first test I did. Let me give it a try and get back to u