-
Notifications
You must be signed in to change notification settings - Fork 610
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
[BottomNavigation] Added show and hide animations #55
Conversation
Fix bottom navigation component
All platforms (iOS, android and 3rd party windows) implements BackAndroid (iOS mocks it).
* Add bottom navigation component * Fixed a bug where the list item component uses the wrong then color refrence * Fixed a bug where the list item component uses a static background instad of canvas collor * Added onPress ad required prop type * Fix bottom navigation component - moves BottomNavigationAction under BottomNavigation.Action - makes styles global, moves them to getTheme.js - adds ability to use action without label - adds missing paddingTop - adds missing comments - fixes lint
…g the material design mation guidelines
constructor(props) { | ||
super(props); | ||
this.state = { | ||
moveAnimated: new Animated.Value(0 - this.context.uiTheme.bottomNavigation.container.height), |
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.
There should be something like this:
constructor(props, context) {
super(props, context);
.... context.uiTheme ...
}
First question:
Does it work? :) Because the bottomNavigation is StylSheet and you should use this method to access to height
. I'll try it later as well.
Second question:
Why we need bottom navigation to start as hidden?
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.
Yeah, I have it configured to animate in at mount, but I think it's more appropriate to init it in view. That will mean there is no need for the context in the constructor.
this._show(); | ||
} | ||
|
||
if (nextProps.shouldHide !== this.props.shouldHide && nextProps.shouldHide === true) { |
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.
There should be just one property to control if the bottom navigation is visible or not ...
Modal uses visible
Status bar uses hidden
So, pick one of them ;) Status bar is probably more similar to bottom navigation. And please, give it to propTypes
:)
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 will change that up
container: { | ||
bottom: this.state.moveAnimated, | ||
}, | ||
}; |
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.
First of all:
getStyles
should return complete styles. So, you can move the local
object to get styles method and pass the this.state
to getStyles
method as a third param. As I did it here
But:
IMHO it's better to use it directly in animated.view since it's instance of Animated.Value
. Because it's kind of internal state of current position of view and if someone passes style prop to BottomNavigation, he could rewrite your animated value, because user's style has always the biggest priority
<Animated.View style={[styles.container, { bottom: this.state.moveAnimated }]>
I made some changes as requested, It should now suit better. |
Hey man, still waiting for this PR to be merged, this is the feature from the guideline that it implements: https://material.io/guidelines/components/bottom-navigation.html#bottom-navigation-behavior |
Sorry for that @HofmannZ, I've just fetched the current version and there is kind of problem. Could you merge it with master and run eslint and test - I've just made a revision of eslint and jest, now I have to write a documentation about it :) There will be just small issues, fix them and it's ready I think .. |
…es. (xotahal#62) * [BottomNavigation] Ability to handle custom Icons instead of icon names. * Fix PropTypes.
…y has some small issues.
Fixed those small issues, also merged with your master and ran the new Jest tests. All test suites passed. All ready to merge with master ;) |
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.
|
||
hide = () => { | ||
Animated.timing(this.state.moveAnimated, { | ||
toValue: this.context.uiTheme.bottomNavigation.container.height, |
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.
Did not try the demo app, my bad on that one. I made some little changes as well, where we only useNativeDriver on android and not on iOS. Seems to be a little funky on iOS. |
Could not connect the demo app's dev server to my iPhone due to a small change in the iOS source code, already did a quick PR with the fix 🤓. |
Fix getting height of bottom navigation
Thanks for that @HofmannZ ;) |
* Remove code specific to Android in Toolbar Search (#54) All platforms (iOS, android and 3rd party windows) implements BackAndroid (iOS mocks it). * [BottomNavigation] Added component (#52) * Add bottom navigation component * Fixed a bug where the list item component uses the wrong then color refrence * Fixed a bug where the list item component uses a static background instad of canvas collor * Added onPress ad required prop type * Fix bottom navigation component - moves BottomNavigationAction under BottomNavigation.Action - makes styles global, moves them to getTheme.js - adds ability to use action without label - adds missing paddingTop - adds missing comments - fixes lint * Update BottomNavigation.md * Update README.md * Delete BottomNavigationAction.md * Bump version * Added show and hide animations to BottomNavigation component following the material design mation guidelines * Edit based on feedback in pull request * Fix eslint errors * Update jest * Add snapshot tests for Subheader * Add circle.yml * Update codecov.yml * Add codecov.io (#57) * Add tests for Container.react.js * Update README.md * [BottomNavigation] Ability to handle custom Icons instead of icon names. (#62) * [BottomNavigation] Ability to handle custom Icons instead of icon names. * Fix PropTypes. * [RippleFeedback] Use TouchableOpacity for iOS (#41) (#64) * Minor bug fix and added nativa animation driver support for android * Fixed lint error. * Added useNAtiveDriver and fixed the heigth issue * Fix getting height of bottom navigation
* Added bottom navigation component with dacumentation, as dricribed in the material design guidelines * Fixed a bug where the list item component uses a static background instad of canvas collor * Added onPress ad required prop type * Fix bottom navigation component - moves BottomNavigationAction under BottomNavigation.Action - makes styles global, moves them to getTheme.js - adds ability to use action without label - adds missing paddingTop - adds missing comments - fixes lint * [BottomNavigation] Add show and hide animations (#55) * Remove code specific to Android in Toolbar Search (#54) All platforms (iOS, android and 3rd party windows) implements BackAndroid (iOS mocks it). * [BottomNavigation] Added component (#52) * Add bottom navigation component * Fixed a bug where the list item component uses the wrong then color refrence * Fixed a bug where the list item component uses a static background instad of canvas collor * Added onPress ad required prop type * Fix bottom navigation component - moves BottomNavigationAction under BottomNavigation.Action - makes styles global, moves them to getTheme.js - adds ability to use action without label - adds missing paddingTop - adds missing comments - fixes lint * Update BottomNavigation.md * Update README.md * Delete BottomNavigationAction.md * Bump version * Added show and hide animations to BottomNavigation component following the material design mation guidelines * Edit based on feedback in pull request * Fix eslint errors * Update jest * Add snapshot tests for Subheader * Add circle.yml * Update codecov.yml * Add codecov.io (#57) * Add tests for Container.react.js * Update README.md * [BottomNavigation] Ability to handle custom Icons instead of icon names. (#62) * [BottomNavigation] Ability to handle custom Icons instead of icon names. * Fix PropTypes. * [RippleFeedback] Use TouchableOpacity for iOS (#41) (#64) * Minor bug fix and added nativa animation driver support for android * Fixed lint error. * Added useNAtiveDriver and fixed the heigth issue * Fix getting height of bottom navigation * Fix eslint
I just added some show and hide animations to the BottomNavigation component.
It can be passed as a prop to the component like
shouldShow={true}
orshouldHide={true}
. It follows the material design guidelines on motion and curves, we use this to hide the BottomNavigation when scrolling in a ScrollView.