Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(rn): fix tabBar add QueryReducer
Signed-off-by: Godefroy Ponsinet <godefroy.ponsinet@outlook.com>
- Loading branch information
Showing
7 changed files
with
156 additions
and
101 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,35 @@ | ||
import { createBottomTabNavigator } from 'react-navigation' | ||
import createTabNavigator from 'react-navigation-deprecated-tab-navigator/src/createTabNavigator' | ||
import Contacts from './Contacts' | ||
import Chats from './Chats' | ||
import Settings from './Settings' | ||
import { colors } from '../../constants' | ||
import { borderTop, shadow } from '../../styles' | ||
|
||
export default createBottomTabNavigator( | ||
export default createTabNavigator( | ||
{ | ||
Contacts, | ||
Chats, | ||
Settings, | ||
}, | ||
{ | ||
initialRouteName: 'Chats', | ||
swipeEnabled: true, | ||
animationEnabled: true, | ||
tabBarPosition: 'bottom', | ||
tabBarOptions: { | ||
labelStyle: { | ||
color: colors.black, | ||
}, | ||
indicatorStyle: { | ||
backgroundColor: colors.black, | ||
}, | ||
style: [ | ||
{ | ||
backgroundColor: colors.white, | ||
}, | ||
borderTop, | ||
shadow, | ||
], | ||
}, | ||
} | ||
) |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import React from 'react' | ||
import Relay from 'react-relay' | ||
import environment from './environment' | ||
|
||
const handleChildren = (children, state, retry) => { | ||
if (typeof children === 'function') { | ||
return children(state, retry) | ||
} | ||
return React.Children.map(children, child => | ||
React.cloneElement(child, { relay: { state, retry } }) | ||
) | ||
} | ||
|
||
const QueryReducer = ({ children, ...props }) => ( | ||
<Relay.QueryRenderer | ||
environment={environment} | ||
{...props} | ||
render={({ error, props, retry }) => { | ||
if (!error && !props) { | ||
return handleChildren( | ||
children, | ||
{ | ||
type: 'loading', | ||
loading: 'loading', | ||
data: {}, | ||
}, | ||
retry | ||
) | ||
} | ||
if (!error) { | ||
return handleChildren( | ||
children, | ||
{ | ||
type: 'success', | ||
success: 'success', | ||
data: props, | ||
}, | ||
retry | ||
) | ||
} | ||
if (!props) { | ||
return handleChildren( | ||
children, | ||
{ | ||
type: 'error', | ||
error: 'error', | ||
data: error, | ||
}, | ||
retry | ||
) | ||
} | ||
}} | ||
/> | ||
) | ||
|
||
export default QueryReducer |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export environment, { fetchQuery } from './environment' | ||
export commit from './commit' | ||
export QueryReducer from './QueryReducer.js' |