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

Group Nav: Use ScrollView instead of View #4513

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

im-adithya
Copy link
Contributor

Description

This PR updates TitleGroup.js to use ScrollView so that the avatars don't overflow
and can be scrolled to view entire contents.

Issues related to PR

Fixes issue: #3700

Screenshots

Normal:

On rotating screen:

Copy link
Contributor

@chrisbobbe chrisbobbe left a comment

Choose a reason for hiding this comment

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

Thanks, @im-adithya! I've just tried this out on my iPhone, and it's looking good.

A nice-to-have would be a more graceful way to handle the left and right sides of the fixed rectangle, the one that acts as a "window" onto the content that scrolls left and right. Right now, it just ends abruptly:

110251137-23176800-7fa5-11eb-8169-02c0ab85a541

I seem to remember a pattern where a rectangle like this fades into the background at the edge. Here's a Stack Overflow answer with an image that conveys what I'm thinking of (screenshot below):

image

(We'd leave out the users' names.)

Am I imagining things, or is that a common pattern to use?

I see a prop for ScrollView called FadingEdgeLength that might do something like what I'm thinking of. What happens if you use something greater than zero for that prop? Looks like it's Android-only, though, hmm.

A small nit in the commit message: instead of "Fixes #3700", our habit is to say "Fixes: #3700" (note the colon).

@@ -22,7 +22,7 @@ const componentStyles = createStyleSheet({
export default function TitleGroup(props: Props) {
const { userIds } = props;
return (
<View style={styles.navWrapper}>
<ScrollView horizontal showsHorizontalScrollIndicator={false}>
Copy link
Contributor

@chrisbobbe chrisbobbe Mar 16, 2021

Choose a reason for hiding this comment

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

What's the reason for removing the style={styles.navWrapper}? 🙂 I don't think I'm attached to it (though I haven't thought super hard about it yet). But if we remove it, I'd like to record a reason for doing so.

…Ah, I see that I get the following error if I try to add that back in on the ScrollView:

Invariant Violation: ScrollView child layout (["alignItems","justifyContent"]) must be applied through the contentContainerStyle prop.

What happens if you follow that recommendation, and apply alignItems and justifyContent through the contentContainerStyle prop, instead of the style prop?

Or is there some other motivation for dropping styles.navWrapper?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or is there some other motivation for dropping styles.navWrapper?

I thought it was of no use as the ScrollView horizontal is equivalent to flexDirection: row, and the spacing is taken care of by the marginRight property of the avatars

Copy link
Contributor

Choose a reason for hiding this comment

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

ScrollView horizontal is equivalent to flexDirection: row

This may sound a bit nit-picky, but this isn't really true. 🙂 Strictly speaking, they aren't equivalent: passing true for horizontal will help us have horizontal scrolling behavior, while flexDirection: 'row' will not (and it hasn't been; we've been setting that, and we don't have horizontal scrolling). Since we know of at least that difference, it might be useful to explore more, to help avoid accidentally introducing bugs.

What happens if you follow that recommendation, and apply alignItems and justifyContent through the contentContainerStyle prop, instead of the style prop?

Have you tried this out? 🙂 Do you notice anything?

@im-adithya
Copy link
Contributor Author

im-adithya commented Mar 16, 2021

Looks like it's Android-only, though, hmm.

So what should we do now? Can we use a component to solve this for both platforms or leave it as is for iOS? I found react-native-fading-edge as a good option after some research.

@im-adithya im-adithya force-pushed the task-avatars-overflow branch 2 times, most recently from 49a8bd8 to 6a7ac21 Compare March 18, 2021 02:46
@im-adithya im-adithya force-pushed the task-avatars-overflow branch from 6a7ac21 to 3cd6768 Compare April 2, 2021 14:04
@im-adithya
Copy link
Contributor Author

Sorry for being late! Added the fadingEdgeLength for now. See thread here

Here are the screenshots:
Screenshot_1617372778
Screenshot_1617372789

@chrisbobbe, Please review it now :)

@chrisbobbe
Copy link
Contributor

Sorry for being late!

No problem! 🙂

One nit I see is let's put a code comment on the Android-only prop that gives the fade effect, so we can tell it's Android-only without having to look it up (that seems like a useful thing to know right away when reading that code).

Updates TitleGroup to use ScrollView instead of View
so that the avatars in nav bar don't overflow and can
be scrolled to view.

Fixes: zulip#3700
@im-adithya im-adithya force-pushed the task-avatars-overflow branch from 3cd6768 to 725d29e Compare April 6, 2021 20:54
@im-adithya
Copy link
Contributor Author

Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants