Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RNMobile] Adjust bottom-sheet #18574

Merged
merged 24 commits into from
Feb 12, 2020
Merged

[RNMobile] Adjust bottom-sheet #18574

merged 24 commits into from
Feb 12, 2020

Conversation

lukewalczak
Copy link
Member

@lukewalczak lukewalczak commented Nov 18, 2019

Description

Ref to gb-mobile PR: wordpress-mobile/gutenberg-mobile#1837

That PR is fixing the issue with wrong layout within inserter: wordpress-mobile/gutenberg-mobile#1404

That PR is fixing: wordpress-mobile/WordPress-iOS#13304.

NOTE: At the same point, it's disabling swipe-to-close option on Android ( swipe / drag is still available in the top most area - near drag indicator).

How has this been tested?

  1. Run the app on a smaller device or on the regular in horizontal mode
  2. User should be able to scroll through all the blocks / add them
  3. Please check also other bottom-sheets in the app e.g: Image settings

Screenshots

ios android
ios_scroll_swipe android_drag

Types of changes

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR. .

@lukewalczak lukewalczak changed the title Initial work on iOS Inserter [RNMobile] Initial work on iOS Inserter Nov 18, 2019
@lukewalczak lukewalczak marked this pull request as ready for review January 30, 2020 08:56
@lukewalczak lukewalczak changed the title [RNMobile] Initial work on iOS Inserter [RNMobile] Adjust bottom-sheet Jan 30, 2020
@pinarol pinarol requested a review from etoledom January 30, 2020 10:54
@pinarol
Copy link
Contributor

pinarol commented Jan 30, 2020

cc @iamthomasbishop Could you check the screen captures in this PR?

@pinarol
Copy link
Contributor

pinarol commented Jan 30, 2020

cc @koke could you also verify this is solving the problems you mentioned in the issue?

@dratwas
Copy link
Contributor

dratwas commented Jan 30, 2020

Hi! It is only a temporary solution since in the future we will be able to have swipe with the scroll on Android as well. We just need to wait for that fix to be merged software-mansion/react-native-gesture-handler#937.

Some context:
I was trying to achieve the perfect solution with a scroll view and swipe but failed because of an issue with react-native-gesture-handler. I used react-native-reanimated-bottom-sheet that supports all we need (ScrollView inside, swipe to hide, keyboard aware view) but - It is rendered inside our RN root view that doesn't cover the whole screen (we have a native navbar that is above) and it looks like that:

We need to render it inside react-native Modal component that creates a separate native view that covers the whole screen. Unfortunately, react-native-gesture-handler doesn't work on Android in Modal software-mansion/react-native-gesture-handler#139 . Fortunately, @osdnk already created a fix for that 🎉 software-mansion/react-native-gesture-handler#937 I tested it and it seems to work. We need to wait for reviews, merge, and release and we will be able to implement the Bottom Sheet that works as we wanted. In addition, we will change the old PanResponder that is controlled by the JS responder system to a more performant one.

Technically we are able to make it with react-native-modal that we use at this moment but it works really really bad because when it recognizes that the touch should be handled by Scroll View it calls scrollView.scrollTo() to scroll instead of swipe. However, it doesn't have any easing etc, so the feeling when scrolling is terrible.

@pinarol
Copy link
Contributor

pinarol commented Jan 30, 2020

Thank you @dratwas for those great news and all your effort on that!

To sum up, until the time we have that perfect solution we'll need to solve the issue about block picker not fitting into small screens anymore. So I believe this PR brings a good short term solution to that.

scrollEventThrottle={ 16 }
style={ { maxHeight } }
contentContainerStyle={ [ styles.content, contentStyle ] }
>
{ this.props.children }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing which is worrying me ( and I'm not proud of it :( ) is placing a FlatList within a ScrollView. Generally, it shouldn't have any performance issues since scrolling is disabled in a FlatList. There is no issue with rewriting it, but we're going to lose nice features such as ItemSeparatorComponent or numColumns. Please let me know wdyt.

@lukewalczak
Copy link
Member Author

One more thing which I think it's worth mentioning is these changes affect (fixes) other bottom-sheets in the application, eg: Image settings. This is how it looks like on iPhone 6 with the largest font:

before after
Screenshot 2020-01-30 at 18 25 07 Screenshot 2020-01-30 at 18 23 21

As you can notice in the screenshot before the change, there is not too much free space and keep in mind that e.g Button block will have more settings inside.

@iamthomasbishop
Copy link

iamthomasbishop commented Jan 30, 2020

This is much better than what exists now so I agree w/ @pinarol we should ship these improvements and iterate. With that said, I have a few bits of feedback:

  • The sizing/spacing feels a bit off on the top drag handle. IIRC, the drag handle area should be ~16px and the scroll area should be flush up against that "container". Example EDIT: The scroll container itself is flush up against the drag handle container, but there is 8px of padding-top on the scroll container. So visually, it is 24px from the top — 16px of that is the drag handle area, 8px is additional padding-top on the scroll container. Another visual example here.

  • It looks like something is off about the bottom safe area around the home indicator. Sometimes the contents of the sheet scroll directly beneath the home indicator (which is what I would expect) and sometimes they do not. Is there any way we can remove the background fill from the safe area that covers the sheet contents? Examples: Expected, not covering the contents vs. Covering

NOTE: At the same point, it's disabling swipe-to-close option on Android ( swipe / drag is still available in the top most area - near drag indicator).

Can the user tap the scrim to dismiss the sheet? I would hope so. Even if they can, because we won't provide swipe-to-dismiss on Android, we might want to target that for a shorter max-height on Android so that the scrim and drag handle are slightly more reachable while still showing ~2.5 rows of blocks — maybe ~250-260px tall so that it looks something like this?

@lukewalczak
Copy link
Member Author

lukewalczak commented Jan 31, 2020

UPDATES:

  • Horizontal:
top during scroll bottom
Screenshot 2020-01-31 at 15 01 09 Screenshot 2020-01-31 at 15 01 14 Screenshot 2020-01-31 at 15 01 18
  • Vertical:
top during scroll bottom
Screenshot 2020-01-31 at 15 01 25 Screenshot 2020-01-31 at 15 01 29 Screenshot 2020-01-31 at 15 01 31

@etoledom etoledom added the Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change) label Jan 31, 2020
@lukewalczak
Copy link
Member Author

UPDATES

Q&A

On Android I still see a two columns inserter:

This is kind of expected behavior, especially on devices with an 18:9 (or 18,5:9) aspect ratio and enabled screen zoom on max.

Number of columns is calculated based on Dimensions.get( 'window' ).width / itemWidth, where itemWidth is fixed and value is 120. The problem here is the width from Dimensions which is changing accordingly to screen zoom (the width is decreasing while screen zoom is increasing). That's why e.g on Samsung S8 on neutral zoom we'll see 3 columns (width is ~411), but on max zoom we'll see 2 columns (width is ~320)

neutral zoom max zoom
Screenshot_20200203-140451_Gutenberg Screenshot_20200203-140507_Gutenberg

There seems to be bouncing even when the content is smaller than the maximum height

Tbh, I was not able to reproduce it before refactor and after as well. Please check it one more time, if you will face that issue again, please send me some repro steps along with device configuration / specs 🙏

@iamthomasbishop
Copy link

This is kind of expected behavior, especially on devices with an 18:9 (or 18,5:9) aspect ratio and enabled screen zoom on max.

@lukewalczak I think even with "large" display zoom, we should ensure there are 3 columns per row. If we need to adjust the spacing around grid items, widths, or font-sizes, then let's do that.

@iamthomasbishop
Copy link

Also, the other screenshots above (bottom sheet inset and landscape mode) look great 👍

@lukewalczak
Copy link
Member Author

UPDATES

Adjusted item width for a zoomed screen on Android:

regular zoomed
Screenshot 2020-02-04 at 11 17 24 Screenshot 2020-02-04 at 11 26 58

@etoledom
Copy link
Contributor

etoledom commented Feb 4, 2020

UPDATES

Adjusted item width for a zoomed screen on Android:

Looking great on Android now! 🎉
Thank you for the updates.

@etoledom It's hard to tell from the gif above, but does that mean you're not able to swipe to dismiss the sheet?

@iamthomasbishop no, it just tries to scroll the content.

Tbh, I was not able to reproduce it before refactor and after as well. Please check it one more time, if you will face that issue again, please send me some repro steps along with device configuration / specs 🙏

@lukewalczak you are right, it's not the normal behaviour, but a corner case. That's probably why you couldn't reproduce it. I was able to reproduce it on an iPhone XS with these steps:

  1. With the device on Landscape, open an image block's settings sheet.
  2. Start written a link or an Alt text.
  3. Notice that now the sheet is smaller than the available space, so it becomes scrollable (that's good ✅ ). Also notice that the top went out of the screen (not so good, but not alarming).
  4. Scroll all the way until the Clear All Settings button is visible.
  5. With the Clear button visible and the keyboard still present, rotate the device to Portrait mode.
  6. Now the Bottom Sheet bounces being smaller than half screen.
  7. You can close it and open the same settings, and the problem persist without the need of the previous steps.

This being a corner case, I don't consider it a blocker for this PR, but it would be great to fix it if it's not too complex.

EDIT: Adding a video showing the steps to reproduce the issue: https://cloudup.com/cBxQc0qynbx

Let me know!

@lukewalczak
Copy link
Member Author

UPDATES

  • BottomSheet height fixed along with redundant scrolling

ezgif com-resize (2)

Copy link
Contributor

@etoledom etoledom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The remaining issues seem to be fixed. Looking great to me! 🎉

Super job @lukewalczak ! I'm so glad we will finally have a scrolling bottom sheet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants