-
-
Notifications
You must be signed in to change notification settings - Fork 673
home screen: Use material tabs for bottom navigation. #4176
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
Open
agrawal-d
wants to merge
1
commit into
zulip:main
Choose a base branch
from
agrawal-d:home-screen
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| /* @flow strict-local */ | ||
| import React from 'react'; | ||
| import { Platform } from 'react-native'; | ||
| import { createBottomTabNavigator } from 'react-navigation-tabs'; | ||
| import { Platform, Dimensions } from 'react-native'; | ||
| import { createMaterialTopTabNavigator } from 'react-navigation-tabs'; | ||
|
|
||
| import type { TabNavigationOptionsPropsType } from '../types'; | ||
| import tabsOptions from '../styles/tabs'; | ||
|
|
@@ -14,7 +14,7 @@ import { OwnAvatar } from '../common'; | |
| import IconUnreadConversations from '../nav/IconUnreadConversations'; | ||
| import ProfileCard from '../account-info/ProfileCard'; | ||
|
|
||
| export default createBottomTabNavigator( | ||
| export default createMaterialTopTabNavigator( | ||
| { | ||
| home: { | ||
| screen: HomeTab, | ||
|
|
@@ -62,6 +62,8 @@ export default createBottomTabNavigator( | |
| }, | ||
| { | ||
| backBehavior: 'none', | ||
| initialLayout: { width: Dimensions.get('window').width }, | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is required to prevent a layout bug that happens in the first few moments of initial render. |
||
| tabBarPosition: 'bottom', | ||
| ...tabsOptions({ | ||
| showLabel: !!Platform.isPad, | ||
| showIcon: true, | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, interesting. I wonder why this still puts the tabs on the bottom, when it looks like we're asking for it to make a "top" tab navigator here.
To get the buttons to show feedback, I wonder about still using
createBottomTabNavigator, but with something special for thetabBarButtonsetting: https://reactnavigation.org/docs/bottom-tab-navigator/#tabbarbuttonThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's at the bottom because I passed this option in line 66:
tabBarPosition: 'bottom'I tried
Touchablefrom our 'commons', but it did not give any feedback at all - because it changes opacity on tap, and that does not change the appearance in this case, and also causes a weird layout bug for our 'PMs' icon - because it comes with an unread count indicator, and it becomes misplaced.I feel material tabs are a good option, because they provide good feedback without an additional setup, along with a nice indicator for the active tab.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I think the problem I have is that createMaterialTopTabNavigator is...just that, a thing to get material tabs at the top. From the doc:
Aha, though! After taking a look at the documentation, it looks like there may be a compromise between
createBottomTabNavigatorandcreateMaterialTopTabNavigator:createMaterialBottomTabNavigatorHave you tried that? 🙂
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I already tried that. But we don't have access to
createMaterialBottomTabNavigator- the package we use - 'react-navigation-tabs' only provides two exports:So, I didn't want to add an extra dependency for material bottom tabs when I was able to use material top tabs. Do you want me to add the dependency
createMaterialBottomTabNavigator(yarn add @react-navigation/bottom-tabs) or is this fine? I guess if I do add the dependency, I'll also have to create a flow libdef.I think we should not add an extra dependency when we are able to configure
createMaterialTopTabNavigatorto do the job, but I'll let you make the final decision.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mm, earlier, I didn't see that
createMaterialBottomTabNavigatormeans adding another dependency (actually two; the doc says to installreact-navigation-material-bottom-tabsandreact-native-paper). This would still be true after #4114, ascreateMaterialBottomTabNavigatorisn't exposed by the plainreact-navigationlibrary. Making a libdef can be a pain, but it can also be pretty straightforward; we have a growing doc about it, which it may be productive to add to.I'm still a bit torn; @gnprice, do you have thoughts on this? Someday, without declaring it as a breaking change,
createMaterialTopTabNavigatorcould reasonably drop the ability to be hacked into showing bottom tabs instead of top tabs.I've just tested out
createMaterialBottomTabNavigator; it worked with these versions:"react-navigation-material-bottom-tabs": "^0.4.0"(any later, and there are issues with its dependencies or peerDependencies)"react-native-paper": "^2.0.1"(react-navigation-material-bottom-tabshas this in its peerDependencies)Just replacing
createBottomTabNavigatorwithcreateMaterialBottomTabNavigator, and not adding any additional config, this is what it looks like on Android and iOS. It's quite different from what we have now, but there's lots of config available:On Android, there is a "ripple" effect, like the animation at this doc except the colors don't change (looks like you can optionally give a different color to each tab). It looks like there's no feedback, by default, on iOS. (The latest version explicitly documents a way to switch out the
TouchableWithoutFeedbackcomponent) .I do slightly prefer the way it shows which tab is selected; in particular, I like seeing the smooth appearance and disappearance of the tab's name in addition to the icon. We likely wouldn't choose this indigo color, but I like how the icons are translucent when not focused.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh, though it does more closely match the new logo we now have! #4200
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Luckily, our app uses global constants for the theme colours everywhere, so it will be very easy to change the theme colours in other places too.