Skip to content

Commit

Permalink
feat: top back & responsive desktop
Browse files Browse the repository at this point in the history
  • Loading branch information
glouvigny committed Mar 19, 2019
1 parent f2550b4 commit 32605aa
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
Expand Up @@ -36,7 +36,10 @@ const BackActionProvider = ({ navigation, children }) => {
splitNavigator.dispatch(NavigationActions.navigate({ routeName: shownPaneRouteName }))
}

navigation.goBack(...args)
if (navigation.goBack(...args) === false) {
navigation.navigate('placeholder')
splitNavigator.dispatch(NavigationActions.navigate({ routeName: 'placeholder' }))
}
}

return children({ goBack })
Expand Down
34 changes: 31 additions & 3 deletions client/react-native/common/components/Navigator/SplitNavigator.js
@@ -1,19 +1,47 @@
import React from 'react'
import { View } from 'react-native'
import { Dimensions, View } from 'react-native'
import createTabNavigator from 'react-navigation-tabs/src/utils/createTabNavigator'
import { createSwitchNavigator, createBottomTabNavigator } from 'react-navigation'

class SplitterView extends React.PureComponent {
constructor (props) {
super(props)

this.state = this.getDims()
}

getDims () {
return Dimensions.get('window') || Dimensions.get('screen') || { height: 0, width: 0 }
}

componentDidMount () {
if (this._screenSizeWatcher === undefined) {
this._screenSizeWatcher = (...args) => this.screenSizeWatcher(...args)
}
Dimensions.addEventListener('change', this._screenSizeWatcher)
}

componentWillUnmount () {
Dimensions.removeEventListener('change', this._screenSizeWatcher)
}

screenSizeWatcher () {
this.setState(this.getDims())
}

render () {
const { renderScene } = this.props
const { navigation } = this.props
const { state } = navigation

const narrow = this.state.width <= 750
const isPlaceholder = state.routes[1].routes[state.routes[1].index].routeName === 'placeholder'

return <View style={{ flex: 1, flexDirection: 'row' }}>
<View style={{ width: 400 }}>
<View style={{ width: narrow ? '100%' : 350, display: narrow && !isPlaceholder ? 'none' : 'flex' }}>
{renderScene({ route: state.routes[0] })}
</View>
<View style={{ flex: 1 }}>
<View style={{ flex: 1, display: narrow && isPlaceholder ? 'none' : 'flex' }}>
{renderScene({ route: state.routes[1] })}
</View>
</View>
Expand Down

0 comments on commit 32605aa

Please sign in to comment.