fix: Enable additional tabs

This commit is contained in:
2018-09-04 15:32:27 +02:00
parent c8f41d45ea
commit 87bde4c742
5 changed files with 45 additions and 20 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "react-native-debug-console", "name": "react-native-debug-console",
"version": "1.0.0-beta.13", "version": "1.0.0-beta.14",
"main": "src/index.js", "main": "src/index.js",
"repository": { "repository": {
"url": "https://github.com/morten-olsen/react-native-debugger" "url": "https://github.com/morten-olsen/react-native-debugger"

View File

@@ -68,7 +68,7 @@ const formatData = (data, options) => {
theme={theme} theme={theme}
data={{ data={{
message: data.toString(), message: data.toString(),
stackTrace: data.stack.toString(), stackTrace: data.stack ? data.stack.toString() : undefined,
}} }}
/> />
); );

View File

@@ -42,7 +42,7 @@ class Events extends Component {
render() { render() {
const { const {
includeStackTrace, ...others,
} = this.props; } = this.props;
return ( return (
@@ -63,7 +63,7 @@ class Events extends Component {
enabled enabled
> >
<DevTool <DevTool
includeStackTrace={includeStackTrace} {...others}
onClose={() => { onClose={() => {
events.publish('HIDE_DEVTOOLS'); events.publish('HIDE_DEVTOOLS');
}} }}

View File

@@ -41,9 +41,30 @@ const Button = styled.TouchableOpacity`
padding: 10px 20px 10px 0; padding: 10px 20px 10px 0;
`; `;
const TabScroll = styled.ScrollView`
flex: 1;
border-right-width: 1px;
border-color: #ccc;
margin-right: 20px;
`;
const TabWrapper = styled.View`
flex-direction: row;
`;
const Header = styled.View`
flex-direction: row;
`;
const Tab = styled.TouchableOpacity`
align-items: center;
justify-content: center;
padding: 10px 20px;
flex: 1;
`
const Console = ({ const Console = ({
tabs, tabs,
buttons = [],
onClose, onClose,
onDownload, onDownload,
}) => ( }) => (
@@ -55,9 +76,11 @@ const Console = ({
> >
{({ active }, setState) => ( {({ active }, setState) => (
<Fragment> <Fragment>
<View style={styles.tabs}> <Header>
<TabScroll horizontal>
<TabWrapper>
{tabs.map(({ name }, i) => ( {tabs.map(({ name }, i) => (
<TouchableOpacity <Tab
key={name} key={name}
style={active === i ? styles.tabActive : styles.tabInactive} style={active === i ? styles.tabActive : styles.tabInactive}
onPress={() => { onPress={() => {
@@ -65,8 +88,10 @@ const Console = ({
}} }}
> >
<Text>{name}</Text> <Text>{name}</Text>
</TouchableOpacity> </Tab>
))} ))}
</TabWrapper>
</TabScroll>
{onDownload && ( {onDownload && (
<Button <Button
onPress={onDownload} onPress={onDownload}
@@ -81,7 +106,7 @@ const Console = ({
<Icon name="close" /> <Icon name="close" />
</Button> </Button>
)} )}
</View> </Header>
{tabs[active] && tabs[active].view} {tabs[active] && tabs[active].view}
</Fragment> </Fragment>
)} )}

View File

@@ -25,7 +25,7 @@ const DevTool = ({
showNetwork = true, showNetwork = true,
showStorage = true, showStorage = true,
showConsole = true, showConsole = true,
additionTools = [], additionalTools = [],
}) => { }) => {
const views = []; const views = [];
@@ -52,7 +52,7 @@ const DevTool = ({
}); });
} }
additionTools.forEach(tool => { additionalTools.forEach(tool => {
views.push(tool); views.push(tool);
}); });