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

[BottomNavigation] Added show and hide animations #55

Merged
merged 25 commits into from
Jan 10, 2017

Conversation

HofmannZ
Copy link
Contributor

@HofmannZ HofmannZ commented Dec 7, 2016

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} or shouldHide={true}. It follows the material design guidelines on motion and curves, we use this to hide the BottomNavigation when scrolling in a ScrollView.

HofmannZ and others added 8 commits December 6, 2016 17:35
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
constructor(props) {
super(props);
this.state = {
moveAnimated: new Animated.Value(0 - this.context.uiTheme.bottomNavigation.container.height),
Copy link
Owner

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?

Copy link
Contributor Author

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) {
Copy link
Owner

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 :)

Copy link
Contributor Author

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,
},
};
Copy link
Owner

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 }]>

@HofmannZ
Copy link
Contributor Author

HofmannZ commented Dec 7, 2016

I made some changes as requested, It should now suit better.

@HofmannZ
Copy link
Contributor Author

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

@xotahal
Copy link
Owner

xotahal commented Dec 19, 2016

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 ..

screen shot 2016-12-19 at 10 35 21 am

@HofmannZ
Copy link
Contributor Author

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 ;)

Copy link
Owner

@xotahal xotahal left a comment

Choose a reason for hiding this comment

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

Hey @HofmannZ :) Have you already tried somewhere? I've just pulled it and tried with demo app and the behaivour is strange. But maybe I use it in bad way.


hide = () => {
Animated.timing(this.state.moveAnimated, {
toValue: this.context.uiTheme.bottomNavigation.container.height,
Copy link
Owner

Choose a reason for hiding this comment

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

This is not correct. Because it always returns undefined. Another problem is when you override ...container.height it will return bad number.

Ends with this error:
screen shot 2017-01-03 at 7 40 18 pm

@xotahal
Copy link
Owner

xotahal commented Jan 3, 2017

When I fixed the ...height number it works like this:

untitled

But looks really good. Can't wait when we use it :)

@HofmannZ
Copy link
Contributor Author

HofmannZ commented Jan 3, 2017

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 also use the behavior on the Toolbar, because it should also hide as described in the Guidelines. I could set up a PR for that right away.

@HofmannZ
Copy link
Contributor Author

HofmannZ commented Jan 3, 2017

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 🤓.

@xotahal xotahal merged commit 663e417 into xotahal:HotmannZ Jan 10, 2017
@xotahal
Copy link
Owner

xotahal commented Jan 10, 2017

Thanks for that @HofmannZ ;)

xotahal pushed a commit that referenced this pull request Jan 10, 2017
* 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
xotahal added a commit that referenced this pull request Jan 10, 2017
* 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
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.

5 participants