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
render() { | |
return ( | |
<SearchBarProvider currentTab={this.state.currentTab}> | |
{(animation, { canJumpToTab }) => | |
<View style={initialLayout}> | |
{Platform.OS === 'android' && | |
<StatusBar | |
translucent={true} | |
backgroundColor="transparent" | |
/> |
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
_onScrollEndDrag = e => { | |
let velocity = e.nativeEvent.velocity.y; | |
if(velocity == 0 || (isAndroid() && Math.abs(Math.round(velocity)) <= 2)) { | |
this.props.animation.handleIntermediateState(this.scrollToOffset); | |
} | |
}; |
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 SearchBar extends Component { | |
blurInputs() { | |
this.inputSearch.blur(); | |
this.inputLocation.blur(); | |
this.props.changeInputFocus(false); | |
} | |
render() { | |
const { animation, changeInputFocus, renderTabBar } = this.props; |
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
getOpacitySearchBar() { | |
return { | |
opacity: this.scrollY.interpolate({ | |
inputRange: [...], | |
outputRange: [1, 0], | |
extrapolate: 'clamp', | |
}) | |
}; | |
} |
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
getOpacitySearchBar() { | |
return { | |
opacity: this.scrollY.interpolate({ | |
inputRange: [...], | |
outputRange: [1, 0], | |
extrapolate: 'clamp', | |
}) | |
}; | |
} |
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 SearchBarAnimation { | |
statusBarHeight = 21; | |
wrapperHeight = 177; | |
paddingStatusBar = 41; | |
arrowHeight = 36 - ifIphoneX(2, 0); | |
topPartHeight = this.arrowHeight + 45 + 10; // arrowHeight + inputHeight + padding (Top part) | |
fullHeight = this.topPartHeight + 131; // = 222 | |
distanceRange = this.fullHeight - this.topPartHeight; | |
maxClamp = this.fullHeight - (this.paddingStatusBar + this.statusBarHeight); | |
minClamp = this.topPartHeight; |
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.searchBarAnimation = new SearchBarAnimation({ | |
scrollToOffset: (configScroll) => { | |
let tab = configScroll.tab ? configScroll.tab : this.props.currentTab; | |
let scrollToOffset = this._handlersScroll[tab]; | |
scrollToOffset && scrollToOffset(configScroll.offset, configScroll.animated); |
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
const AnimatedFlatList = Animated.createAnimatedComponent(FlatList); | |
class FlatListHelper extends React.PureComponent { | |
componentDidMount() { | |
let { tabRoute, animation, addHandlerScroll } = this.props; | |
addHandlerScroll(tabRoute, this.scrollToOffset); | |
setTimeout(() => { // Fix bug initialScroll set | |
this.scrollToOffset(animation.initialScroll, false) |
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
import React from 'react'; | |
import { View, StyleSheet } from 'react-native'; | |
import { FlatList } from '../searchBarAnimation'; | |
export default class Tab extends React.PureComponent { | |
constructor(props) { | |
super(props); | |
this.state = { | |
dataSource: Array(20).fill().map((_, index) => ({id: index})) |
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
import React from 'react'; | |
import { StyleSheet, Dimensions, Animated, View, Platform, StatusBar } from 'react-native'; | |
import { TabView, TabBar, SceneMap } from 'react-native-tab-view'; | |
import { SearchBarProvider } from './searchBarAnimation'; | |
import SearchBar from './components/SearchBar'; | |
import Tab from './tabs/Tab'; | |
import SearchBarSuggestion from './components/SearchBarSuggestion'; | |
import SearchBarLocationSuggestion from './components/SearchBarLocationSuggestion'; |
OlderNewer