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
| constructor(initialState) { | |
| this.initialState = initialState; | |
| this._createClampedScroll(); | |
| this.scrollY.addListener(this._updateScroll); | |
| } | |
| _updateScroll = ({value}) => { | |
| const diff = value - this._scrollValue; | |
| this._scrollValue = Math.max(value, this.topPartHeight); // Fix normal state |
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
| scrollToOffset(offset, animated) { | |
| if(offset != this.scrollY._value) { | |
| this.initialState.scrollToOffset({offset, animated}); | |
| } | |
| } | |
| minimizeBar = () => { | |
| if(Math.round(this.scrollY._value) == 0) { // Full | |
| this.scrollToOffset(this.topPartHeight); | |
| } else { // Clamped |
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
| maxActionAnimated = 88; // Location input height + padding (Bottom part) | |
| actionAnimated = new Animated.Value(0); | |
| getTransformWrapper() { | |
| let byScroll = Animated.add( | |
| Animated.multiply(this.clampedScroll, -1), | |
| this.scrollY.interpolate({ // To negative | |
| inputRange: [0, 1], | |
| outputRange: [0, -1], | |
| }).interpolate({ // Add bottom height part |
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
| _setStateBar(state) { | |
| let toValue = state == 'full' ? this.maxActionAnimated : 0; | |
| Animated.timing(this.actionAnimated, { | |
| toValue: toValue, | |
| duration: 250, | |
| useNativeDriver: true, | |
| }).start(); | |
| } | |
| minimizeBar = () => { |
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
| _handleIntermediateState = (scrollToOffset) => { | |
| let scrollY = this.scrollY._value; | |
| if(scrollY < this.topPartHeight) { // Full | |
| scrollToOffset(scrollY > (this.topPartHeight / 2) ? this.topPartHeight : 0); | |
| } else { // Clamped | |
| if( | |
| this._clampedScrollValue < this.maxClamp && | |
| this._clampedScrollValue > this.minClamp | |
| ) { | |
| let scrollTo; |
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
| _updateScroll = ({value, manually}) => { | |
| if(value && manually) { | |
| this._clampedScrollValue = value; | |
| } else { | |
| const diff = value - this._scrollValue; | |
| this._scrollValue = Math.max(value, this.topPartHeight); // Fix normal state | |
| this._clampedScrollValue = Math.min( | |
| Math.max(this._clampedScrollValue + diff, this.minClamp), | |
| this.maxClamp | |
| ); |
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
| [...] | |
| _renderHeader = (animation, canJumpToTab) => props => ( | |
| <SearchBar | |
| animation={animation} | |
| changeInputFocus={suggestionFocus => | |
| this.setState({suggestionFocus}) | |
| } | |
| renderTabBar={() => ( | |
| <TabBar | |
| onTabPress={({route}) => { |
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
| export default class SearchBarProvider extends React.Component { | |
| constructor(props) { | |
| super(props); | |
| [...] | |
| this.state = { | |
| currentTab: null, | |
| canJumpToTab: true, | |
| contextProvider: { | |
| animation: this.searchBarAnimation.animationProps, |
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
| class FlatListHelper extends React.PureComponent { | |
| [...] | |
| _onMomentumScrollBegin = () => this.props._canJumpToTab(false); | |
| _onMomentumScrollEnd = () => this.props._canJumpToTab(true); | |
| [...] | |
| render() { |
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
| class FlatListHelper extends React.PureComponent { | |
| [...] | |
| _onScrollEndDrag = e => { | |
| if(e.nativeEvent.velocity.y == 0) { | |
| this.props.animation.handleIntermediateState(this.scrollToOffset); | |
| } | |
| }; | |
| [...] |