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",
"version": "1.0.0-beta.13",
"version": "1.0.0-beta.14",
"main": "src/index.js",
"repository": {
"url": "https://github.com/morten-olsen/react-native-debugger"

View File

@@ -68,7 +68,7 @@ const formatData = (data, options) => {
theme={theme}
data={{
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() {
const {
includeStackTrace,
...others,
} = this.props;
return (
@@ -63,7 +63,7 @@ class Events extends Component {
enabled
>
<DevTool
includeStackTrace={includeStackTrace}
{...others}
onClose={() => {
events.publish('HIDE_DEVTOOLS');
}}

View File

@@ -41,9 +41,30 @@ const Button = styled.TouchableOpacity`
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 = ({
tabs,
buttons = [],
onClose,
onDownload,
}) => (
@@ -55,9 +76,11 @@ const Console = ({
>
{({ active }, setState) => (
<Fragment>
<View style={styles.tabs}>
<Header>
<TabScroll horizontal>
<TabWrapper>
{tabs.map(({ name }, i) => (
<TouchableOpacity
<Tab
key={name}
style={active === i ? styles.tabActive : styles.tabInactive}
onPress={() => {
@@ -65,8 +88,10 @@ const Console = ({
}}
>
<Text>{name}</Text>
</TouchableOpacity>
</Tab>
))}
</TabWrapper>
</TabScroll>
{onDownload && (
<Button
onPress={onDownload}
@@ -81,7 +106,7 @@ const Console = ({
<Icon name="close" />
</Button>
)}
</View>
</Header>
{tabs[active] && tabs[active].view}
</Fragment>
)}

View File

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